tags 520650 + patch
thanks
On Sat, Mar 21, 2009 at 04:59:10PM +0100, Michael Schutte wrote:
> Package: devscripts
> Version: 2.10.47
> Severity: normal
>
> Hey,
>
> The seemingly low number of python-central users baffled me at first,
> the “Is this for real? Let’s try debhelper” test even more so. Then I
> realised that in my case, only the debian-multimedia repo and
> ftp.debian.org’s contrib and non-free packages were read by build-rdeps.
> The offender is this test from findsources(), line 150:
>
> | if (/$source_pattern/ and $sources_count <= 3) {
>
> If the second condition is dropped, all *_Sources files are processed.
> That’s better, but also doesn’t seem quite right. Perhaps it is best to
> check the matching Release files for “Origin: Debian”? I guess that
> would be the behaviour which most users expect.Here’s a patch which does the Release file dance. I haven’t written Perl for years, so please trust it as far as you can throw it. All the best, -- Michael Schutte <[email protected]>
Index: scripts/build-rdeps.pl
===================================================================
--- scripts/build-rdeps.pl (Revision 1843)
+++ scripts/build-rdeps.pl (Arbeitskopie)
@@ -51,6 +51,10 @@
Ignore the given component (e.g. main, contrib, non-free).
+=item B<--origin>
+
+Select another origin (such as "Debian") to be searched for build-depends.
+
=item B<-m> B<--print-maintainer>
Print the value of the maintainer field for each package.
@@ -82,15 +86,16 @@
my $version = '1.0';
my $dctrl = "/usr/bin/grep-dctrl";
my $sources_path = "/var/lib/apt/lists/";
-my $source_pattern = ".*_dists_(sid|unstable)_.*Sources\$";
+my $release_pattern = "(.*_dists_(sid|unstable))_Release\$";
+my %seen_origins;
my @source_files;
-my $sources_count=0;
my $opt_debug;
my $opt_update;
my $opt_sudo;
my $opt_maintainer;
my $opt_mainonly;
my $opt_distribution;
+my $opt_origin = "Debian";
my @opt_exclude_components;
if (!(-x $dctrl)) {
@@ -124,6 +129,8 @@
-m, --print-maintainer Print the maintainer information (experimental)
--distribution distribution Select a distribution to search for build-depends
(Default: unstable)
+ --origin origin Select an origin to search for build-depends
+ (Default: Debian)
--only-main Ignore contrib and non-free
--exclude-component COMPONENT Ignore the specified component (can be given multiple times)
@@ -133,6 +140,7 @@
# Sub to test if a given section shall be included in the result
sub test_for_valid_component {
+ $_ = shift;
if ($opt_mainonly and /(contrib|non-free)/) {
return -1;
}
@@ -142,20 +150,48 @@
}
}
- print STDERR "DEBUG: Component ($_) may not be excluded." if ($opt_debug);
+ print STDERR "DEBUG: Component ($_) may not be excluded.\n" if ($opt_debug);
return 0;
}
-sub findsources {
- if (/$source_pattern/ and $sources_count <= 3) {
- if (test_for_valid_component($_) == 0) {
- push(@source_files, $_);
- $sources_count+=1;
- print STDERR "DEBUG: Added source file: $_ (#$sources_count)\n" if ($opt_debug);
- }
+# Scan Release files and add appropriate Sources files
+sub readrelease {
+ my $file = $_;
+ my $base = $1;
+ open(RELEASE, "<$sources_path/$file");
+ while (<RELEASE>) {
+ if (/^Origin:\s*(.*)$/) {
+ # skip undesired origins
+ last if ($opt_origin) and ($1 ne $opt_origin);
+ # we also don't use an origin twice
+ last if $seen_origins{$1};
+ $seen_origins{$1} = 1;
+ }
+ elsif (/^(MD5|SHA)/) {
+ # from a list of checksums, grab names of Sources files
+ while (<RELEASE>) {
+ last unless /^ /;
+ if (/([^ ]+\/Sources)$/) {
+ addsources($base, $1);
+ }
+ }
+ last;
+ }
}
+ close(RELEASE);
}
+# Add a *_Sources file if test_for_valid_component likes it
+sub addsources {
+ my ($base, $filename) = @_;
+ $filename =~ s/\//_/g; # main/source/Sources
+ $filename = "${base}_${filename}"; # -> ftp.debian.org_..._main_source_Sources
+ if (test_for_valid_component($filename) == 0) {
+ push(@source_files, $filename);
+ print STDERR "DEBUG: Added source file: $_\n" if ($opt_debug);
+ }
+}
+
sub findreversebuilddeps {
my ($package, $source_file) = @_;
my %packages;
@@ -223,6 +259,7 @@
"distribution=s" => \$opt_distribution,
"only-main" => \$opt_mainonly,
"exclude-component=s" => \...@opt_exclude_components,
+ "origin=s" => \$opt_origin,
"d|debug" => \$opt_debug,
"h|help" => sub { usage; },
"v|version" => sub { version; }
@@ -248,12 +285,12 @@
}
if ($opt_distribution) {
- print STDERR "DEBUG: Setting distribution to $opt_distribution" if ($opt_debug);
- $source_pattern = ".*_dists_" . $opt_distribution . "_.*Sources\$";
+ print STDERR "DEBUG: Setting distribution to $opt_distribution\n" if ($opt_debug);
+ $release_pattern = "(.*_dists_" . $opt_distribution . ")_Release\$";
}
# Find sources files
-find(\&findsources, $sources_path);
+find(sub { readrelease($_) if /$release_pattern/ }, $sources_path);
if (($#source_files+1) <= 0) {
die "$progname: unable to find sources files.\nDid you forget to run apt-get update (or add --update to this command)?";
signature.asc
Description: Digital signature
