]>
Commit | Line | Data |
---|---|---|
b17a1cf3 SI |
1 | #! /bin/sh |
2 | set -e | |
3 | ||
fbf55ac2 | 4 | . /usr/share/pve-kernel-helper/scripts/functions |
b17a1cf3 SI |
5 | |
6 | eval "$(apt-config shell APT_CONF_D Dir::Etc::parts/d)" | |
7 | test -n "${APT_CONF_D}" || APT_CONF_D="/etc/apt/apt.conf.d" | |
8 | ||
9 | config_file="${APT_CONF_D}/76pveconf" | |
10 | ||
11 | generate_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: | |
4f11dd63 | 29 | $(dpkg -l | grep -F 'pve-kernel' || true) |
b17a1cf3 SI |
30 | # list of installed kernel packages: |
31 | $kernels | |
32 | */ | |
33 | EOF | |
34 | fi | |
35 | } | |
36 | ||
37 | generate_apt_config "$@" > "${config_file}.dpkg-new" | |
38 | mv -f "${config_file}.dpkg-new" "$config_file" | |
39 | chmod 444 "$config_file" |