]> git.saurik.com Git - apt.git/blobdiff - debian/apt.auto-removal.sh
CMake: Rewrite existing Documentation support and add doxygen
[apt.git] / debian / apt.auto-removal.sh
index f615fa67707e6cf5f3e9c3f1501a764b7b53750a..608d950b5d2fd779097352bd2e1ec907718222ef 100644 (file)
@@ -18,8 +18,7 @@ config_file="${APT_CONF_D}/01autoremove-kernels"
 eval $(apt-config shell DPKG Dir::bin::dpkg/f)
 test -n "$DPKG" || DPKG="/usr/bin/dpkg"
 
-
-list="$(${DPKG} -l | awk '/^[ih][^nc][ ]+(linux|kfreebsd|gnumach)-image-[0-9]+\./ && $2 !~ /-dbg$/ && $2 !~ /-dbgsym$/ { print $2,$3; }' \
+list="$("${DPKG}" -l | awk '/^[ih][^nc][ ]+(linux|kfreebsd|gnumach)-image-[0-9]+\./ && $2 !~ /-dbg(:.*)?$/ && $2 !~ /-dbgsym(:.*)?$/ { print $2,$3; }' \
    | sed -e 's#^\(linux\|kfreebsd\|gnumach\)-image-##' -e 's#:[^:]\+ # #')"
 debverlist="$(echo "$list" | cut -d' ' -f 2 | sort --unique --reverse --version-sort)"
 
@@ -39,7 +38,7 @@ $running_version
 $previous_version" | sort -u | sed -e '/^$/ d')"
 kernels="$( (echo "$1
 $unamer"; for deb in $debkernels; do echo "$list" | awk "\$2 == \"$deb\" { print \$1; }"; done; ) \
-   | sed -e 's#\.#\\.#g' -e '/^$/ d' | sort -u)"
+   | sed -e 's#\([\.\+]\)#\\\1#g' -e '/^$/ d' | sort -u)"
 
 generateconfig() {
        cat <<EOF
@@ -47,13 +46,33 @@ generateconfig() {
 APT::NeverAutoRemove
 {
 EOF
-       apt-config dump --no-empty --format '%v%n' 'APT::VersionedKernelPackages' | while read package; do
+       for package in $(apt-config dump --no-empty --format '%v%n' 'APT::VersionedKernelPackages'); do
                for kernel in $kernels; do
                        echo "   \"^${package}-${kernel}$\";"
                done
        done
        echo '};'
+       if [ "${APT_AUTO_REMOVAL_KERNELS_DEBUG:-true}" = 'true' ]; then
+               cat <<EOF
+/* Debug information:
+# dpkg list:
+$(dpkg -l | grep '\(linux\|kfreebsd\|gnumach\)-image-')
+# list of installed kernel packages:
+$list
+# list of different kernel versions:
+$debverlist
+# Installing kernel: $installed_version ($1)
+# Running kernel: $running_version ($unamer)
+# Last kernel: $latest_version
+# Previous kernel: $previous_version
+# Kernel versions list to keep:
+$debkernels
+# Kernel packages (version part) to protect:
+$kernels
+*/
+EOF
+       fi
 }
-generateconfig > "${config_file}.dpkg-new"
-mv "${config_file}.dpkg-new" "$config_file"
+generateconfig "$@" > "${config_file}.dpkg-new"
+mv -f "${config_file}.dpkg-new" "$config_file"
 chmod 444 "$config_file"