Bug#700472: Upgrade of the foreign arch libc6 causes service restart

2019-09-10 Thread Aurelien Jarno
On 2019-09-09 22:18, Sven Joachim wrote:
> Control: tags -1 + patch
> 
> On 2013-02-13 06:20 +0600, Andrey Rahmatullin wrote:
> 
> > Package: libc6
> > Version: 2.17-0experimental2
> > Severity: wishlist
> >
> > Filing as wishlist, maybe it's minor or even worse for some people.
> >
> > The postinst script of libc6 checks services that need to be restarted not
> > taking into account that those services may be of a different arch and so 
> > not
> > using the libc6 being upgraded. That also means when you upgrade both
> > libc6:amd64 and libc6:i386 you get double restart of all those services.
> 
> Today, upgrading libc6:amd64 and libc6:i386 to 2.29-1, I got annoyed by
> this again and had a look what needs to be done.  The attached patch
> (lightly tested, I have only a few amd64 and no i386 services running)
> appears to do the trick.  It also drops the need for awk in the
> maintainer scripts.
> 
> Feedback and brave testers welcome!

Thanks for the patch, I have just applied it.

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net



Processed: Re: Bug#700472: Upgrade of the foreign arch libc6 causes service restart

2019-09-09 Thread Debian Bug Tracking System
Processing control commands:

> tags -1 + patch
Bug #700472 [libc6] Upgrade of the foreign arch libc6 causes service restart
Bug #752527 [libc6] Upgrading libc6:i386 on amd64 restarts services
Added tag(s) patch.
Added tag(s) patch.

-- 
700472: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=700472
752527: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=752527
Debian Bug Tracking System
Contact ow...@bugs.debian.org with problems



Bug#700472: Upgrade of the foreign arch libc6 causes service restart

2019-09-09 Thread Sven Joachim
Control: tags -1 + patch

On 2013-02-13 06:20 +0600, Andrey Rahmatullin wrote:

> Package: libc6
> Version: 2.17-0experimental2
> Severity: wishlist
>
> Filing as wishlist, maybe it's minor or even worse for some people.
>
> The postinst script of libc6 checks services that need to be restarted not
> taking into account that those services may be of a different arch and so not
> using the libc6 being upgraded. That also means when you upgrade both
> libc6:amd64 and libc6:i386 you get double restart of all those services.

Today, upgrading libc6:amd64 and libc6:i386 to 2.29-1, I got annoyed by
this again and had a look what needs to be done.  The attached patch
(lightly tested, I have only a few amd64 and no i386 services running)
appears to do the trick.  It also drops the need for awk in the
maintainer scripts.

Feedback and brave testers welcome!

Cheers,
   Sven

From 8d3ef80d688b71503dc369b68bf0323349e9fbda Mon Sep 17 00:00:00 2001
From: Sven Joachim 
Date: Mon, 9 Sep 2019 13:46:28 +0200
Subject: [PATCH 1/1] Do not restart services of different architecture than
 libc

Only check services in packages which are of the same architecture, or
"arch:all".  This is most easily done by replacing the rather
convoluted way of parsing "dpkg --status" output by switching to a
more suitable output format of dpkg-query.  As a bonus, awk is no
longer used in the maintscripts.

Note that services in architecture-independent packages like
postgresql-common will still be restarted twice, since there is no
obvious way to tell the architecture of the actual binaries which need
to be re-executed.
---
 debian/script.in/nsscheck.sh | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/debian/script.in/nsscheck.sh b/debian/script.in/nsscheck.sh
index 80dfd2fb..623278c0 100644
--- a/debian/script.in/nsscheck.sh
+++ b/debian/script.in/nsscheck.sh
@@ -1,6 +1,8 @@
 	echo -n "Checking for services that may need to be restarted..."
-	# Only get the ones that are installed, and configured
-	check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
+	# Only get the ones that are installed, of the same architecture
+	# as libc (or arch all) and configured
+	check=$(dpkg-query -W -f='${binary:Package} ${Status} ${Architecture}\n' $check 2> /dev/null | \
+			grep -E "installed (all|${DPKG_MAINTSCRIPT_ARCH})$" | sed 's/[: ].*//')
 	# some init scripts don't match the package names
 	check=$(echo $check | \
 		sed -e's/\bapache2.2-common\b/apache2/g' \
--
2.23.0