[Collab-qa-commits] r2084 - rc-buggy-leaf-packages

Alexander Reichle-Schmehl tolimar at alioth.debian.org
Wed Nov 9 14:50:52 UTC 2011


Author: tolimar
Date: 2011-11-09 14:50:51 +0000 (Wed, 09 Nov 2011)
New Revision: 2084

Added:
   rc-buggy-leaf-packages/check-rdeps
Modified:
   rc-buggy-leaf-packages/get-rcbuggy-leaf-packages
Log:
Use nthykier perl replacement for my grep



Added: rc-buggy-leaf-packages/check-rdeps
===================================================================
--- rc-buggy-leaf-packages/check-rdeps	                        (rev 0)
+++ rc-buggy-leaf-packages/check-rdeps	2011-11-09 14:50:51 UTC (rev 2084)
@@ -0,0 +1,117 @@
+#!/usr/bin/perl
+#
+# check-rdeps Sources-file Packages-$arch1 [... Packages-$arch2]
+#
+# and then pipe "<src>|X| <bin1> [... <binN>]" to it.  It filters
+# out all lines where the binaries have no rdepends.
+#
+# (note: X (in |X|) must be a number)
+#
+
+use strict;
+use warnings;
+
+# $rdeps{'binary-package'} = "count of $rdeps";
+my %rdeps = ();
+
+die "Usage: check-rdeps <Sources> <Packages1> [... PackagesN]\n"
+    unless scalar @ARGV > 1;
+
+foreach my $file (@ARGV) {
+    open my $fd, '<', $file or die "opening $file: $!";
+    _parse_file ($fd, \&_parse_pg);
+    close $fd;
+}
+
+while (my $line = <STDIN>) {
+    my $orig;
+    my $found = 0;
+    chomp $line;
+    next unless $line;
+    $orig = $line;
+    $line=~ s/^.*\|\d+\|\s*+//og;
+    foreach my $pkg (split m/\s++/, $line) {
+        if ($rdeps{$pkg}) {
+            $found = 1;
+            last;
+        }
+    }
+    print "$orig\n" unless $found;
+}
+
+exit 0;
+
+sub _parse_pg {
+    my ($pg) = @_;
+    foreach my $f (qw(pre-depends depends build-depends build-depends-indep)) {
+        my $v = $pg->{$f};
+        next unless $v;
+        # Strip architectures and versions
+        $v =~ s/\[[^\]]*\]//og;
+        $v =~ s/\([^\)]*\)//og;
+        foreach my $d (split m/\s*,\s*/o, $v) {
+            foreach my $alt (split m/\s*\|\s*/o, $d) {
+                $rdeps{$alt}++;
+            }
+        }
+    }
+}
+
+## More or less stolen from Lintian, so under GPL-2 and
+# (most likely) Copyright (C) 1998 Christian Schwarz
+sub _parse_file {
+    my ($fd, $code) = @_;
+    my $open_section = 0;
+    my $section;
+    my $last_tag;
+    while ( my $line = <$fd> ) {
+        chomp ($line);
+        if ($line =~ m/^\s*$/o) {
+            if ($open_section) { # end of current section
+                # pass the current section to the handler
+                $code->($section);
+                $section = {};
+                $open_section = 0;
+            }
+        }
+
+        if ($line =~ m/^([^: \t]+):\s*$/o) {
+            $open_section = 1;
+
+            my ($tag) = (lc $1);
+            $section->{$tag} = '';
+
+            $last_tag = $tag;
+        }
+        # new field?
+        elsif ($line =~ m/^([^: \t]+):\s*(.*)$/o) {
+            $open_section = 1;
+
+            # Policy: Horizontal whitespace (spaces and tabs) may occur
+            # immediately before or after the value and is ignored there.
+            my ($tag,$value) = (lc $1,$2);
+            $value =~ s/\s+$//;
+            $section->{$tag} = $value;
+
+            $last_tag = $tag;
+        }
+        # continued field?
+        elsif ($line =~ m/^([ \t].*)$/o) {
+            $open_section or next;
+
+            # Policy: Many fields' values may span several lines; in this case
+            # each continuation line must start with a space or a tab.  Any
+            # trailing spaces or tabs at the end of individual lines of a
+            # field value are ignored.
+            my $value = $1;
+            $value =~ s/\s+$//;
+            $section->{$last_tag} .= "\n" . $value;
+        } else {
+            next;
+        }
+    }
+
+    # pass the last section (if not already done).
+    $code->($section) if $open_section;
+}
+


Property changes on: rc-buggy-leaf-packages/check-rdeps
___________________________________________________________________
Added: svn:executable
   + *

Modified: rc-buggy-leaf-packages/get-rcbuggy-leaf-packages
===================================================================
--- rc-buggy-leaf-packages/get-rcbuggy-leaf-packages	2011-11-09 10:47:11 UTC (rev 2083)
+++ rc-buggy-leaf-packages/get-rcbuggy-leaf-packages	2011-11-09 14:50:51 UTC (rev 2084)
@@ -39,21 +39,23 @@
 # newlines; didn't find a away to parameter for psql to prevent that
 while read source rcbugs ; do echo -en "$source|$rcbugs|" ; /usr/bin/psql -h localhost -p 5441 -U guest -f source-builds.sql udd --tuples-only --set="source='$source'" |tr -d "\n" ; echo; done < $SOURCE_RCBUGS > $SOURCE_RCBUGS_BUILDS
 
-PATTERNS=$(mktemp)
+# temporary directory to store package indices
+PACKAGE_INDEX=$(mktemp -d)
 
-# now we create a list of dependencie patterns for a later grep
-# First we download the list of Source Packages and binary Packages and
-# extrect the depency and build-dependency lines
-# These lines are then reformat (removal of version number, archs and
-# alternatives), so we end up with one package per line.
-# The output format ".*|.*|.*$package" is needed as that is used as a
-# pattenr for the grep
-(wget -q -O- http://ftp.debian.org/debian/dists/testing/main/source/Sources.gz | zgrep Build-Depends:|sed -e "s/^Build-Depends: //;s/ \[.*\]//g;s/ (.*)//g;s/, /\n/g;s/ | /\n/g" ; wget -q -O- http://ftp.debian.org/debian/dists/testing/main/binary-amd64/Packages.gz | zgrep Depends:|sed -e "s/^Depends: //;s/ (.*)//g;s/, /\n/g;s/ | /\n/g" )|sort -u|while read depends ; do echo ".*|.*|.*$depends" ; done > $PATTERNS
+wget -q -O- "http://ftp.debian.org/debian/dists/testing/main/source/Sources.gz" | zcat > $PACKAGE_INDEX/Sources
+INDICES="$PACKAGE_INDEX/Sources"
 
-# Not we remove the lines matching the patterns we just created from the
-# source-rc-bugs-builds file.
-grep -v -f $PATTERNS $SOURCE_RCBUGS_BUILDS
+# architectures to consider
+ARCHS="amd64"
 
+for arch in $ARCHS ; do
+	wget -q -O- "http://ftp.debian.org/debian/dists/testing/main/binary-$arch/Packages.gz" | zcat > $PACKAGE_INDEX/Packages-$arch ;
+	INDICES="$INDICES $PACKAGE_INDEX/Packages-$arch"
+done
+
+# now filter out the packages with dependencies with nthykier perl code
+cat $SOURCE_RCBUGS_BUILDS | ./check-rdeps $INDICES
+
 # cleaning up our temporary files
-rm -f $PATTERNS $SOURCE_RCBUGS $SOURCE_RCBUGS_BUILDS
+rm -rf $SOURCE_RCBUGS $SOURCE_RCBUGS_BUILDS $PACKAGE_INDEX
 




More information about the Collab-qa-commits mailing list