Currently I have a script that works for me, it is attached. It works on Debian-format changelogs, and .changes files. Brief usage guide: changelogcloses package_1.2-3_i386.changes will print a list of bugs closed in that changes file, what package each belongs to, and whether that package is one that is relevant to the changes file (i.e., if there is a Binary: or Source: package that matches the bug's package). changelogcloses -h will print usage information. I can't currently implement LDAP querying because I don't have access to the server (Awaiting DAM Approval (tm)). Using the -i /path/to/index.db option will greatly improve the speed of access, by eliminating the BTS query. On master, use -i /debian2/org/bugs.debian.org/debbugs/spool/index.db Where should this check go? In lintian? In katie? In both? Away? If nobody comments on it, I'll package it separately, and write a lintian check for it if I get time to figure out the interface before Shaleh feature-freezes 1.20. -thomas -- Thomas Smith <tgs@finbar.dyndns.org> http://finbar.dyndns.org/ gpg key id 1024D/ACABA81E, fingerprint: 3A47 CFA5 0E5D CF4A 5B22 12D3 FF1B 84FE ACAB A81E
#!/usr/bin/perl -w # This is free software. # You may distribute it under the terms of the GNU # Lesser GPL, any version. # Copyright 2001 by Thomas Smith <chihuahua@tmbg.org> my $version = '$Id: changelogcloses,v 1.2 2001/02/18 00:05:35 tgs Exp $'; use strict; use Getopt::Std; use LWP::Simple; use URI; my (%opt, %index); getopts("i:hVp", \%opt); if ($opt{'h'}) { print "Usage:\n", " $0 [-i /path/to/index.db] [-hVp] <changes-file>\n", "Options:\n", " -i <file>\n", " Use <file> as an index, greatly reducing load on the BTS,\n", " and greatly increasing the speed of processing.\n", " -h\n", " Print this usage message, then exit.\n", " -V\n", " Print the CVS id (Version) and exit.\n", " -p\n", " Before the list of bugs, print a space-separated list of\n", " binary and source packages that belong to the package\n", " that <changes-file> belongs to.\n", " <changes-file>\n", " A .changes file, or a changelog in Debian format. A\n", " .changes file works better for multi-binary packages.\n", "Output:\n", " Outputs lines of the following form:\n", "<bug-number> <package> <bit>\n", " where <bug-number> is a bug number, as used in the BTS,\n", " <package> is the package to which the bug ``belongs'', or\n", " `[unknown-package]' if the bug does not have a package.\n", " <bit> is 1 if <package> is one of the packages to which\n", " the changes file belongs, or 0 otherwise.\n"; exit 0; } if ($opt{'V'}) { print $version, "\n"; exit 0; } if ($opt{'i'}) { local *INDEXDB; open(INDEXDB, "<", $opt{'i'}) or die "$! in index making"; while (<INDEXDB>) { m/^(\S+) (\d+)/; $index{$2} = $1; } close(INDEXDB) or warn "$! in index making"; } sub findpkg { my $bugid = shift; $bugid =~ s/\D//g; if (defined($index{$bugid})) { return $index{$bugid}; } else { my $buguri = URI->new("http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=$bugid"); my $bughtml = get($buguri); if (!defined($bughtml)) { # error in fetching, or server error return undef; } elsif ($bughtml =~ m/^<HTML><HEAD><TITLE>Error/) { # error in bts return undef; } else { $bughtml =~ m/^.*?Package: <A.*?>(.*?)<\/A>/s; return $1; } } } my (%pkg, $changes); while (<>) { $changes .= $_; } while ($changes =~ m/^(?:Source|Binary)\s*:\s*(.*)/mg) { foreach (split(/\s+/, $1)) { $pkg{$_} = 1; } } while ($changes =~ m/^([a-zA-Z0-9\-]+)\s+\(/mg) { foreach (split(/\s+/, $1)) { $pkg{$_} = 1; } } (print join(" ", keys %pkg), "\n") if ($opt{'p'}); my (@bugid); while ($changes =~ m/closes:\s*(?:bug)?\#\s*(\d+(?:,\s*(?:bug)?\#\s*\d+)*)/ig) { # regex is stolen from Developer's Reference, sec. 10.4, # current as of 14 Feb 2001. slightly modified. my $buglist = $1; push(@bugid, split(/\D+/, $buglist)); } if ($opt{'t'}) { #t is for test print join(" ", @bugid), "\n"; exit 0; } else { foreach (@bugid) { my $bugpkg = findpkg($_); if (defined($bugpkg)) { print join(" ", $_, $bugpkg, (exists($pkg{$bugpkg})) || "0"), "\n"; } else { print "$_ [unknown-package] 0\n"; } } }
Attachment:
pgpuyhmx6JFhG.pgp
Description: PGP signature