]> git.proxmox.com Git - pve-kernel-meta.git/blame - efiboot/pve-auto-removal
zz-pve-efiboot: adapt to static list of ESPs
[pve-kernel-meta.git] / efiboot / pve-auto-removal
CommitLineData
b17a1cf3
SI
1#! /bin/sh
2set -e
3
fbf55ac2 4. /usr/share/pve-kernel-helper/scripts/functions
b17a1cf3
SI
5
6eval "$(apt-config shell APT_CONF_D Dir::Etc::parts/d)"
7test -n "${APT_CONF_D}" || APT_CONF_D="/etc/apt/apt.conf.d"
8
9config_file="${APT_CONF_D}/76pveconf"
10
11generate_apt_config() {
12
13 kernels="$(kernel_keep_versions "$@")"
14
15 cat <<- EOF
16 // DO NOT EDIT! File autogenerated by $0
17 APT::NeverAutoRemove
18 {
19 EOF
20 for kernel in $kernels; do
21 escaped_kver="$(echo "$kernel" | sed -e 's#\([\.\+]\)#\\\1#g')"
22 echo " \"^pve-kernel-${escaped_kver}$\";"
23 done
24 echo '};'
25 if [ "${APT_AUTO_REMOVAL_KERNELS_DEBUG:-false}" = 'true' ]; then
26 cat <<-EOF
27 /* Debug information:
28 # dpkg list:
29 $(dpkg -l | grep 'pve-kernel')
30 # list of installed kernel packages:
31 $kernels
32 */
33 EOF
34 fi
35}
36
37generate_apt_config "$@" > "${config_file}.dpkg-new"
38mv -f "${config_file}.dpkg-new" "$config_file"
39chmod 444 "$config_file"