[devscripts] 03/11: Replace use of Parse::DebControl with Dpkg::Control
James McCoy
jamessan at debian.org
Fri Mar 13 03:40:51 UTC 2015
This is an automated email from the git hooks/post-receive script.
jamessan pushed a commit to branch master
in repository devscripts.
commit 4c0d3ec6c5f95aa22b9cfe4f92831c3a7c324fb3
Author: James McCoy <jamessan at debian.org>
Date: Wed Mar 11 22:12:00 2015 -0400
Replace use of Parse::DebControl with Dpkg::Control
Parse::DebControl doesn't handle some valid debian/control files
(#780138) and is an unnecessary dependency since Dpkg::Control is
already being used.
Signed-off-by: James McCoy <jamessan at debian.org>
---
README | 5 ++--
debian/changelog | 2 ++
debian/control | 7 ++---
scripts/debchange.pl | 68 +++++++++++++------------------------------
scripts/who-permits-upload.pl | 15 +++++-----
5 files changed, 34 insertions(+), 63 deletions(-)
diff --git a/README b/README
index 85e19c8..e024fa8 100644
--- a/README
+++ b/README
@@ -66,7 +66,7 @@ And now, in mostly alphabetical order, the scripts:
- debchange (abbreviation dch): Modifies debian/changelog and manages version
numbers for you. It will either increment the version number or add a
entry for the current version, depending upon the options given to it.
- [libdistro-info-perl, libparse-debcontrol-perl, libsoap-lite-perl]
+ [libdistro-info-perl, libsoap-lite-perl]
- debcheckout: checkout the development repository of a Debian package
@@ -248,8 +248,7 @@ And now, in mostly alphabetical order, the scripts:
- whodepends: check which maintainers' packages depend on a package
- who-permits-upload: Retrieve information about Debian Maintainer access
- control lists [gnupg, libencode-locale-perl, libparse-debcontrol-perl,
- libwww-perl, debian-keyring]
+ control lists [gnupg, libencode-locale-perl, libwww-perl, debian-keyring]
- who-uploads: determine the most recent uploaders of a package to the Debian
archive [gnupg, debian-keyring, debian-maintainers, wget]
diff --git a/debian/changelog b/debian/changelog
index 567811d..8bd08e3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -32,6 +32,8 @@ devscripts (2.15.1+exp1) UNRELEASED; urgency=medium
code. This is an alternative way to cancel a command, rather than saving
an empty message. (Closes: #778648)
* who-permits-upload: Update URL to use https.
+ * Replace use of Parse::DebControl with Dpkg::Control to work around
+ #780138 and remove a dependency.
[ Johannes Schauer ]
* chdist: Also set Apt::Architectures to prevent foreign architectures from
diff --git a/debian/control b/debian/control
index f3c8de4..b940892 100644
--- a/debian/control
+++ b/debian/control
@@ -13,7 +13,6 @@ Build-Depends: debhelper (>= 9),
file,
libdistro-info-perl,
libfile-desktopentry-perl,
- libparse-debcontrol-perl,
libtimedate-perl,
liburi-perl,
libwww-perl,
@@ -52,7 +51,6 @@ Recommends: at,
libdistro-info-perl,
libencode-locale-perl,
libjson-perl,
- libparse-debcontrol-perl,
liburi-perl,
libwww-perl,
lintian,
@@ -121,7 +119,7 @@ Description: scripts to make the life of a Debian Package maintainer easier
- dd-list: given a list of packages, pretty-print it ordered by maintainer
- debc: display the contents of just-built .debs
- debchange/dch: automagically add entries to debian/changelog files
- [libdistro-info-perl, libparse-debcontrol-perl, libsoap-lite-perl]
+ [libdistro-info-perl, libsoap-lite-perl]
- debcheckout: checkout the development repository of a Debian package
- debclean: clean a Debian source tree [fakeroot]
- debcommit: commit changes to cvs, darcs, svn, svk, tla, bzr, git, or hg,
@@ -207,8 +205,7 @@ Description: scripts to make the life of a Debian Package maintainer easier
- wnpp-check: check whether there is an open request for packaging or
intention to package bug for a package [wget | curl]
- who-permits-upload: Retrieve information about Debian Maintainer access
- control lists [gnupg, libencode-locale-perl, libparse-debcontrol-perl,
- libwww-perl, debian-keyring]
+ control lists [gnupg, libencode-locale-perl, libwww-perl, debian-keyring]
- wrap-and-sort: wrap long lines and sort items in packaging files
[python3-debian]
.
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index 00346e3..7e695ba 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -41,6 +41,7 @@ use File::Basename;
use Cwd;
use Dpkg::Vendor qw(get_current_vendor);
use Dpkg::Changelog::Parse;
+use Dpkg::Control;
BEGIN { push @INC, '/usr/share/devscripts'; }
use Devscripts::Compression;
use Devscripts::Debbugs;
@@ -60,25 +61,6 @@ my $CHGLINE; # used by the format O section at the end
my $compression_re = compression_get_file_extension_regex();
-my $lpdc_broken;
-
-sub have_lpdc {
- return ($lpdc_broken ? 0 : 1) if defined $lpdc_broken;
- eval {
- require Parse::DebControl;
- };
-
- if ($@) {
- if ($@ =~ m%^Can\'t locate Parse/DebControl%) {
- $lpdc_broken="the libparse-debcontrol-perl package is not installed";
- } else {
- $lpdc_broken="couldn't load Parse::DebControl: $@";
- }
- }
- else { $lpdc_broken=''; }
- return $lpdc_broken ? 0 : 1;
-}
-
my $debian_distro_info;
sub get_debian_distro_info {
return $debian_distro_info if defined $debian_distro_info;
@@ -814,18 +796,14 @@ if (! $opt_m and ! $opt_M) {
if ($opt_M) {
if (-f 'debian/control') {
- if (have_lpdc()) {
- my $parser = Parse::DebControl->new;
- my $deb822 = $parser->parse_file('debian/control', {stripComments => 'true'});
- my $maintainer = decode_utf8($deb822->[0]->{'Maintainer'});
- if ($maintainer =~ /^(.*)\s+<(.*)>$/) {
- $MAINTAINER = $1;
- $EMAIL = $2;
- } else {
- fatal "$progname: invalid debian/control Maintainer field value\n";
- }
+ my $parser = Dpkg::Control->new(type => CTRL_INFO_SRC);
+ $parser->load('debian/control');
+ my $maintainer = decode_utf8($parser->{Maintainer});
+ if ($maintainer =~ /^(.*)\s+<(.*)>$/) {
+ $MAINTAINER = $1;
+ $EMAIL = $2;
} else {
- fatal "$progname: unable to get maintainer from debian/control: $lpdc_broken\n";
+ fatal "$progname: invalid debian/control Maintainer field value\n";
}
} else {
fatal "Missing file debian/control";
@@ -844,23 +822,19 @@ if ($opt_auto_nmu eq 'yes' and ! $opt_v and ! $opt_l and ! $opt_s and
$changelog->{Distribution} eq 'UNRELEASED' and ! $opt_i_passed)) {
if (-f 'debian/control') {
- if (have_lpdc()) {
- my $parser = new Parse::DebControl;
- my $deb822 = $parser->parse_file('debian/control', {stripComments => 'true'});
- my $uploader = decode_utf8($deb822->[0]->{'Uploaders'}) || '';
- my $maintainer = decode_utf8($deb822->[0]->{'Maintainer'});
- my @uploaders = split(/,\s*/, $uploader);
-
- my $packager = "$MAINTAINER <$EMAIL>";
-
- if ($maintainer !~ m/<packages\@qa\.debian\.org>/ and
- ! grep { $_ eq $packager } ($maintainer, @uploaders) and
- $packager ne $changelog->{Maintainer} and ! $opt_team) {
- $opt_n=1;
- $opt_a=0;
- }
- } else {
- warn "$progname: skipping automatic NMU detection: $lpdc_broken\n";
+ my $parser = Dpkg::Control->new(type => CTRL_INFO_SRC);
+ $parser->load('debian/control');
+ my $uploader = decode_utf8($parser->{Uploaders}) || '';
+ my $maintainer = decode_utf8($parser->{Maintainer});
+ my @uploaders = split(/,\s*/, $uploader);
+
+ my $packager = "$MAINTAINER <$EMAIL>";
+
+ if ($maintainer !~ m/<packages\@qa\.debian\.org>/ and
+ ! grep { $_ eq $packager } ($maintainer, @uploaders) and
+ $packager ne $changelog->{Maintainer} and ! $opt_team) {
+ $opt_n=1;
+ $opt_a=0;
}
} else {
fatal "Missing file debian/control";
diff --git a/scripts/who-permits-upload.pl b/scripts/who-permits-upload.pl
index 006aa5f..7b9ab54 100755
--- a/scripts/who-permits-upload.pl
+++ b/scripts/who-permits-upload.pl
@@ -19,7 +19,7 @@
use strict;
-use Parse::DebControl;
+use Dpkg::Control;
use LWP::UserAgent;
use Encode::Locale;
use Encode;
@@ -276,22 +276,21 @@ sub lookup_fingerprint
sub parse_data
{
my $raw_data = shift;
- my $parser = new Parse::DebControl;
- my $parsed_dm_data = $parser->parse_mem($raw_data, { discardCase=>1 });
+ my $parser = Dpkg::Control->new(type => CTRL_UNKNOWN, allow_duplicate => 1);
+ open(my $fh, '+<:utf8', \$raw_data) || leave('unable to read dm data: '.$!);
my @dm_data = ();
- foreach my $stanza (@{$parsed_dm_data})
+ while ($parser->parse($fh))
{
- foreach my $package (split(/,/, $stanza->{'allow'}))
+ foreach my $package (split(/,/, $parser->{Allow}))
{
if ($package =~ m/([a-z0-9\+\-\.]+)\s+\((\w+)\)/s)
{
- my @package_row = ($1, $stanza->{'fingerprint'}, $stanza->{'uid'}, $2, SPONSOR_FINGERPRINT);
+ my @package_row = ($1, $parser->{Fingerprint}, $parser->{Uid}, $2, SPONSOR_FINGERPRINT);
push(@dm_data, \@package_row);
}
}
}
- undef($parsed_dm_data);
return @dm_data;
}
@@ -329,7 +328,7 @@ $http->env_proxy;
my $response = $http->get($DM_URL);
if ($response->is_success)
{
- @DM_DATA = parse_data($response->decoded_content);
+ @DM_DATA = parse_data($response->content);
}
else
{
--
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