[Popcon-commits] cvs commit to popularity-contest by pere

popcon-commits at lists.alioth.debian.org popcon-commits@lists.alioth.debian.org
Mon Jul 4 21:47:22 UTC 2005


Update of /cvsroot/popcon/popularity-contest
In directory haydn:/tmp/cvs-serv12982

Modified Files:
	popularity-contest 
Log Message:
Rewrite popularity-contest to use dpkg-awk if dpkg-query is missing, to
make it compatible with dpkg versions before 1.10.  Drop versioned
dependency on dpkg.  This make a backport to woody trivial.


Index: popularity-contest
===================================================================
RCS file: /cvsroot/popcon/popularity-contest/popularity-contest,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- popularity-contest	7 Jun 2005 14:53:45 -0000	1.12
+++ popularity-contest	4 Jul 2005 21:47:20 -0000	1.13
@@ -58,8 +58,15 @@
 my $debarch = `dpkg --print-installation-architecture`;
 chomp $debarch;
 
+# Set if dpkg package version is older than 1.10, thus missing dpkg-query.
+my $olddpkg = 0;
+
 # Popcon release
-my $popconver=`dpkg-query --showformat='\${version}' --show popularity-contest`;
+my $popconver=`dpkg-query --showformat='\${version}' --show popularity-contest 2>/dev/null`;
+if ($?) {
+    $popconver = `dpkg-awk "Package: *popularity-contest.*" -- Version|grep ^Version|sed 's/^Version: //'`;
+    $olddpkg = 1;
+}
 
 # Initialise time computations
 
@@ -71,8 +78,11 @@
 my %popcon=();
 
 #Read dpkg database of installed packages
-
-open PACKAGES, "dpkg-query --show --showformat='\${status} \${package}\\n'|";
+if ($olddpkg) {
+    open PACKAGES, "dpkg-awk 'Status: .* installed' -- Package | grep '^Package:' | sed 's/^Package: /install ok installed /'|";
+} else {
+    open PACKAGES, "dpkg-query --show --showformat='\${status} \${package}\\n'|";
+}
 while (<PACKAGES>)
 {
   /^.*installed *(.+)$/ or next;





More information about the Popcon-commits mailing list