]> git.saurik.com Git - apt.git/blobdiff - debian/apt.auto-removal.sh
use a configurable list of versioned kernel packages
[apt.git] / debian / apt.auto-removal.sh
index d105f440aa6f6601908c71ae35db247a00f8f70e..9c4a4157d5f0fed1aa55b485eac3282ad545f56c 100644 (file)
@@ -72,22 +72,23 @@ $previous_version
 EOF
 )
 
-cat > "$config_file".dpkg-new <<EOF
+generateconfig() {
+       cat <<EOF
 // File autogenerated by $0, do not edit
 APT
 {
   NeverAutoRemove
   {
 EOF
-for kernel in $kernels; do
-       echo "    \"^linux-image-${kernel}$\";" >> "$config_file".dpkg-new
-       echo "    \"^linux-image-extra-${kernel}$\";" >> "$config_file".dpkg-new
-       echo "    \"^linux-signed-image-${kernel}$\";" >> "$config_file".dpkg-new
-       echo "    \"^linux-backports-modules-.*-${kernel}$\";" >> "$config_file".dpkg-new
-       echo "    \"^linux-headers-${kernel}$\";" >> "$config_file".dpkg-new
-done
-cat >> "$config_file".dpkg-new <<EOF
+       apt-config dump --no-empty --format '%v%n' 'APT::VersionedKernelPackages' | while read package; do
+               for kernel in $kernels; do
+                       echo "    \"^${package}-${kernel}$\";"
+               done
+       done
+       cat <<EOF
   };
 };
 EOF
-mv "$config_file".dpkg-new "$config_file"
+}
+generateconfig > "${config_file}.dpkg-new"
+mv "${config_file}.dpkg-new" "$config_file"