[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#830159: apt-get autoremove removes kernels with "+" in the package name



On 07/06/2016 02:38 PM, Andrew Patterson wrote:
> 
> 
> On 07/06/2016 02:04 PM, Julian Andres Klode wrote:
>> On Wed, Jul 06, 2016 at 01:48:17PM -0600, Andrew Patterson wrote:
>>> Package: apt
>>> Version: 1.2.11
>>>
>>> When I run apt-get autoremove, apt will also remove kernels with a "+"
>>> in the package name, e.g,
>> [...]
>>> I have attached a patch that has a fix for this problem.
>>
>> Thanks for your patch!
>>
>> Can you also extend the test in test/integration/test-kernel-helper-autoremove? That
>> would be helpful to ensure it did not work before and works now. We could also do it
>> ourselves, but maybe you want to do it (looks more coherent that way!).
>>
> 
> I'll give it a try.
> 
>> Would be great if you could submit an updated patch with that in it (and a "Closes: #830159" as
>> a last line of the commit message, so we don't forget to close the bug) and in the right
>> format (see below).
>>
> 
> Will do.
> 
>>>
>>> -- 
>>> Andrew Patterson
>>> Hewlett-Packard Enterprise
>>
>>> commit 4c851c0d9b8d04e6c6aa44d1d380e139f0c2f7af
>>> Author: Andrew Patterson <andrew.patterson@hpe.com>
>>> Date:   Wed Jul 6 13:40:16 2016 -0600
>>
>> Please format patches with git-format patch, this cannot be applied
>> directly with git am.
>>
> 
> Sorry. I'll be better next time.
> 
> 

Here is the new version, formatted with git format-patch and with the requested test integration changes.

BTW, that test framework it pretty slick.

Andrew


-- 
Andrew Patterson
Hewlett-Packard Enterprise
>From 75d3da5fa3c9a19ed7bd90ecd64c95d715f120f8 Mon Sep 17 00:00:00 2001
From: Andrew Patterson <andrew.patterson@hpe.com>
Date: Wed, 6 Jul 2016 13:40:16 -0600
Subject: [PATCH] Add kernels with "+" in the package name to
 APT::NeverAutoRemove

Escape "+" in kernel package names when generating APT::NeverAutoRemove
list so it is not treated as a regular expression meta-character.

Closes: #830159
---
 debian/apt.auto-removal.sh                     | 2 +-
 test/integration/test-kernel-helper-autoremove | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/debian/apt.auto-removal.sh b/debian/apt.auto-removal.sh
index e7e2ca0..608d950 100644
--- a/debian/apt.auto-removal.sh
+++ b/debian/apt.auto-removal.sh
@@ -38,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
diff --git a/test/integration/test-kernel-helper-autoremove b/test/integration/test-kernel-helper-autoremove
index 2e8da1c..c49abef 100755
--- a/test/integration/test-kernel-helper-autoremove
+++ b/test/integration/test-kernel-helper-autoremove
@@ -21,6 +21,8 @@ insertinstalledpackage 'linux-image-amd64' 'amd64' '200-1'
 insertinstalledpackage 'linux-image-686-pae' 'i386' '300-1'
 # ensure that the '.' is really a dot and not a wildcard
 insertinstalledpackage 'linux-headers-1000000-1-generic' 'amd64' '100.0.0-1'
+# ensure that the '+' is really a plus and not a regexp quantifier
+insertinstalledpackage "${CURRENTKERNEL}+variant" 'amd64' '5-1'
 
 testsuccess aptmark auto "$CURRENTKERNEL" "${CURRENTKERNEL}-dbg" "${CURRENTKERNEL}-686-pae:i386" "${CURRENTKERNEL}-rt" \
 	'linux-image-1.0.0-2-generic' 'linux-image-100.0.0-1-generic' 'linux-headers-1000000-1-generic'
-- 
2.8.0.rc3


Reply to: