pve-kernel-meta/efiboot/pve-auto-removal
Fabian Grünbichler 4f11dd6347 efiboot: guard against grep returning non-zero
which would trigger 'set -e', instead of continuing with correct (empty)
strings.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2019-07-15 14:28:21 +02:00

40 lines
889 B
Bash
Executable File

#! /bin/sh
set -e
. /usr/share/pve-kernel-helper/scripts/functions
eval "$(apt-config shell APT_CONF_D Dir::Etc::parts/d)"
test -n "${APT_CONF_D}" || APT_CONF_D="/etc/apt/apt.conf.d"
config_file="${APT_CONF_D}/76pveconf"
generate_apt_config() {
kernels="$(kernel_keep_versions "$@")"
cat <<- EOF
// DO NOT EDIT! File autogenerated by $0
APT::NeverAutoRemove
{
EOF
for kernel in $kernels; do
escaped_kver="$(echo "$kernel" | sed -e 's#\([\.\+]\)#\\\1#g')"
echo " \"^pve-kernel-${escaped_kver}$\";"
done
echo '};'
if [ "${APT_AUTO_REMOVAL_KERNELS_DEBUG:-false}" = 'true' ]; then
cat <<-EOF
/* Debug information:
# dpkg list:
$(dpkg -l | grep -F 'pve-kernel' || true)
# list of installed kernel packages:
$kernels
*/
EOF
fi
}
generate_apt_config "$@" > "${config_file}.dpkg-new"
mv -f "${config_file}.dpkg-new" "$config_file"
chmod 444 "$config_file"