[pkg-perl-tools] 01/03: examples/pbuilder-hooks/E10cleanup: use `apt-get indextargets' and `/usr/lib/apt/apt-helper cat-file'

gregor herrmann gregoa at debian.org
Sat Sep 9 16:21:29 UTC 2017


This is an automated email from the git hooks/post-receive script.

gregoa pushed a commit to branch master
in repository pkg-perl-tools.

commit 4a0e3eca80fd42fab9d85244f80ff1d51ef17efd
Author: gregor herrmann <gregoa at debian.org>
Date:   Sat Sep 9 18:15:11 2017 +0200

    examples/pbuilder-hooks/E10cleanup: use `apt-get indextargets' and `/usr/lib/apt/apt-helper cat-file'
    
    instead of grepping the Packages files directly.
    
    Guarded by a check for apt 1.1, so the old code is still there but only used
    in oldoldstable.
    
    Thanks: Julian Andres Klode for the bug report.
    Closes: #874778
---
 examples/pbuilder-hooks/E10cleanup | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/examples/pbuilder-hooks/E10cleanup b/examples/pbuilder-hooks/E10cleanup
index b8c51d4..e62b5e9 100755
--- a/examples/pbuilder-hooks/E10cleanup
+++ b/examples/pbuilder-hooks/E10cleanup
@@ -1,12 +1,20 @@
 #!/bin/sh
 
-# Copyright: 2012-2016 gregor herrmann <gregoa at debian.org>
+# Copyright: 2012-2017 gregor herrmann <gregoa at debian.org>
 #
 # This program is free software; you can redistribute it and/or modify it
 # under the same terms as Perl itself.
 
+APTVERSION=$(dpkg-query -f '${Version}\n' -W apt)
 pkgavail() {
-	grep -q "Package: $1" /var/lib/apt/lists/*_Packages
+	if dpkg --compare-versions "$APTVERSION" ge 1.1 ; then
+		for p in $(apt-get indextargets --format '$(FILENAME)' "Created-By: Packages") ; do
+			/usr/lib/apt/apt-helper cat-file $p | grep -q $1 && return 0
+		done
+		return 1
+	else
+		grep -q "Package: $1" /var/lib/apt/lists/*_Packages
+	fi
 }
 
 EAT=

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git



More information about the Pkg-perl-cvs-commits mailing list