[devscripts] 02/03: build-rdeps: Use apt-helper's cat-file to read Sources files
James McCoy
jamessan at debian.org
Thu Sep 7 02:11:22 UTC 2017
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch master
in repository devscripts.
commit 480904f36a01f3ce5a4597bf0ea8f7bfe759a728
Author: James McCoy <jamessan at debian.org>
Date: Wed Sep 6 21:16:57 2017 -0400
build-rdeps: Use apt-helper's cat-file to read Sources files
Using cat-file allows us to reliably read the file, regardless of how
the user may have configured the storage of the lists files (e.g.,
compression) or future storage format changes.
Closes #698240
Signed-off-by: James McCoy <jamessan at debian.org>
---
debian/changelog | 4 ++++
scripts/build-rdeps.pl | 47 +++++++++++++++++++----------------------------
2 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 23610fa..86ae1c7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -31,6 +31,10 @@ devscripts (2.17.10) UNRELEASED; urgency=medium
+ Add "--" in --help output for debian/rules mode.
* test_package_lifecycle:
+ Fix expected output when run as root.
+ * build-rdeps:
+ + Use apt interfaces to find and read the sources files, fixing --old
+ (non-dose) behavior when sources files are compressed. (Closes:
+ #698240)
[ Daniel Shahaf ]
* bts:
diff --git a/scripts/build-rdeps.pl b/scripts/build-rdeps.pl
index 6fae3a3..c8f7e1d 100755
--- a/scripts/build-rdeps.pl
+++ b/scripts/build-rdeps.pl
@@ -156,10 +156,6 @@ my $opt_hostarch;
my $opt_without_ceve;
my $opt_quiet;
-if (system('command -v grep-dctrl >/dev/null 2>&1')) {
- die "$progname: Fatal error. grep-dctrl is not available.\nPlease install the 'dctrl-tools' package.\n";
-}
-
sub version {
print <<"EOT";
This is $progname $version, from the Debian devscripts package, v. ###VERSION###
@@ -349,37 +345,28 @@ sub findreversebuilddeps {
$count += 1;
}
} else {
- my %packages;
- my $depending_package;
- open(PACKAGES, '-|', 'grep-dctrl', '-r', '-F', 'Build-Depends,Build-Depends-Indep', "\\(^\\|, \\)$package", '-s', 'Package,Build-Depends,Build-Depends-Indep,Maintainer', $source_file);
+ open(my $out, '-|', '/usr/lib/apt/apt-helper', 'cat-file', $source_file)
+ or die "$progname: Unable to run \"apt-helper cat-file '$source_file'\": $!";
- while(<PACKAGES>) {
- chomp;
- print STDERR "$_\n" if ($opt_debug);
- if (/Package: (.*)$/) {
- $depending_package = $1;
- $packages{$depending_package}->{'Build-Depends'} = 0;
- }
- elsif (/Maintainer: (.*)$/) {
- if ($depending_package) {
- $packages{$depending_package}->{'Maintainer'} = $1;
- }
+ my %packages;
+ until (eof $out) {
+ my $ctrl = Dpkg::Control->new(type => CTRL_INDEX_SRC);
+ if (!$ctrl->parse($out, 'apt-helper cat-file')) {
+ next;
}
- elsif (/Build-Depends: (.*)$/ or /Build-Depends-Indep: (.*)$/) {
- if ($depending_package) {
- print STDERR "$1\n" if ($opt_debug);
- if ($1 =~ /^(.*\s)?\Q$package\E(?::[a-zA-Z0-9][a-zA-Z0-9-]*)?([\s,]|$)/) {
- $packages{$depending_package}->{'Build-Depends'} = 1;
+ print STDERR "$ctrl\n" if ($opt_debug);
+ for my $relation (qw(Build-Depends Build-Depends-Indep)) {
+ if (exists $ctrl->{$relation}) {
+ if ($ctrl->{$relation} =~ m/^(.*\s)?\Q$package\E(?::[a-zA-Z0-9][a-zA-Z0-9-]*)?([\s,]|$)/) {
+ $packages{$ctrl->{Package}}{Maintainer} = $ctrl->{Maintainer};
}
}
}
}
- while($depending_package = each(%packages)) {
- if ($packages{$depending_package}->{'Build-Depends'} != 1) {
- print STDERR "Ignoring package $depending_package because its not really build depending on $package.\n" if ($opt_debug);
- next;
- }
+ close($out);
+
+ while (my $depending_package = each(%packages)) {
print $depending_package;
if ($opt_maintainer) {
print " ($packages{$depending_package}->{'Maintainer'})";
@@ -462,6 +449,10 @@ if (!$use_ceve and !$opt_without_ceve) {
}
if ($use_ceve) {
+ if (system('command -v grep-dctrl >/dev/null 2>&1')) {
+ die "$progname: Fatal error. grep-dctrl is not available.\nPlease install the 'dctrl-tools' package.\n";
+ }
+
# set hostarch and buildarch if they have not been set yet
if (!$opt_hostarch) {
$opt_hostarch = `dpkg-architecture --query DEB_HOST_ARCH`;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list