]>
git.saurik.com Git - apt.git/blob - debian/apt.auto-removal.sh
3 # Mark as not-for-autoremoval those kernel packages that are:
4 # - the currently booted version
5 # - the kernel version we've been called for
6 # - the latest kernel version (as determined by debian version number)
7 # - the second-latest kernel version
9 # In the common case this results in two kernels saved (booted into the
10 # second-latest kernel, we install the latest kernel in an upgrade), but
11 # can save up to four. Kernel refers here to a distinct release, which can
12 # potentially be installed in multiple flavours counting as one kernel.
14 eval $(apt-config shell APT_CONF_D Dir::Etc::parts/d)
15 test -n "${APT_CONF_D}" || APT_CONF_D
="/etc/apt/apt.conf.d"
16 config_file
="${APT_CONF_D}/01autoremove-kernels"
18 eval $(apt-config shell DPKG Dir::bin::dpkg/f)
19 test -n "$DPKG" || DPKG
="/usr/bin/dpkg"
22 list
="$(${DPKG} -l | awk '/^[ih][^nc][ ]+(linux|kfreebsd|gnumach)-image-[0-9]+\./ && $2 !~ /-dbg$/ && $2 !~ /-dbgsym$/ { print $2,$3; }' \
23 | sed -e 's#^\(linux\|kfreebsd\|gnumach\)-image-##' -e 's#:[^:]\+ # #')"
24 debverlist
="$(echo "$list" | cut -d' ' -f 2 | sort --unique --reverse --version-sort)"
27 installed_version
="$(echo "$list" | awk "\$1 == \"$1\" { print \$2;exit; }")"
30 if [ -n "$unamer" ]; then
31 running_version
="$(echo "$list" | awk "\$1 == \"$unamer\" { print \$2;exit; }")"
33 latest_version
="$(echo "$debverlist" | sed -n 1p)"
34 previous_version
="$(echo "$debverlist" | sed -n 2p)"
36 debkernels
="$(echo "$latest_version
39 $previous_version" | sort -u | sed -e '/^$/ d')"
41 $unamer"; for deb in $debkernels; do echo "$list" | awk "\
$2 == \"$deb\" { print \
$1; }"; done; ) \
42 | sed -e 's#\.#\\.#g' -e '/^$/ d' | sort -u)"
46 // DO NOT EDIT! File autogenerated by $0
50 apt
-config dump
--no-empty --format '%v%n' 'APT::VersionedKernelPackages' | while read package
; do
51 for kernel
in $kernels; do
52 echo " \"^${package}-${kernel}$\";"
57 generateconfig
> "${config_file}.dpkg-new"
58 mv "${config_file}.dpkg-new" "$config_file"
59 chmod 444 "$config_file"