proxmox-kernel-helper/proxmox-boot/proxmox-auto-removal
Fabian Grünbichler 96fa4a98ef rename /usr/share/pve-kernel-helper
and ensure upgrades that also involve a kernel install/uninstall/upgrade still
work by symlinking the old path to the new one.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-03-16 12:56:32 +01:00

40 lines
893 B
Bash
Executable File

#! /bin/sh
set -e
. /usr/share/proxmox-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"