File rpm-helper of Package libpulp.25800
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
USAGE="$0 <install|remove> <package> <version> <num_packages>"
if test "$1" = "-h" -o "$1" = "--help"; then
echo "$USAGE"
exit 0
fi
if test "$#" -lt 2; then
echo "$USAGE" >&2
exit 1
fi
# ulp trigger have problems with bash expanding its arguments. Disable that
# and let it expand the wildcard by itself.
shopt -s nullglob
check_livepatching_env()
{
[ -z "$PACKAGE" ] && return 0
COMPONENT=${PACKAGE%-livepatches}
COMPONENT=${COMPONENT^^}
COMPONENT=${COMPONENT/-/_}
CONF_VAR_NAME="LIVEPATCH_$COMPONENT"
eval "$CONF_VAR_NAME"=auto
# Check if a sysconfig for livepatching exists. If yes, include the file.
if test -f "/etc/sysconfig/livepatching"; then
. /etc/sysconfig/livepatching || :
fi
# We want to preserve the immutability of the system in the
# transactional server role. To that end, we define the "auto" patch
# deployment mode that skips the patch loading in transactional
# updates.
DO_PATCHING=0
[ "$TRANSACTIONAL_UPDATE" != "true" -a "${!CONF_VAR_NAME}" == "auto" ] && DO_PATCHING=1
[ "${!CONF_VAR_NAME}" == "always" ] && DO_PATCHING=1
[ "$DO_PATCHING" -eq 0 ] && return 1
return 0
}
do_install()
{
if test -e /.buildenv; then
echo "Skipping userspace live patches in buildroot"
return 0
fi
check_livepatching_env || return 0
# TODO: review if we need to guard against multiple patch application
echo -n '[ulp] '; ulp trigger --revert-all="$TARGET_LIB" "/usr/lib64/$PACKAGE/*.so"
}
do_remove()
{
: # reserved for future use
}
if test $# -ne 5; then
echo 'WARNING: Unexpected number of parameters. Are the live patch RPM scripts compatible with this rpm-helper?' >&2
fi
cmd=$1
PACKAGE=$2
VER=$3
TARGET_LIB=$4
NUM_PACKAGES=${5-0}
case "$cmd" in
install|remove)
do_$cmd
exit
;;
*)
echo "$USAGE" >&2
exit 1
esac