]>
git.saurik.com Git - apt.git/blob - debian/apt.auto-removal.sh
8f6fc2efcf522d99aa73e38c352e215d669a4544
5 # Author: Steve Langasek <steve.langasek@canonical.com>
7 # Mark as not-for-autoremoval those kernel packages that are:
8 # - the currently booted version
9 # - the kernel version we've been called for
10 # - the latest kernel version (determined using rules copied from the grub
11 # package for deciding which kernel to boot)
12 # In the common case, this results in exactly two kernels saved, but it can
13 # result in three kernels being saved. It's better to err on the side of
14 # saving too many kernels than saving too few.
16 # We generate this list and save it to /etc/apt/apt.conf.d instead of marking
17 # packages in the database because this runs from a postinst script, and apt
18 # will overwrite the db when it exits.
20 config_file
=/etc
/apt
/apt.conf.d
/01autoremove
-kernels
22 installed_version
="$1"
23 running_version
="$(uname -r)"
28 local version_test_gt_sedexp
="s/[._-]\(pre\|rc\|test\|git\|old\|trunk\)/~\1/g"
29 local version_a
="`echo "$1" | sed -e "$version_test_gt_sedexp"`"
30 local version_b
="`echo "$2" | sed -e "$version_test_gt_sedexp"`"
31 dpkg
--compare-versions "$version_a" gt
"$version_b"
35 list
=$(dpkg -l 'linux-image-[0-9]*'|awk '/^ii/ { print $2 }' | sed -e's/linux-image-//')
39 if version_test_gt
"$i" "$latest_version"; then
44 kernels
=$
(sort -u <<EOF
51 cat > "$config_file".dpkg
-new <<EOF
52 # File autogenerated by $0, do not edit
58 for kernel
in $kernels; do
59 echo " \"^linux-image-$kernel.*\";" >> "$config_file".dpkg
-new
60 echo " \"^linux-image-extra-$kernel.*\";" >> "$config_file".dpkg
-new
61 echo " \"^linux-signed-image-$kernel.*\";" >> "$config_file".dpkg
-new
63 cat >> "$config_file".dpkg
-new <<EOF
67 mv "$config_file".dpkg
-new "$config_file"