From 0e894ddaa68792246bd03a5dcf3f2e56fd2aeb74 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 27 Oct 2017 22:06:58 +0200 Subject: Dpkg::Vendor::Debian: Use proper use_feature key We need to access the features within the feature area hash now. Missed in a previous refactoring. Fixes: commit 2125e8dd7388e2adb9b6c837f4832fe8f0f63b25 Reported-by: Mattia Rizzolo (on IRC) Closes: #881051 --- scripts/Dpkg/Vendor/Debian.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index e0fd01113..980597b5c 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -204,7 +204,7 @@ sub _add_build_flags { # so that we do not need to worry about escaping the characters # on output. if ($build_path =~ m/[^-+:.0-9a-zA-Z~\/_]/) { - $use_feature{fixdebugpath} = 0; + $use_feature{reproducible}{fixdebugpath} = 0; } } -- cgit v1.2.3 From fe186374cd2a287723fe227fe37ea4a5373822c0 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Mon, 4 Dec 2017 15:12:50 +0800 Subject: Dpkg::Changelog: Print versions for incorrect changelog range warnings Within scripts operating on lots of different package changelogs, this can help track down where these warnings come from. Signed-off-by: Guillem Jover --- debian/changelog | 2 ++ scripts/Dpkg/Changelog.pm | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index cc537f866..8ed5546f1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::Vendor::Debian: Use proper %use_feature key. This was causing perl errors on paths not accapted for fixdebugpath. Reported by Mattia Rizzolo , on IRC. Closes: #881051 + - Dpkg::Changelog: Print versions for incorrect changelog range warnings. + Thanks to Paul Wise . * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index db8e3eb09..35e48ef02 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -254,7 +254,7 @@ sub __sanity_check_range { push @versions, $version->as_string(); } if ((defined($r->{since}) and not exists $versions{$r->{since}})) { - warning(g_("'%s' option specifies non-existing version"), 'since'); + warning(g_("'%s' option specifies non-existing version '%s'"), 'since', $r->{since}); warning(g_('use newest entry that is earlier than the one specified')); foreach my $v (@versions) { if (version_compare_relation($v, REL_LT, $r->{since})) { @@ -270,7 +270,7 @@ sub __sanity_check_range { } } if ((defined($r->{from}) and not exists $versions{$r->{from}})) { - warning(g_("'%s' option specifies non-existing version"), 'from'); + warning(g_("'%s' option specifies non-existing version '%s'"), 'from', $r->{from}); warning(g_('use oldest entry that is later than the one specified')); my $oldest; foreach my $v (@versions) { @@ -281,12 +281,12 @@ sub __sanity_check_range { if (defined($oldest)) { $r->{from} = $oldest; } else { - warning(g_("no such entry found, ignoring '%s' parameter"), 'from'); + warning(g_("no such entry found, ignoring '%s' parameter '%s'"), 'from', $r->{from}); delete $r->{from}; # No version was oldest } } if (defined($r->{until}) and not exists $versions{$r->{until}}) { - warning(g_("'%s' option specifies non-existing version"), 'until'); + warning(g_("'%s' option specifies non-existing version '%s'"), 'until', $r->{until}); warning(g_('use oldest entry that is later than the one specified')); my $oldest; foreach my $v (@versions) { @@ -297,12 +297,12 @@ sub __sanity_check_range { if (defined($oldest)) { $r->{until} = $oldest; } else { - warning(g_("no such entry found, ignoring '%s' parameter"), 'until'); + warning(g_("no such entry found, ignoring '%s' parameter '%s'"), 'until', $r->{until}); delete $r->{until}; # No version was oldest } } if (defined($r->{to}) and not exists $versions{$r->{to}}) { - warning(g_("'%s' option specifies non-existing version"), 'to'); + warning(g_("'%s' option specifies non-existing version '%s'"), 'to', $r->{to}); warning(g_('use newest entry that is earlier than the one specified')); foreach my $v (@versions) { if (version_compare_relation($v, REL_LT, $r->{to})) { @@ -312,17 +312,17 @@ sub __sanity_check_range { } if (not exists $versions{$r->{to}}) { # No version was earlier - warning(g_("no such entry found, ignoring '%s' parameter"), 'to'); + warning(g_("no such entry found, ignoring '%s' parameter '%s'"), 'to', $r->{to}); delete $r->{to}; } } if (defined($r->{since}) and $data->[0]->get_version() eq $r->{since}) { - warning(g_("'since' option specifies most recent version, ignoring")); + warning(g_("'since' option specifies most recent version '%s', ignoring"), $r->{since}); delete $r->{since}; } if (defined($r->{until}) and $data->[-1]->get_version() eq $r->{until}) { - warning(g_("'until' option specifies oldest version, ignoring")); + warning(g_("'until' option specifies oldest version '%s', ignoring"), $r->{until}); delete $r->{until}; } ## use critic -- cgit v1.2.3 From b29058ea75ce28f95b373b0c36deffd4b57d466b Mon Sep 17 00:00:00 2001 From: Dmitry Shachnev Date: Sun, 3 Dec 2017 03:37:23 +0100 Subject: Dpkg::Shlibs::SymbolFile: Check that $state->{seen} exists instead of $state being defined Fixes: commit 0d2b3cee25b74dd3fd9ddc3a469b8b144368c963 Closes: #880166 Signed-off-by: Guillem Jover --- debian/changelog | 3 +++ scripts/Dpkg/Shlibs/SymbolFile.pm | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 813b17053..820135a0f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,9 @@ dpkg (1.19.1) UNRELEASED; urgency=medium Reported by Mattia Rizzolo , on IRC. Closes: #881051 - Dpkg::Changelog: Print versions for incorrect changelog range warnings. Thanks to Paul Wise . + - Check that $state->{seen} exists instead of $state being just defined. + Fixes regression in dpkg-gensymbols symbols output. + Thanks to Dmitry Shachnev . Closes: #880166 * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm index d03ce2598..b36d542ce 100644 --- a/scripts/Dpkg/Shlibs/SymbolFile.pm +++ b/scripts/Dpkg/Shlibs/SymbolFile.pm @@ -204,7 +204,7 @@ sub parse { my ($self, $fh, $file, %opts) = @_; my $state = $opts{state} //= {}; - if (defined $state) { + if (exists $state->{seen}) { return if exists $state->{seen}{$file}; # Avoid include loops } else { $self->{file} = $file; -- cgit v1.2.3 From 2f5816d8be40b449d2473b22f9e0c33b32f3bd78 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 10 Dec 2017 12:07:42 +0100 Subject: scripts: Reject negated values in Architecture field Add new positive options argument to arch validators, as the Architecture field should not accept negated architectures. We preserve the current functions default behavior and add a new option to control whether to reject negated architectures. Fixes: commit d355b340f3a6cde7fc1cb5649d82fbebd3b97ea1 Stable-Candidate: 1.18.x --- debian/changelog | 3 +++ scripts/Dpkg/Arch.pm | 28 ++++++++++++++++++++++------ scripts/dpkg-genchanges.pl | 4 ++-- scripts/dpkg-gencontrol.pl | 2 +- scripts/t/Dpkg_Arch.t | 9 ++++++++- 5 files changed, 36 insertions(+), 10 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 9b6533fc9..2d4f616f2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium Reported by Jakub Wilk . * Add new AS, STRIP, OBJCOPY, OBJDUMP, NM, AR and RANLIB buildtools variables to buildtools.mk. Prompted by Helmut Grohne . + * Restore rejecting negated architectures in Architecture field in + dpkg-gencontrol and dpkg-genchanges. Regression introduced in dpkg 1.18.5. * Perl modules: - Check that $tarname is defined before use in Dpkg::Source::Package::V1. Thanks to Christoph Biedl . @@ -30,6 +32,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Check that $state->{seen} exists instead of $state being just defined. Fixes regression in dpkg-gensymbols symbols output. Thanks to Dmitry Shachnev . Closes: #880166 + - Add new positive options argument to arch validators in Dpkg::Arch. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm index c3e891526..14709d6cc 100644 --- a/scripts/Dpkg/Arch.pm +++ b/scripts/Dpkg/Arch.pm @@ -36,7 +36,7 @@ use strict; use warnings; use feature qw(state); -our $VERSION = '1.02'; +our $VERSION = '1.03'; our @EXPORT_OK = qw( get_raw_build_arch get_raw_host_arch @@ -599,17 +599,25 @@ sub debarch_is_wildcard($) return 0; } -=item $bool = debarch_is_illegal($arch) +=item $bool = debarch_is_illegal($arch, %options) Validate an architecture name. +If the "positive" option is set to a true value, only positive architectures +will be accepted, otherwise negated architectures are allowed. + =cut sub debarch_is_illegal { - my ($arch) = @_; + my ($arch, %opts) = @_; + my $arch_re = qr/[a-zA-Z0-9][a-zA-Z0-9-]*/; - return $arch !~ m/^!?[a-zA-Z0-9][a-zA-Z0-9-]*$/; + if ($opts{positive}) { + return $arch !~ m/^$arch_re$/; + } else { + return $arch !~ m/^!?$arch_re$/; + } } =item $bool = debarch_is_concerned($arch, @arches) @@ -651,15 +659,18 @@ sub debarch_is_concerned Parse an architecture list. +If the "positive" option is set to a true value, only positive architectures +will be accepted, otherwise negated architectures are allowed. + =cut sub debarch_list_parse { - my $arch_list = shift; + my ($arch_list, %opts) = @_; my @arch_list = split ' ', $arch_list; foreach my $arch (@arch_list) { - if (debarch_is_illegal($arch)) { + if (debarch_is_illegal($arch, %opts)) { error(g_("'%s' is not a legal architecture in list '%s'"), $arch, $arch_list); } @@ -676,6 +687,11 @@ __END__ =head1 CHANGES +=head2 Version 1.03 (dpkg 1.19.1) + +New argument: Accept a "positive" option in debarch_is_illegal() and +debarch_list_parse(). + =head2 Version 1.02 (dpkg 1.18.19) New import tags: ":all", ":getters", ":parsers", ":mappers", ":operators". diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 84bdc4ba6..4f4b33608 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -369,7 +369,7 @@ foreach my $pkg ($control->get_packages()) { # No files for this package... warn if it's unexpected if (((build_has_any(BUILD_ARCH_INDEP) and debarch_eq('all', $a)) or (build_has_any(BUILD_ARCH_DEP) and - (any { debarch_is($host_arch, $_) } debarch_list_parse($a)))) and + (any { debarch_is($host_arch, $_) } debarch_list_parse($a, positive => 1)))) and (@restrictions == 0 or evaluate_restriction_formula(\@restrictions, \@profiles))) { @@ -388,7 +388,7 @@ foreach my $pkg ($control->get_packages()) { $f2pricf{$_} = $v foreach (@f); } elsif (m/^Architecture$/) { if (build_has_any(BUILD_ARCH_DEP) and - (any { debarch_is($host_arch, $_) } debarch_list_parse($v))) { + (any { debarch_is($host_arch, $_) } debarch_list_parse($v, positive => 1))) { $v = $host_arch; } elsif (!debarch_eq('all', $v)) { $v = ''; diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 2e656a246..1c92e66dd 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -217,7 +217,7 @@ foreach (keys %{$pkg}) { if (debarch_eq('all', $v)) { $fields->{$_} = $v; } else { - my @archlist = debarch_list_parse($v); + my @archlist = debarch_list_parse($v, positive => 1); if (none { debarch_is($host_arch, $_) } @archlist) { error(g_("current host architecture '%s' does not " . diff --git a/scripts/t/Dpkg_Arch.t b/scripts/t/Dpkg_Arch.t index 525817085..0ef9d1899 100644 --- a/scripts/t/Dpkg_Arch.t +++ b/scripts/t/Dpkg_Arch.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 16367; +use Test::More tests => 16369; use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch debarch_eq debarch_is debarch_is_wildcard @@ -148,9 +148,16 @@ my @arch_ref; @arch_new = debarch_list_parse('amd64 !arm64 linux-i386 !kfreebsd-any'); is_deeply(\@arch_new, \@arch_ref, 'parse valid arch list'); +@arch_ref = qw(amd64 arm64 linux-i386 kfreebsd-any); +@arch_new = debarch_list_parse('amd64 arm64 linux-i386 kfreebsd-any', positive => 1); +is_deeply(\@arch_new, \@arch_ref, 'parse valid positive arch list'); + eval { @arch_new = debarch_list_parse('!amd64!arm64') }; ok($@, 'parse concatenated arches failed'); +eval { @arch_new = debarch_list_parse('amd64 !arm64 !mips', positive => 1) }; +ok($@, 'parse disallowed negated arches failed'); + is(debarch_to_abiattrs(undef), undef, 'undef ABI attrs'); is_deeply([ debarch_to_abiattrs('amd64') ], [ qw(64 little) ], 'amd64 ABI attrs'); -- cgit v1.2.3 From 81591e0f2590052ff221964c8c554bbbd39763b5 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 13 Jan 2018 02:34:46 +0100 Subject: Dpkg::Vendor::Debian: Mark hurd-i386 as having built-in PIE support Requested-by: Samuel Thibault --- debian/changelog | 2 ++ scripts/Dpkg/Vendor/Debian.pm | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 74bab5d95..f83b8b6ce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium Fixes regression in dpkg-gensymbols symbols output. Thanks to Dmitry Shachnev . Closes: #880166 - Add new positive options argument to arch validators in Dpkg::Arch. + - Mark hurd-i386 as having gcc builtin PIE in Dpkg::Vendor::Debian. + Requested by Samuel Thibault . * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 980597b5c..08ed8250d 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -267,7 +267,7 @@ sub _add_build_flags { # Mask builtin features that are not enabled by default in the compiler. my %builtin_pie_arch = map { $_ => 1 } qw( - amd64 arm64 armel armhf i386 kfreebsd-amd64 kfreebsd-i386 + amd64 arm64 armel armhf hurd-i386 i386 kfreebsd-amd64 kfreebsd-i386 mips mipsel mips64el powerpc ppc64 ppc64el s390x sparc sparc64 ); if (not exists $builtin_pie_arch{$arch}) { -- cgit v1.2.3 From dde2a51557ccde71a536d5e4a9af236bcb45be9c Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 3 Feb 2018 03:24:00 +0100 Subject: Dpkg::Source::Package::V2: Print one building line per existing tarball Lumping all found tarballs into a single line makes the output more confusing. --- debian/changelog | 1 + scripts/Dpkg/Source/Package/V2.pm | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 659c055a7..252efd994 100644 --- a/debian/changelog +++ b/debian/changelog @@ -51,6 +51,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Add new positive options argument to arch validators in Dpkg::Arch. - Mark hurd-i386 as having gcc builtin PIE in Dpkg::Vendor::Debian. Requested by Samuel Thibault . + - Dpkg::Source::Package::V2: Print one building line per existing tarball. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index 818e32ddc..5fdd24957 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -428,8 +428,10 @@ sub _generate_patch { $self->_upstream_tarball_template()) unless $tarfile; if ($opts{usage} eq 'build') { - info(g_('building %s using existing %s'), - $self->{fields}{'Source'}, "@origtarballs"); + foreach my $origtarfile (@origtarballs) { + info(g_('building %s using existing %s'), + $self->{fields}{'Source'}, $origtarfile); + } } # Unpack a second copy for comparison -- cgit v1.2.3 From e226e6cf5507eebd4888d3d11e1b65752af6752f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 3 Feb 2018 03:24:00 +0100 Subject: Dpkg::Source::Package: Print building lines for upstream tarball signatures When we are picking up upstream tarball signatures, we should also print them as being used to create the source package. Closes: #888787 --- debian/changelog | 2 ++ scripts/Dpkg/Source/Package/V1.pm | 5 ++++- scripts/Dpkg/Source/Package/V2.pm | 18 ++++++++++++------ 3 files changed, 18 insertions(+), 7 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 252efd994..541b0c206 100644 --- a/debian/changelog +++ b/debian/changelog @@ -52,6 +52,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Mark hurd-i386 as having gcc builtin PIE in Dpkg::Vendor::Debian. Requested by Samuel Thibault . - Dpkg::Source::Package::V2: Print one building line per existing tarball. + - Dpkg::Source::Package: Print building lines for upstream tarball + signatures. Closes: #888787 * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Source/Package/V1.pm b/scripts/Dpkg/Source/Package/V1.pm index 001d9ecd3..38c2498f4 100644 --- a/scripts/Dpkg/Source/Package/V1.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -413,7 +413,10 @@ sub do_build { if ($tarname and -e "$tarname.sig" and not -e "$tarname.asc") { openpgp_sig_to_asc("$tarname.sig", "$tarname.asc"); } - $self->add_file($tarsign) if $tarsign and -e $tarsign; + if ($tarsign and -e $tarsign) { + info(g_('building %s using existing %s'), $sourcepackage, $tarsign); + $self->add_file($tarsign); + } if ($sourcestyle =~ m/[kpKP]/) { if (stat($origdir)) { diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index 5fdd24957..13e5d7456 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -399,7 +399,7 @@ sub _generate_patch { # Identify original tarballs my ($tarfile, %addonfile); my $comp_ext_regex = compression_get_file_extension_regex(); - my @origtarballs; + my @origtarfiles; foreach my $file (sort $self->find_original_tarballs()) { if ($file =~ /\.orig\.tar\.$comp_ext_regex$/) { if (defined($tarfile)) { @@ -407,20 +407,26 @@ sub _generate_patch { 'one is allowed'), $tarfile, $file); } $tarfile = $file; - push @origtarballs, $file; + push @origtarfiles, $file; $self->add_file($file); if (-e "$file.sig" and not -e "$file.asc") { openpgp_sig_to_asc("$file.sig", "$file.asc"); } - $self->add_file("$file.asc") if -e "$file.asc"; + if (-e "$file.asc") { + push @origtarfiles, "$file.asc"; + $self->add_file("$file.asc") + } } elsif ($file =~ /\.orig-([[:alnum:]-]+)\.tar\.$comp_ext_regex$/) { $addonfile{$1} = $file; - push @origtarballs, $file; + push @origtarfiles, $file; $self->add_file($file); if (-e "$file.sig" and not -e "$file.asc") { openpgp_sig_to_asc("$file.sig", "$file.asc"); } - $self->add_file("$file.asc") if -e "$file.asc"; + if (-e "$file.asc") { + push @origtarfiles, "$file.asc"; + $self->add_file("$file.asc"); + } } } @@ -428,7 +434,7 @@ sub _generate_patch { $self->_upstream_tarball_template()) unless $tarfile; if ($opts{usage} eq 'build') { - foreach my $origtarfile (@origtarballs) { + foreach my $origtarfile (@origtarfiles) { info(g_('building %s using existing %s'), $self->{fields}{'Source'}, $origtarfile); } -- cgit v1.2.3 From f7488217a506871f1aed58373220a76ea2e170ab Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 6 Feb 2017 03:17:32 +0100 Subject: Dpkg::Deps: Turn virtualpkg tracking from an arrayyref into a hashref This is more extensible and more clear. --- debian/changelog | 1 + scripts/Dpkg/Deps.pm | 19 ++++++++++++++----- scripts/dpkg-genbuildinfo.pl | 3 +-- 3 files changed, 16 insertions(+), 7 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 6fae00607..efd84ec45 100644 --- a/debian/changelog +++ b/debian/changelog @@ -59,6 +59,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::Source::Package::V2: Print one building line per existing tarball. - Dpkg::Source::Package: Print building lines for upstream tarball signatures. Closes: #888787 + - Dpkg::Deps: Turn virtualpkg tracking from an arrayyref into a hashref. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index 3560e1a72..df8d9f4ec 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -1423,9 +1423,15 @@ field (if present). sub add_provided_package { my ($self, $pkg, $rel, $ver, $by) = @_; + my $v = { + package => $pkg, + relation => $rel, + version => $ver, + provider => $by, + }; $self->{virtualpkg}{$pkg} //= []; - push @{$self->{virtualpkg}{$pkg}}, [ $by, $rel, $ver ]; + push @{$self->{virtualpkg}{$pkg}}, $v; } =item ($check, $param) = $facts->check_package($package) @@ -1453,7 +1459,10 @@ sub check_package { return (1, $self->{pkg}{$pkg}[0]{version}); } if (exists $self->{virtualpkg}{$pkg}) { - return (1, $self->{virtualpkg}{$pkg}); + my $arrayref = [ map { [ + $_->{provider}, $_->{relation}, $_->{version} + ] } @{$self->{virtualpkg}{$pkg}} ]; + return (1, $arrayref); } return (0, undef); } @@ -1510,11 +1519,11 @@ sub _evaluate_simple_dep { } } foreach my $virtpkg ($self->_find_virtual_packages($pkg)) { - next if defined $virtpkg->[1] and $virtpkg->[1] ne REL_EQ; + next if defined $virtpkg->{relation} and $virtpkg->{relation} ne REL_EQ; if (defined $dep->{relation}) { - next if not defined $virtpkg->[2]; - return 1 if version_compare_relation($virtpkg->[2], + next if not defined $virtpkg->{version}; + return 1 if version_compare_relation($virtpkg->{version}, $dep->{relation}, $dep->{version}); } else { diff --git a/scripts/dpkg-genbuildinfo.pl b/scripts/dpkg-genbuildinfo.pl index 45c45089d..96b06093a 100755 --- a/scripts/dpkg-genbuildinfo.pl +++ b/scripts/dpkg-genbuildinfo.pl @@ -232,8 +232,7 @@ sub collect_installed_builddeps { # virtual package: we cannot know for sure which implementation # is the one that has been used, so let's add them all... foreach my $provided (@{$facts->{virtualpkg}->{$pkg_name}}) { - my ($provided_by, $provided_rel, $provided_ver) = @{$provided}; - push @unprocessed_pkgs, $provided_by; + push @unprocessed_pkgs, $provided->{provider}; } } # else: it is a package in an OR dependency that has been otherwise -- cgit v1.2.3 From 83272497c5be8c4e703ab179906cf904465fe775 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 6 Feb 2017 03:52:50 +0100 Subject: Dpkg::Deps: Accept $archqual for add_provided_package() method --- debian/changelog | 1 + scripts/Dpkg/Deps.pm | 14 ++++++++++---- scripts/dpkg-checkbuilddeps.pl | 2 +- scripts/dpkg-genbuildinfo.pl | 3 ++- scripts/dpkg-gencontrol.pl | 3 ++- 5 files changed, 16 insertions(+), 7 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index efd84ec45..a73e91077 100644 --- a/debian/changelog +++ b/debian/changelog @@ -60,6 +60,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::Source::Package: Print building lines for upstream tarball signatures. Closes: #888787 - Dpkg::Deps: Turn virtualpkg tracking from an arrayyref into a hashref. + - Dpkg::Deps: Accept $archqual for add_provided_package() method. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index df8d9f4ec..3612eb303 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -49,7 +49,7 @@ All the deps_* functions are exported by default. use strict; use warnings; -our $VERSION = '1.06'; +our $VERSION = '1.07'; our @EXPORT = qw( deps_concat deps_parse @@ -1413,18 +1413,20 @@ sub add_installed_package { push @{$self->{pkg}{$pkg}}, $p; } -=item $facts->add_provided_package($virtual, $relation, $version, $by) +=item $facts->add_provided_package($virtual, $relation, $version, $by, $archqual) Records that the "$by" package provides the $virtual package. $relation and $version correspond to the associated relation given in the Provides -field (if present). +field (if present). $archqual corresponds to the package arch qualifier +(if present). =cut sub add_provided_package { - my ($self, $pkg, $rel, $ver, $by) = @_; + my ($self, $pkg, $rel, $ver, $by, $archqual) = @_; my $v = { package => $pkg, + archqual => $archqual, relation => $rel, version => $ver, provider => $by, @@ -1536,6 +1538,10 @@ sub _evaluate_simple_dep { =head1 CHANGES +=head2 Version 1.07 (dpkg 1.19.1) + +New argument: Add $archqual to $dep->add_provided_package(). + =head2 Version 1.06 (dpkg 1.18.7; module version bumped on dpkg 1.18.24) New option: Add tests_dep option to Dpkg::Deps::deps_parse(). diff --git a/scripts/dpkg-checkbuilddeps.pl b/scripts/dpkg-checkbuilddeps.pl index 80b309f14..738afa042 100755 --- a/scripts/dpkg-checkbuilddeps.pl +++ b/scripts/dpkg-checkbuilddeps.pl @@ -173,7 +173,7 @@ sub parse_status { { $facts->add_provided_package($_->{package}, $_->{relation}, $_->{version}, - $package); + $package, $_->{archqual}); } } } diff --git a/scripts/dpkg-genbuildinfo.pl b/scripts/dpkg-genbuildinfo.pl index 96b06093a..c2916c2b2 100755 --- a/scripts/dpkg-genbuildinfo.pl +++ b/scripts/dpkg-genbuildinfo.pl @@ -115,7 +115,8 @@ sub parse_status { deps_iterate($provides, sub { my $dep = shift; $facts->add_provided_package($dep->{package}, $dep->{relation}, - $dep->{version}, $package); + $dep->{version}, $package, + $dep->{archqual}); }); } diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 1c92e66dd..517db351b 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -263,7 +263,8 @@ if (exists $pkg->{'Provides'}) { if ($subdep->isa('Dpkg::Deps::Simple')) { $facts->add_provided_package($subdep->{package}, $subdep->{relation}, $subdep->{version}, - $fields->{'Package'}); + $fields->{'Package'}, + $subdep->{archqual}); } } } -- cgit v1.2.3 From cba523f59c2d8f18d8b1e9940681579f871034ce Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 22 Mar 2018 03:59:28 +0100 Subject: Dpkg::Vendor::Debian: Split pie builtin arches one per line This makes changing them easier to see when diffing. --- scripts/Dpkg/Vendor/Debian.pm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 08ed8250d..d7af8e3b7 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -267,8 +267,23 @@ sub _add_build_flags { # Mask builtin features that are not enabled by default in the compiler. my %builtin_pie_arch = map { $_ => 1 } qw( - amd64 arm64 armel armhf hurd-i386 i386 kfreebsd-amd64 kfreebsd-i386 - mips mipsel mips64el powerpc ppc64 ppc64el s390x sparc sparc64 + amd64 + arm64 + armel + armhf + hurd-i386 + i386 + kfreebsd-amd64 + kfreebsd-i386 + mips + mipsel + mips64el + powerpc + ppc64 + ppc64el + s390x + sparc + sparc64 ); if (not exists $builtin_pie_arch{$arch}) { $builtin_feature{hardening}{pie} = 0; -- cgit v1.2.3 From 544dd8967940aeee11b47b53a8df6f88110a9a16 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 22 Mar 2018 04:00:07 +0100 Subject: Dpkg::Vendor::Debian: Mark riscv64 as having gcc built-in PIE support --- debian/changelog | 1 + scripts/Dpkg/Vendor/Debian.pm | 1 + 2 files changed, 2 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index a73e91077..ed4d8e796 100644 --- a/debian/changelog +++ b/debian/changelog @@ -61,6 +61,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium signatures. Closes: #888787 - Dpkg::Deps: Turn virtualpkg tracking from an arrayyref into a hashref. - Dpkg::Deps: Accept $archqual for add_provided_package() method. + - Dpkg::Vendor::Debian: Mark riscv64 as having gcc builtin PIE. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index d7af8e3b7..814948e83 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -281,6 +281,7 @@ sub _add_build_flags { powerpc ppc64 ppc64el + riscv64 s390x sparc sparc64 -- cgit v1.2.3 From 94728ead2cc22af5043b16483aab1e4f5a50223c Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 29 Apr 2018 01:26:10 +0200 Subject: Revert "Dpkg::Deps: Accept $archqual for add_provided_package() method" This reverts commit 83272497c5be8c4e703ab179906cf904465fe775. This commit introduced a regression in the author test suite. And there's a patch by Johannes 'josch' Schauer which should be fixing this and other problems. If this is needed after all, we will need to refactor the functions first to take a hash instead of a long list of arguments. --- debian/changelog | 1 - scripts/Dpkg/Deps.pm | 14 ++++---------- scripts/dpkg-checkbuilddeps.pl | 2 +- scripts/dpkg-genbuildinfo.pl | 3 +-- scripts/dpkg-gencontrol.pl | 3 +-- 5 files changed, 7 insertions(+), 16 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 3d59b4278..59d2cffd6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -74,7 +74,6 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::Source::Package: Print building lines for upstream tarball signatures. Closes: #888787 - Dpkg::Deps: Turn virtualpkg tracking from an arrayyref into a hashref. - - Dpkg::Deps: Accept $archqual for add_provided_package() method. - Dpkg::Vendor::Debian: Mark riscv64 as having gcc builtin PIE. * Documentation: - Update gettext minimal version in README. diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index 3612eb303..df8d9f4ec 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -49,7 +49,7 @@ All the deps_* functions are exported by default. use strict; use warnings; -our $VERSION = '1.07'; +our $VERSION = '1.06'; our @EXPORT = qw( deps_concat deps_parse @@ -1413,20 +1413,18 @@ sub add_installed_package { push @{$self->{pkg}{$pkg}}, $p; } -=item $facts->add_provided_package($virtual, $relation, $version, $by, $archqual) +=item $facts->add_provided_package($virtual, $relation, $version, $by) Records that the "$by" package provides the $virtual package. $relation and $version correspond to the associated relation given in the Provides -field (if present). $archqual corresponds to the package arch qualifier -(if present). +field (if present). =cut sub add_provided_package { - my ($self, $pkg, $rel, $ver, $by, $archqual) = @_; + my ($self, $pkg, $rel, $ver, $by) = @_; my $v = { package => $pkg, - archqual => $archqual, relation => $rel, version => $ver, provider => $by, @@ -1538,10 +1536,6 @@ sub _evaluate_simple_dep { =head1 CHANGES -=head2 Version 1.07 (dpkg 1.19.1) - -New argument: Add $archqual to $dep->add_provided_package(). - =head2 Version 1.06 (dpkg 1.18.7; module version bumped on dpkg 1.18.24) New option: Add tests_dep option to Dpkg::Deps::deps_parse(). diff --git a/scripts/dpkg-checkbuilddeps.pl b/scripts/dpkg-checkbuilddeps.pl index 738afa042..80b309f14 100755 --- a/scripts/dpkg-checkbuilddeps.pl +++ b/scripts/dpkg-checkbuilddeps.pl @@ -173,7 +173,7 @@ sub parse_status { { $facts->add_provided_package($_->{package}, $_->{relation}, $_->{version}, - $package, $_->{archqual}); + $package); } } } diff --git a/scripts/dpkg-genbuildinfo.pl b/scripts/dpkg-genbuildinfo.pl index c2916c2b2..96b06093a 100755 --- a/scripts/dpkg-genbuildinfo.pl +++ b/scripts/dpkg-genbuildinfo.pl @@ -115,8 +115,7 @@ sub parse_status { deps_iterate($provides, sub { my $dep = shift; $facts->add_provided_package($dep->{package}, $dep->{relation}, - $dep->{version}, $package, - $dep->{archqual}); + $dep->{version}, $package); }); } diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 517db351b..1c92e66dd 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -263,8 +263,7 @@ if (exists $pkg->{'Provides'}) { if ($subdep->isa('Dpkg::Deps::Simple')) { $facts->add_provided_package($subdep->{package}, $subdep->{relation}, $subdep->{version}, - $fields->{'Package'}, - $subdep->{archqual}); + $fields->{'Package'}); } } } -- cgit v1.2.3 From b9090a05af10b4f12adbc796fdc846c667ac7670 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 8 Apr 2018 22:34:35 +0200 Subject: Dpkg::Shlibs::Objdump: Remove duplicate assignment in reset() method --- scripts/Dpkg/Shlibs/Objdump.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index 91cc06488..2694f596f 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -268,7 +268,6 @@ sub reset { $self->{file} = ''; $self->{id} = ''; - $self->{SONAME} = ''; $self->{HASH} = ''; $self->{GNU_HASH} = ''; $self->{SONAME} = ''; -- cgit v1.2.3 From c972dfdcd85d92a39998b81a0fb23dc63935b137 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 8 Apr 2018 22:38:27 +0200 Subject: Dpkg::Shlibs::Objdump: Fix ELF program detection An ELF executable is defined by whether the object has the EXEC_P flag defined or an interpreter in the program header. The former applies to statically linked programs, the latter to dynamically linked programs and possibly some shared libraries that can be executed, such as the ones provided by glibc. This is now more relevant as PIE makes normal executables show up as shared objects, so they do not contain the EXEC_P flag, and were not being detected as executables. --- debian/changelog | 2 ++ scripts/Dpkg/Shlibs/Objdump.pm | 10 ++++++++-- scripts/t/Dpkg_Shlibs.t | 6 ++++-- 3 files changed, 14 insertions(+), 4 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 0d4410be9..5098e7f2d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -87,6 +87,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium signatures. Closes: #888787 - Dpkg::Deps: Turn virtualpkg tracking from an arrayyref into a hashref. - Dpkg::Vendor::Debian: Mark riscv64 as having gcc builtin PIE. + - Dpkg::Shlibs::Objdump: Fix ELF program detection, for PIE binaries and + executable libraries. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index 2694f596f..d0a7b56cb 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -270,6 +270,7 @@ sub reset { $self->{id} = ''; $self->{HASH} = ''; $self->{GNU_HASH} = ''; + $self->{INTERP} = 0; $self->{SONAME} = ''; $self->{NEEDED} = []; $self->{RPATH} = []; @@ -324,7 +325,7 @@ sub parse_objdump_output { $section = 'dyninfo'; next; } elsif (/^Program Header:/) { - $section = 'header'; + $section = 'program'; next; } elsif (/^Version definitions:/) { $section = 'verdef'; @@ -363,6 +364,10 @@ sub parse_objdump_output { $self->{RPATH} = [ split /:/, $rpath ]; } } + } elsif ($section eq 'program') { + if (/^\s*INTERP\s+/) { + $self->{INTERP} = 1; + } } elsif ($section eq 'none') { if (/^\s*.+:\s*file\s+format\s+(\S+)$/) { $self->{format} = $1; @@ -535,7 +540,8 @@ sub get_needed_libraries { sub is_executable { my $self = shift; - return exists $self->{flags}{EXEC_P} && $self->{flags}{EXEC_P}; + return (exists $self->{flags}{EXEC_P} && $self->{flags}{EXEC_P}) || + (exists $self->{INTERP} && $self->{INTERP}); } sub is_public_library { diff --git a/scripts/t/Dpkg_Shlibs.t b/scripts/t/Dpkg_Shlibs.t index 2310f4f1c..a271af587 100644 --- a/scripts/t/Dpkg_Shlibs.t +++ b/scripts/t/Dpkg_Shlibs.t @@ -21,7 +21,7 @@ use Test::Dpkg qw(:needs :paths); use Cwd; -plan tests => 148; +plan tests => 150; use Dpkg::Path qw(find_command); @@ -104,7 +104,7 @@ $obj->parse_objdump_output($objdump); close $objdump; ok($obj->is_public_library(), 'libc6 is a public library'); -ok(!$obj->is_executable(), 'libc6 is not an executable'); +ok($obj->is_executable(), 'libc6 is an executable'); is($obj->{SONAME}, 'libc.so.6', 'SONAME'); is($obj->{HASH}, '0x13d99c', 'HASH'); @@ -350,6 +350,8 @@ open $objdump, '<', "$datadir/objdump.glib-ia64" or die "$datadir/objdump.glib-ia64: $!"; $obj->parse_objdump_output($objdump); close $objdump; +ok($obj->is_public_library(), 'glib-ia64 is a public library'); +ok(!$obj->is_executable(), 'glib-ia64 is not an executable'); $sym = $obj->get_symbol('IA__g_free'); is_deeply( $sym, { name => 'IA__g_free', version => '', -- cgit v1.2.3 From 981a18c37036b68f368b0bfab71d2a984abba9e6 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 8 Apr 2018 22:43:09 +0200 Subject: Dpkg::Version: Fix bool overload behavior The current bool overload has broken semantics, because it considers the version "0" to be false. The bool overload used to have sane semantics (equivalent to is_valid()) before commit 5b9f353b2940de751df47036608afbe71992d622, but there it got changed to return the stringified version if it was valid, or undef otherwise, to fix a problem within dpkg-shlibdeps, instead of properly fixing the local-only problem in the tool. This makes the overload hard to use, and broke existing callers from external projects. We will emit a warning until dpkg 1.20.x to notify of the semantic change in case there is code relying on the broken semantics. For fixed code the warning can then be quiesced with: no warnings qw(Dpkg::Version::semantic_change::overload::bool); Closes: #895004 --- debian/changelog | 4 ++++ scripts/Dpkg/Version.pm | 20 +++++++++++++++++--- scripts/dpkg-shlibdeps.pl | 3 ++- scripts/t/Dpkg_Version.t | 17 ++++++++--------- t/pod-spell.t | 1 + 5 files changed, 32 insertions(+), 13 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 5098e7f2d..56b4c9e12 100644 --- a/debian/changelog +++ b/debian/changelog @@ -89,6 +89,10 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::Vendor::Debian: Mark riscv64 as having gcc builtin PIE. - Dpkg::Shlibs::Objdump: Fix ELF program detection, for PIE binaries and executable libraries. + - Dpkg::Version: Fix bool overload behavior back to be an is_valid() + alias. Emit a specific perl warning until 1.20.x so that users can check + whether the semantic change has any impact on the code, which can then + be quiesced. Closes: #895004 * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm index 477082b67..a06ba268d 100644 --- a/scripts/Dpkg/Version.pm +++ b/scripts/Dpkg/Version.pm @@ -20,6 +20,7 @@ package Dpkg::Version; use strict; use warnings; +use warnings::register qw(semantic_change::overload::bool); our $VERSION = '1.01'; our @EXPORT = qw( @@ -55,7 +56,12 @@ use overload '<=>' => \&_comparison, 'cmp' => \&_comparison, '""' => sub { return $_[0]->as_string(); }, - 'bool' => sub { return $_[0]->as_string() if $_[0]->is_valid(); }, + 'bool' => sub { + warnings::warnif('Dpkg::Version::semantic_change::overload::bool', + 'bool overload behavior has changed back to be ' . + 'an is_valid() alias'); + return $_[0]->is_valid(); + }, 'fallback' => 1; =encoding utf8 @@ -121,8 +127,16 @@ sub new { =item boolean evaluation When the Dpkg::Version object is used in a boolean evaluation (for example -in "if ($v)" or "$v || 'default'") it returns its string representation -if the version stored is valid ($v->is_valid()) and undef otherwise. +in "if ($v)" or "$v ? \"$v\" : 'default'") it returns true if the version +stored is valid ($v->is_valid()) and false otherwise. + +B: Between dpkg 1.15.7.2 and 1.19.1 this overload used to return +$v->as_string() if $v->is_valid(), a breaking change in behavior that caused +"0" versions to be evaluated as false. To catch any possibly intended code +that relied on those semantics, this overload will emit a warning with +category "Dpkg::Version::semantic_change::overload::bool" until dpkg 1.20.x. +Once fixed, or for already valid code the warning can be quiesced with +C. =item $v->is_valid() diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 323fba9e1..4b18545e9 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -546,7 +546,8 @@ foreach my $field (reverse @depfields) { map { # Translate dependency templates into real dependencies my $templ = $_; - if ($dependencies{$field}{$templ}) { + if ($dependencies{$field}{$templ}->is_valid() and + $dependencies{$field}{$templ}->as_string()) { $templ =~ s/#MINVER#/(>= $dependencies{$field}{$templ})/g; } else { $templ =~ s/#MINVER#//g; diff --git a/scripts/t/Dpkg_Version.t b/scripts/t/Dpkg_Version.t index 78db7aead..17e9b4b9e 100644 --- a/scripts/t/Dpkg_Version.t +++ b/scripts/t/Dpkg_Version.t @@ -20,6 +20,7 @@ use Test::More; use Dpkg::ErrorHandling; use Dpkg::IPC; +use Dpkg::Version; report_options(quiet_warnings => 1); @@ -30,7 +31,7 @@ my @ops = ('<', '<<', 'lt', '>=', 'ge', '>', '>>', 'gt'); -plan tests => scalar(@tests) * (3 * scalar(@ops) + 4) + 30; +plan tests => scalar(@tests) * (3 * scalar(@ops) + 4) + 27; sub dpkg_vercmp { my ($a, $cmp, $b) = @_; @@ -57,8 +58,6 @@ sub obj_vercmp { return $a gt $b if $cmp eq 'gt'; } -use_ok('Dpkg::Version'); - my $truth = { '-1' => { '<<' => 1, 'lt' => 1, @@ -83,6 +82,12 @@ my $truth = { }, }; +# XXX: Some of the tests check the bool overload, which currently emits +# the semantic_change warning. Disable it until we stop emitting the +# warning in dpkg 1.20.x. +## no critic (TestingAndDebugging::ProhibitNoWarnings) +no warnings(qw(Dpkg::Version::semantic_change::overload::bool)); + # Handling of empty/invalid versions my $empty = Dpkg::Version->new(''); ok($empty eq '', "Dpkg::Version->new('') eq ''"); @@ -128,12 +133,6 @@ ok(!$ver->is_native(), 'upstream version w/ revision is not native'); $ver = Dpkg::Version->new('1.0-1.0-1'); ok(!$ver->is_native(), 'upstream version w/ dash and revision is not native'); -# Other tests -$ver = Dpkg::Version->new('1.2.3-4'); -is($ver || 'default', '1.2.3-4', 'bool eval returns string representation'); -$ver = Dpkg::Version->new('0'); -is($ver || 'default', 'default', 'bool eval of version 0 is still false...'); - # Comparisons foreach my $case (@tests) { my ($a, $b, $res) = split ' ', $case; diff --git a/t/pod-spell.t b/t/pod-spell.t index 6d3f7ffc9..111d592ca 100644 --- a/t/pod-spell.t +++ b/t/pod-spell.t @@ -83,6 +83,7 @@ modelines multiarch nocheck qa +quiesced reportfile rfc822 sig -- cgit v1.2.3 From 43dc5fa95f5241ce790b727c405f96caaad12c19 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 5 May 2018 02:50:03 +0200 Subject: Dpkg::Changelog::Parse: Stop using tail(1) to read the end of the file Instead of relying on the tail command, simply read the end of the file ourselves, assuming a packed set of 80 character lines, reading 4096 bytes before the end, implies around 51 lines, which is close to the 40 lines currently used. This should be both faster and should improve portability, because even if we are using the POSIX -n option, some systems do not have a POSIX compliant tail(1) on the default path, such as Solaris. Analysis-by: James Clarke --- debian/changelog | 4 ++++ scripts/Dpkg/Changelog/Parse.pm | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 8eb639c44..36b5594d8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -99,6 +99,10 @@ dpkg (1.19.1) UNRELEASED; urgency=medium alias. Emit a specific perl warning until 1.20.x so that users can check whether the semantic change has any impact on the code, which can then be quiesced. Closes: #895004 + - Dpkg::Changelog::Parse: When detecting the changelog format, read the + last 4KiB of the file instead of using «tail -n40», which should be + both faster and more portable, as the default tail(1) is not POSIX + compliant on all systems (c.f. Solaris). * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm index e107dcf6d..28bb6892a 100644 --- a/scripts/Dpkg/Changelog/Parse.pm +++ b/scripts/Dpkg/Changelog/Parse.pm @@ -56,12 +56,16 @@ sub _changelog_detect_format { if ($file ne '-') { local $_; - open my $format_fh, '-|', 'tail', '-n', '40', $file - or syserr(g_('cannot create pipe for %s'), 'tail'); + open my $format_fh, '<', $file + or syserr(g_('cannot open file %s'), $file); + if (-s $format_fh > 4096) { + seek $format_fh, -4096, 2 + or syserr(g_('cannot seek into file %s'), $file); + } while (<$format_fh>) { $format = $1 if m/\schangelog-format:\s+([0-9a-z]+)\W/; } - close $format_fh or subprocerr(g_('tail of %s'), $file); + close $format_fh; } return $format; -- cgit v1.2.3 From 40eccd5c044c874cf7fa5f8dc8e2c75379395d8a Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 14 May 2018 23:26:07 +0200 Subject: scripts: Do not use stringy eval to define different sub implementations We can just assign an anonymous sub to the typeglob. --- debian/changelog | 3 +++ scripts/Dpkg/Gettext.pm | 58 +++++++++++++++++++---------------------- scripts/dpkg-mergechangelogs.pl | 10 +++---- 3 files changed, 34 insertions(+), 37 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 01585aef7..14a311e31 100644 --- a/debian/changelog +++ b/debian/changelog @@ -114,6 +114,9 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Document the Testsuite and Testsuite-Triggers fields in deb-src-control(5). Prompted by Mattia Rizzolo . - Update git URLs for move away from alioth.debian.org. + * Code internals: + - Do not use stringy eval to define different sub implementations, + just assign an anonymous sub to the typeglob. * Build system: - Set distribution tarball format to ustar, instead of default v7 format. - Mark PO4A and POD2MAN as precious variables. diff --git a/scripts/Dpkg/Gettext.pm b/scripts/Dpkg/Gettext.pm index 2e3e5042e..33ef1c48d 100644 --- a/scripts/Dpkg/Gettext.pm +++ b/scripts/Dpkg/Gettext.pm @@ -118,41 +118,37 @@ BEGIN { $use_gettext = not $@; } if (not $use_gettext) { - eval q{ - sub g_ { - return shift; - } - sub textdomain { - } - sub ngettext { - my ($msgid, $msgid_plural, $n) = @_; - if ($n == 1) { - return $msgid; - } else { - return $msgid_plural; - } - } - sub C_ { - my ($msgctxt, $msgid) = @_; + *g_ = sub { + return shift; + }; + *textdomain = sub { + }; + *ngettext = sub { + my ($msgid, $msgid_plural, $n) = @_; + if ($n == 1) { return $msgid; + } else { + return $msgid_plural; } - sub P_ { - return ngettext(@_); - } + }; + *C_ = sub { + my ($msgctxt, $msgid) = @_; + return $msgid; + }; + *P_ = sub { + return ngettext(@_); }; } else { - eval q{ - sub g_ { - return dgettext($DEFAULT_TEXT_DOMAIN, shift); - } - sub C_ { - my ($msgctxt, $msgid) = @_; - return dgettext($DEFAULT_TEXT_DOMAIN, - $msgctxt . GETTEXT_CONTEXT_GLUE . $msgid); - } - sub P_ { - return dngettext($DEFAULT_TEXT_DOMAIN, @_); - } + *g_ = sub { + return dgettext($DEFAULT_TEXT_DOMAIN, shift); + }; + *C_ = sub { + my ($msgctxt, $msgid) = @_; + return dgettext($DEFAULT_TEXT_DOMAIN, + $msgctxt . GETTEXT_CONTEXT_GLUE . $msgid); + }; + *P_ = sub { + return dngettext($DEFAULT_TEXT_DOMAIN, @_); }; } } diff --git a/scripts/dpkg-mergechangelogs.pl b/scripts/dpkg-mergechangelogs.pl index 7fd11fc96..20b33dc75 100755 --- a/scripts/dpkg-mergechangelogs.pl +++ b/scripts/dpkg-mergechangelogs.pl @@ -43,12 +43,10 @@ BEGIN { use Algorithm::Merge qw(merge); }; if ($@) { - eval q{ - sub merge { - my ($o, $a, $b) = @_; - return @$a if join("\n", @$a) eq join("\n", @$b); - return get_conflict_block($a, $b); - } + *merge = sub { + my ($o, $a, $b) = @_; + return @$a if join("\n", @$a) eq join("\n", @$b); + return get_conflict_block($a, $b); }; } } -- cgit v1.2.3 From ca394f0f03e9ab025a09e4c99ad4ccfc73550f46 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 23 Jul 2018 11:58:23 +0200 Subject: Dpkg::Build::Types: Fix set_build_type_from_options() description --- debian/changelog | 1 + scripts/Dpkg/Build/Types.pm | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index de40e2e23..700f69715 100644 --- a/debian/changelog +++ b/debian/changelog @@ -118,6 +118,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Document the Testsuite and Testsuite-Triggers fields in deb-src-control(5). Prompted by Mattia Rizzolo . - Update git URLs for move away from alioth.debian.org. + - Fix set_build_type_from_options() description in Dpkg::Build::Types. * Code internals: - Do not use stringy eval to define different sub implementations, just assign an anonymous sub to the typeglob. diff --git a/scripts/Dpkg/Build/Types.pm b/scripts/Dpkg/Build/Types.pm index 45a81d3ba..b6c2366f3 100644 --- a/scripts/Dpkg/Build/Types.pm +++ b/scripts/Dpkg/Build/Types.pm @@ -193,9 +193,10 @@ sub set_build_type $current_option = $build_option; } -=item set_build_type_from_options($build_type, $build_option, %opts) +=item set_build_type_from_options($build_types, $build_option, %opts) -Set the current build type from a list of build type components. +Set the current build type from a list of comma-separated build type +components. The function will check and abort on incompatible build type assignments, this behavior can be disabled by using the boolean option "nocheck". -- cgit v1.2.3 From 23322f43e80ce0c67a361b3b00c680e170fee58f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 23 Jul 2018 12:02:38 +0200 Subject: Dpkg::Build::Types: Add new set_build_type_from_targets() function --- debian/changelog | 1 + scripts/Dpkg/Build/Types.pm | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 700f69715..059de6ed5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -109,6 +109,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium last 4KiB of the file instead of using «tail -n40», which should be both faster and more portable, as the default tail(1) is not POSIX compliant on all systems (c.f. Solaris). + - Dpkg::Build::Types: Add new set_build_type_from_targets() function. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Build/Types.pm b/scripts/Dpkg/Build/Types.pm index b6c2366f3..9fd0344df 100644 --- a/scripts/Dpkg/Build/Types.pm +++ b/scripts/Dpkg/Build/Types.pm @@ -33,6 +33,7 @@ our @EXPORT = qw( build_is set_build_type set_build_type_from_options + set_build_type_from_targets get_build_options_from_type ); @@ -108,6 +109,15 @@ my %build_types = ( any => BUILD_ARCH_DEP, all => BUILD_ARCH_INDEP, ); +my %build_targets = ( + 'clean' => BUILD_SOURCE, + 'build' => BUILD_BINARY, + 'build-arch' => BUILD_ARCH_DEP, + 'build-indep' => BUILD_ARCH_INDEP, + 'binary' => BUILD_BINARY, + 'binary-arch' => BUILD_ARCH_DEP, + 'binary-indep' => BUILD_ARCH_INDEP, +); =back @@ -217,6 +227,28 @@ sub set_build_type_from_options set_build_type($build_type, $build_option, %opts); } +=item set_build_type_from_targets($build_targets, $build_option, %opts) + +Set the current build type from a list of comma-separated build target +components. + +The function will check and abort on incompatible build type assignments, +this behavior can be disabled by using the boolean option "nocheck". + +=cut + +sub set_build_type_from_targets +{ + my ($build_targets, $build_option, %opts) = @_; + + my $build_type = 0; + foreach my $target (split /,/, $build_targets) { + $build_type |= $build_targets{$target} // BUILD_BINARY; + } + + set_build_type($build_type, $build_option, %opts); +} + =item get_build_options_from_type() Get the current build type as a set of comma-separated string options. -- cgit v1.2.3 From 76daf7b7dd594d720f81fa32fbf3e19c1fb9e5ff Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 5 Jun 2018 05:25:58 +0200 Subject: Dpkg::Version: Bump VERSION and improve semantic change description Give context to the warning message, otherwise it's not clear what is going on. If the users to not conditionalize the warning usage they will get a perl warning about the unknown warning category itself, bump the module version to be able to discern this change, and update documentation to reflect this. --- scripts/Dpkg/Version.pm | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm index a06ba268d..2900e5790 100644 --- a/scripts/Dpkg/Version.pm +++ b/scripts/Dpkg/Version.pm @@ -22,7 +22,7 @@ use strict; use warnings; use warnings::register qw(semantic_change::overload::bool); -our $VERSION = '1.01'; +our $VERSION = '1.02'; our @EXPORT = qw( version_compare version_compare_relation @@ -58,8 +58,8 @@ use overload '""' => sub { return $_[0]->as_string(); }, 'bool' => sub { warnings::warnif('Dpkg::Version::semantic_change::overload::bool', - 'bool overload behavior has changed back to be ' . - 'an is_valid() alias'); + 'Dpkg::Version bool overload behavior has changed ' . + 'back to be an is_valid() alias'); return $_[0]->is_valid(); }, 'fallback' => 1; @@ -136,7 +136,11 @@ $v->as_string() if $v->is_valid(), a breaking change in behavior that caused that relied on those semantics, this overload will emit a warning with category "Dpkg::Version::semantic_change::overload::bool" until dpkg 1.20.x. Once fixed, or for already valid code the warning can be quiesced with -C. + + no if $Dpkg::Version::VERSION ge '1.02', + warnings => qw(Dpkg::Version::semantic_change::overload::bool); + +added after the C. =item $v->is_valid() @@ -469,6 +473,10 @@ sub version_check($) { =head1 CHANGES +=head2 Version 1.02 (dpkg 1.19.1) + +Semantic change: bool evaluation semantics restored to their original behavior. + =head2 Version 1.01 (dpkg 1.17.0) New argument: Accept an options argument in $v->as_string(). -- cgit v1.2.3 From 563fd74ef926b23207d58108071d91b7c8ba2507 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 14 Jun 2018 02:51:24 +0200 Subject: Dpkg::Shlibs::SymbolFile: Always assign proper Dpkg::Version to deprecated We should always assign a proper Dpkg::Version object to the deprecated variable. Otherwise it can get confused with the scalar value 0 used on boolean context to denote it is *not* deprecated, instead of it being a version number 0. --- debian/changelog | 4 ++++ scripts/Dpkg/Shlibs/SymbolFile.pm | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index a5920996b..ab1757193 100644 --- a/debian/changelog +++ b/debian/changelog @@ -118,6 +118,10 @@ dpkg (1.19.1) UNRELEASED; urgency=medium both faster and more portable, as the default tail(1) is not POSIX compliant on all systems (c.f. Solaris). - Dpkg::Build::Types: Add new set_build_type_from_targets() function. + - Dpkg::Shlibs::SymbolFile: Always assign a proper Dpkg::Version to the + deprecated variable, otherwise the scalar value 0 can get confused + on scalar context to denote it is *not* deprecated instead of being + version 0. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm index b36d542ce..1a165c9d0 100644 --- a/scripts/Dpkg/Shlibs/SymbolFile.pm +++ b/scripts/Dpkg/Shlibs/SymbolFile.pm @@ -224,7 +224,7 @@ sub parse { error(g_('symbol information must be preceded by a header (file %s, line %s)'), $file, $.); } # Symbol specification - my $deprecated = ($1) ? $1 : 0; + my $deprecated = ($1) ? Dpkg::Version->new($1) : 0; my $sym = _new_symbol($state->{base_symbol}, deprecated => $deprecated); if ($self->create_symbol($2, base => $sym)) { $self->add_symbol($sym, ${$state->{obj_ref}}); -- cgit v1.2.3 From 63e02e0aabe17cb87929037db3939b3e575e97f6 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 14 Jun 2018 02:53:23 +0200 Subject: Dpkg::Shlibs: Disable bool overload Dpkg::Version warnings The usage in this file is correct, but we are still doing boolean evaluation. --- debian/changelog | 1 + scripts/Dpkg/Shlibs/Symbol.pm | 4 ++++ scripts/Dpkg/Shlibs/SymbolFile.pm | 4 ++++ 3 files changed, 9 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index ab1757193..2bd44d571 100644 --- a/debian/changelog +++ b/debian/changelog @@ -122,6 +122,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium deprecated variable, otherwise the scalar value 0 can get confused on scalar context to denote it is *not* deprecated instead of being version 0. + - Dpkg::Shlibs: Disable bool overload Dpkg::Version warnings. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Shlibs/Symbol.pm b/scripts/Dpkg/Shlibs/Symbol.pm index 802681bf1..142992b89 100644 --- a/scripts/Dpkg/Shlibs/Symbol.pm +++ b/scripts/Dpkg/Shlibs/Symbol.pm @@ -33,6 +33,10 @@ use Dpkg::Shlibs::Cppfilt; # Supported alias types in the order of matching preference use constant ALIAS_TYPES => qw(c++ symver); +# Needed by the deprecated key, which is a correct use. +no if $Dpkg::Version::VERSION ge '1.02', + warnings => qw(Dpkg::Version::semantic_change::overload::bool); + sub new { my ($this, %args) = @_; my $class = ref($this) || $this; diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm index 1a165c9d0..4b1c7ef50 100644 --- a/scripts/Dpkg/Shlibs/SymbolFile.pm +++ b/scripts/Dpkg/Shlibs/SymbolFile.pm @@ -30,6 +30,10 @@ use Dpkg::Arch qw(get_host_arch); use parent qw(Dpkg::Interface::Storable); +# Needed by the deprecated key, which is a correct use. +no if $Dpkg::Version::VERSION ge '1.02', + warnings => qw(Dpkg::Version::semantic_change::overload::bool); + my %blacklist = ( __bss_end__ => 1, # arm __bss_end => 1, # arm -- cgit v1.2.3 From 2d02a12697808b01b360e7ceb52864c0873f7eac Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Jun 2018 18:33:15 +0200 Subject: Dpkg::Vendor::Debian: Inline _parse_feature_area() into _add_build_flags() This function was being called on each foreach iteration to parse the options within the DEB_BUILD_MAINT_OPTIONS and DEB_BUILD_OPTIONS environment variables, and needed to parse these at construction time every time. Inlining it should make it more performant and in addition reduce line count. --- debian/changelog | 2 ++ scripts/Dpkg/Vendor/Debian.pm | 20 +++++++------------- 2 files changed, 9 insertions(+), 13 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 2bd44d571..98146943d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -123,6 +123,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium on scalar context to denote it is *not* deprecated instead of being version 0. - Dpkg::Shlibs: Disable bool overload Dpkg::Version warnings. + - Dpkg::Vendor::Debian: Inline _parse_feature_area() into + _add_build_flags(), for a small speed up and line count reduction. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 814948e83..2e42a8b86 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -86,18 +86,6 @@ sub run_hook { } } -sub _parse_feature_area { - my ($self, $area, $use_feature) = @_; - - require Dpkg::BuildOptions; - - # Adjust features based on user or maintainer's desires. - my $opts = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_OPTIONS'); - $opts->parse_features($area, $use_feature); - $opts = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_MAINT_OPTIONS'); - $opts->parse_features($area, $use_feature); -} - sub _add_build_flags { my ($self, $flags) = @_; @@ -141,9 +129,15 @@ sub _add_build_flags { ## Setup + require Dpkg::BuildOptions; + # Adjust features based on user or maintainer's desires. + my $opts_build = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_OPTIONS'); + my $opts_maint = Dpkg::BuildOptions->new(envvar => 'DEB_BUILD_MAINT_OPTIONS'); + foreach my $area (sort keys %use_feature) { - $self->_parse_feature_area($area, $use_feature{$area}); + $opts_build->parse_features($area, $use_feature{$area}); + $opts_maint->parse_features($area, $use_feature{$area}); } require Dpkg::Arch; -- cgit v1.2.3 From d5374bc618310917557daa9c9ac2f4930515a0b2 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Jun 2018 18:33:15 +0200 Subject: Dpkg::BuildFlags: Move default flags setting into the Dpkg::Vendor modules This should really be a vendor specific default. It's also documented that way in the man page. --- debian/changelog | 2 ++ scripts/Dpkg/BuildFlags.pm | 18 +++++++----------- scripts/Dpkg/Vendor/Debian.pm | 18 +++++++++++++++++- 3 files changed, 26 insertions(+), 12 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 98146943d..1a1dbe0c8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -125,6 +125,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::Shlibs: Disable bool overload Dpkg::Version warnings. - Dpkg::Vendor::Debian: Inline _parse_feature_area() into _add_build_flags(), for a small speed up and line count reduction. + - Dpkg::BuildFlags: Move default flags setting into the Dpkg::Vendor + modules. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm index 0533b12b5..a8fd4584a 100644 --- a/scripts/Dpkg/BuildFlags.pm +++ b/scripts/Dpkg/BuildFlags.pm @@ -23,7 +23,6 @@ our $VERSION = '1.03'; use Dpkg (); use Dpkg::Gettext; use Dpkg::Build::Env; -use Dpkg::BuildOptions; use Dpkg::ErrorHandling; use Dpkg::Vendor qw(run_vendor_hook); @@ -72,18 +71,15 @@ sub load_vendor_defaults { $self->{options} = {}; $self->{source} = {}; $self->{features} = {}; - my $build_opts = Dpkg::BuildOptions->new(); - $self->{build_options} = $build_opts; - my $default_flags = $build_opts->has('noopt') ? '-g -O0' : '-g -O2'; $self->{flags} = { CPPFLAGS => '', - CFLAGS => $default_flags, - CXXFLAGS => $default_flags, - OBJCFLAGS => $default_flags, - OBJCXXFLAGS => $default_flags, - GCJFLAGS => $default_flags, - FFLAGS => $default_flags, - FCFLAGS => $default_flags, + CFLAGS => '', + CXXFLAGS => '', + OBJCFLAGS => '', + OBJCXXFLAGS => '', + GCJFLAGS => '', + FFLAGS => '', + FCFLAGS => '', LDFLAGS => '', }; $self->{origin} = { diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 2e42a8b86..1e8f24397 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -150,6 +150,22 @@ sub _add_build_flags { ($abi, $os, $cpu) = ('', '', ''); } + ## Global defaults + + my $default_flags; + if ($opts_build->has('noopt')) { + $default_flags = '-g -O0'; + } else { + $default_flags = '-g -O2'; + } + $flags->append('CFLAGS', $default_flags); + $flags->append('CXXFLAGS', $default_flags); + $flags->append('OBJCFLAGS', $default_flags); + $flags->append('OBJCXXFLAGS', $default_flags); + $flags->append('FFLAGS', $default_flags); + $flags->append('FCFLAGS', $default_flags); + $flags->append('GCJFLAGS', $default_flags); + ## Area: future if ($use_feature{future}{lfs}) { @@ -305,7 +321,7 @@ sub _add_build_flags { } # Mask features that might be influenced by other flags. - if ($flags->{build_options}->has('noopt')) { + if ($opts_build->has('noopt')) { # glibc 2.16 and later warn when using -O0 and _FORTIFY_SOURCE. $use_feature{hardening}{fortify} = 0; } -- cgit v1.2.3 From e3c32720167a6c23fc19471d3e3273965c3dc9e5 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 28 Jul 2018 04:08:58 +0200 Subject: Dpkg::Gettext: Fix fallback textdomain() to honor its expected interface Even though we will not use the domain value set by this function, we should honor its original interface and return a domain string, and update it when requested. --- debian/changelog | 1 + scripts/Dpkg/Gettext.pm | 7 +++++++ 2 files changed, 8 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 5a7b8630f..d818667d2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -129,6 +129,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium _add_build_flags(), for a small speed up and line count reduction. - Dpkg::BuildFlags: Move default flags setting into the Dpkg::Vendor modules. + - Dpkg::Gettext: Fix fallback textdomain() to honor its expected interface. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Gettext.pm b/scripts/Dpkg/Gettext.pm index 33ef1c48d..89a4d154f 100644 --- a/scripts/Dpkg/Gettext.pm +++ b/scripts/Dpkg/Gettext.pm @@ -28,6 +28,7 @@ package Dpkg::Gettext; use strict; use warnings; +use feature qw(state); our $VERSION = '1.03'; our @EXPORT = qw( @@ -122,6 +123,12 @@ BEGIN { return shift; }; *textdomain = sub { + my $new_domain = shift; + state $domain = $DEFAULT_TEXT_DOMAIN; + + $domain = $new_domain if defined $new_domain; + + return $domain; }; *ngettext = sub { my ($msgid, $msgid_plural, $n) = @_; -- cgit v1.2.3 From 1d0be95366c19fbc88c891dbedf7613aedbbdea5 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 28 Jul 2018 04:11:17 +0200 Subject: Dpkg::Gettext: Document textdomain() and ngettext() replacement functions We should mention when these functions are present and what they do, so that users know when they can rely on these. Warned-by: Test::Pod::Coverage --- debian/changelog | 2 ++ scripts/Dpkg/Gettext.pm | 13 +++++++++++++ 2 files changed, 15 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index d818667d2..37e11b1ca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -149,6 +149,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium and -d option descriptions. - Mark profiles as a replaceable item in dpkg-buildpackage --help output. - Update test suite requirements in README. + - Document textdomain() and ngettext() replacement functions in + Dpkg::Gettext POD. * Code internals: - Do not use stringy eval to define different sub implementations, just assign an anonymous sub to the typeglob. diff --git a/scripts/Dpkg/Gettext.pm b/scripts/Dpkg/Gettext.pm index 89a4d154f..03b723c9d 100644 --- a/scripts/Dpkg/Gettext.pm +++ b/scripts/Dpkg/Gettext.pm @@ -89,6 +89,19 @@ our $DEFAULT_TEXT_DOMAIN = 'dpkg-dev'; =over 4 +=item $domain = textdomain($new_domain) + +Compatibility textdomain() fallback when Locale::gettext is not available. + +If $new_domain is not undef, it will set the current domain to $new_domain. +Returns the current domain, after possibly changing it. + +=item $trans = ngettext($msgid, $msgid_plural, $n) + +Compatibility ngettext() fallback when Locale::gettext is not available. + +Returns $msgid if $n is 1 or $msgid_plural otherwise. + =item $trans = g_($msgid) Calls dgettext() on the $msgid and returns its translation for the current -- cgit v1.2.3 From 46ed057b6d95545f3ea55b72de29f52e9d8ba885 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 29 Jul 2018 19:56:17 +0200 Subject: Dpkg::Deps: Merge all Copyright notices into the same block There should be no difference between Copyright and Portions Copyright, remove the distinction, and merge all these notices. --- scripts/Dpkg/Deps.pm | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index df8d9f4ec..c7565b73d 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -1,3 +1,8 @@ +# Copyright © 1998 Richard Braakman +# Copyright © 1999 Darren Benham +# Copyright © 2000 Sean 'Shaleh' Perry +# Copyright © 2004 Frank Lichtenheld +# Copyright © 2006 Russ Allbery # Copyright © 2007-2009 Raphaël Hertzog # Copyright © 2008-2009,2012-2014 Guillem Jover # @@ -13,14 +18,6 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -######################################################################### -# Several parts are inspired by lib/Dep.pm from lintian (same license) -# -# Copyright © 1998 Richard Braakman -# Portions Copyright © 1999 Darren Benham -# Portions Copyright © 2000 Sean 'Shaleh' Perry -# Portions Copyright © 2004 Frank Lichtenheld -# Portions Copyright © 2006 Russ Allbery package Dpkg::Deps; -- cgit v1.2.3 From 72742b569f2cf908bc05fa96c5419120e42a10c6 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 29 Jul 2018 20:01:03 +0200 Subject: Dpkg::Deps: Fix typo in POD --- scripts/Dpkg/Deps.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index c7565b73d..885a6c2e1 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -419,7 +419,7 @@ package Dpkg::Deps::Simple; There are several kind of dependencies. A Dpkg::Deps::Simple dependency represents a single dependency statement (it relates to one package only). Dpkg::Deps::Multiple dependencies are built on top of this object -and combine several dependencies in a different manners. Dpkg::Deps::AND +and combine several dependencies in different manners. Dpkg::Deps::AND represents the logical "AND" between dependencies while Dpkg::Deps::OR represents the logical "OR". Dpkg::Deps::Multiple objects can contain Dpkg::Deps::Simple object as well as other Dpkg::Deps::Multiple objects. -- cgit v1.2.3 From 8fd30b60465acd90ffea6aab19ce15eea94a122a Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 28 Jul 2018 22:10:55 +0200 Subject: Dpkg::Deps: Clarify arch-qualified dependency simplification Dependency simplification can only really be done for metadata for which we have all its context and information during the simplification process. Anything that relies on the state of the dependencies cannot be simplified. This means that any dependency that might change the satisfiability due to the value of Multi-Arch field of the depended on package cannot be simplified. Clarify this in the function commends, and add new test cases to cover this. Prompted-by: Stuart Prescott --- debian/changelog | 2 ++ scripts/Dpkg/Deps.pm | 3 +++ scripts/t/Dpkg_Deps.t | 22 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 688c70b53..b76062154 100644 --- a/debian/changelog +++ b/debian/changelog @@ -151,6 +151,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Update test suite requirements in README. - Document textdomain() and ngettext() replacement functions in Dpkg::Gettext POD. + - Clarify arch-qualified dependency simplification in Dpkg::Deps POD. * Code internals: - Do not use stringy eval to define different sub implementations, just assign an anonymous sub to the typeglob. @@ -189,6 +190,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Infer automatically the unit test data directory. - Infer automatically the unit test temp directory. - Add new po author test case (use i18nspector if available). + - Add new test cases to clarify arch-qualified dependency simplification. [ Updated programs translations ] * Dutch (Frans Spiesschaert). Closes: #881401 diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index 885a6c2e1..88cb98eca 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -758,6 +758,9 @@ sub _arch_is_superset { # Because we are handling dependencies in isolation, and the full context # of the implications are only known when doing dependency resolution at # run-time, we can only assert that they are implied if they are equal. +# +# For example dependencies with different arch-qualifiers cannot be simplified +# as these depend on the state of Multi-Arch field in the package depended on. sub _arch_qualifier_implies { my ($p, $q) = @_; diff --git a/scripts/t/Dpkg_Deps.t b/scripts/t/Dpkg_Deps.t index 71a3cf16a..a519f8166 100644 --- a/scripts/t/Dpkg_Deps.t +++ b/scripts/t/Dpkg_Deps.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 70; +use Test::More tests => 74; use Dpkg::Arch qw(get_host_arch); use Dpkg::Version; @@ -233,6 +233,26 @@ is($dep_profiles->output(), 'libfoo-dev:native , libfoo-dev ', 'Simplification respects archqualifiers and profiles'); +my $dep_archqual = deps_parse('pkg, pkg:any'); +$dep_archqual->simplify_deps($facts); +is($dep_archqual->output(), 'pkg, pkg:any', + 'Simplify respect arch-qualified ANDed dependencies 1/2'); + +$dep_archqual = deps_parse('pkg:amd64, pkg:any, pkg:i386'); +$dep_archqual->simplify_deps($facts); +is($dep_archqual->output(), 'pkg:amd64, pkg:any, pkg:i386', + 'Simplify respects arch-qualified ANDed dependencies 2/2'); + +$dep_archqual = deps_parse('pkg | pkg:any'); +$dep_archqual->simplify_deps($facts); +is($dep_archqual->output(), 'pkg | pkg:any', + 'Simplify respect arch-qualified ORed dependencies 1/2'); + +$dep_archqual = deps_parse('pkg:amd64 | pkg:i386 | pkg:any'); +$dep_archqual->simplify_deps($facts); +is($dep_archqual->output(), 'pkg:amd64 | pkg:i386 | pkg:any', + 'Simplify respect arch-qualified ORed dependencies 2/2'); + my $dep_version = deps_parse('pkg, pkg (= 1.0)'); $dep_version->simplify_deps($facts); is($dep_version->output(), 'pkg (= 1.0)', 'Simplification merges versions'); -- cgit v1.2.3 From 8940f102eb5eecfb8ff55cde52d4866ab50dfd1f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 30 Jul 2018 00:37:13 +0200 Subject: Dpkg::Deps: Improve modules and method documentation Document each implemented method. This will make it easier to split the modules into their own files. --- debian/changelog | 1 + scripts/Dpkg/Deps.pm | 528 ++++++++++++++++++++++++++++++++++++--------------- 2 files changed, 378 insertions(+), 151 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index b129604d9..374c09cf8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -152,6 +152,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Document textdomain() and ngettext() replacement functions in Dpkg::Gettext POD. - Clarify arch-qualified dependency simplification in Dpkg::Deps POD. + - Improve Dpkg::Deps modules and methods documentation. * Code internals: - Do not use stringy eval to define different sub implementations, just assign an anonymous sub to the typeglob. diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index 88cb98eca..d6c90cf77 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -433,87 +433,9 @@ dependencies and while trying to simplify them. It represents a set of installed packages along with the virtual packages that they might provide. -=head2 COMMON METHODS +=head2 OBJECT - Dpkg::Deps::Simple -=over 4 - -=item $dep->is_empty() - -Returns true if the dependency is empty and doesn't contain any useful -information. This is true when a Dpkg::Deps::Simple object has not yet -been initialized or when a (descendant of) Dpkg::Deps::Multiple contains -an empty list of dependencies. - -=item $dep->get_deps() - -Returns a list of sub-dependencies. For Dpkg::Deps::Simple it returns -itself. - -=item $dep->output([$fh]) - -=item "$dep" - -Returns a string representing the dependency. If $fh is set, it prints -the string to the filehandle. - -=item $dep->implies($other_dep) - -Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies -NOT($other_dep). Returns undef when there's no implication. $dep and -$other_dep do not need to be of the same type. - -=item $dep->sort() - -Sorts alphabetically the internal list of dependencies. It's a no-op for -Dpkg::Deps::Simple objects. - -=item $dep->arch_is_concerned($arch) - -Returns true if the dependency applies to the indicated architecture. For -multiple dependencies, it returns true if at least one of the -sub-dependencies apply to this architecture. - -=item $dep->reduce_arch($arch) - -Simplifies the dependency to contain only information relevant to the given -architecture. A Dpkg::Deps::Simple object can be left empty after this -operation. For Dpkg::Deps::Multiple objects, the non-relevant -sub-dependencies are simply removed. - -This trims off the architecture restriction list of Dpkg::Deps::Simple -objects. - -=item $dep->get_evaluation($facts) - -Evaluates the dependency given a list of installed packages and a list of -virtual packages provided. Those lists are part of the -Dpkg::Deps::KnownFacts object given as parameters. - -Returns 1 when it's true, 0 when it's false, undef when some information -is lacking to conclude. - -=item $dep->simplify_deps($facts, @assumed_deps) - -Simplifies the dependency as much as possible given the list of facts (see -object Dpkg::Deps::KnownFacts) and a list of other dependencies that are -known to be true. - -=item $dep->has_arch_restriction() - -For a simple dependency, returns the package name if the dependency -applies only to a subset of architectures. For multiple dependencies, it -returns the list of package names that have such a restriction. - -=item $dep->reset() - -Clears any dependency information stored in $dep so that $dep->is_empty() -returns true. - -=back - -=head2 Dpkg::Deps::Simple - -Such an object has four interesting properties: +This object has several interesting properties: =over 4 @@ -534,33 +456,26 @@ The version. =item arches -The list of architectures where this dependency is applicable. It's -undefined when there's no restriction, otherwise it's an +The list of architectures where this dependency is applicable. It is +undefined when there's no restriction, otherwise it is an array ref. It can contain an exclusion list, in that case each architecture is prefixed with an exclamation mark. =item archqual -The arch qualifier of the dependency (can be undef if there's none). +The arch qualifier of the dependency (can be undef if there is none). In the dependency "python:any (>= 2.6)", the arch qualifier is "any". -=back - -=head3 METHODS - -=over 4 - -=item $simple_dep->parse_string('dpkg-dev (>= 1.14.8) [!hurd-i386]') +=item restrictions -Parses the dependency and modifies internal properties to match the parsed -dependency. +The restrictions formula for this dependency. It is undefined when there +is no restriction formula. Otherwise it is an array ref. -=item $simple_dep->merge_union($other_dep) +=back -Returns true if $simple_dep could be modified to represent the union of -both dependencies. Otherwise returns false. +=head2 METHODS - Dpkg::Deps::Simple -=back +=over 4 =cut @@ -577,6 +492,34 @@ use Dpkg::Gettext; use parent qw(Dpkg::Interface::Storable); +=item $dep = Dpkg::Deps::Simple->new(%opts); + +Creates a new object. Some options can be set through %opts: + +=over + +=item host_arch + +Sets the host architecture. + +=item build_arch + +Sets the build architecture. + +=item build_dep + +Specifies whether the parser should consider it a build dependency. +Defaults to 0. + +=item tests_dep + +Specifies whether the parser should consider it a tests dependency. +Defaults to 0. + +=back + +=cut + sub new { my ($this, $arg, %opts) = @_; my $class = ref($this) || $this; @@ -591,6 +534,13 @@ sub new { return $self; } +=item $dep->reset() + +Clears any dependency information stored in $dep so that $dep->is_empty() +returns true. + +=cut + sub reset { my $self = shift; $self->{package} = undef; @@ -601,6 +551,12 @@ sub reset { $self->{restrictions} = undef; } +=item $dep->parse($fh, $desc) + +Parses a line from a filehandle. + +=cut + sub parse { my ($self, $fh, $desc) = @_; my $line = <$fh>; @@ -608,6 +564,13 @@ sub parse { return $self->parse_string($line); } +=item $dep->parse_string($dep_string) + +Parses the dependency string and modifies internal properties to match the +parsed dependency. + +=cut + sub parse_string { my ($self, $dep) = @_; @@ -662,6 +625,15 @@ sub parse_string { } } +=item $dep->output([$fh]) + +=item "$dep" + +Returns a string representing the dependency. If $fh is set, it prints +the string to the filehandle. + +=cut + sub output { my ($self, $fh) = @_; my $res = $self->{package}; @@ -799,9 +771,14 @@ sub _restrictions_imply { } } -# Returns true if the dependency in parameter can deduced from the current -# dependency. Returns false if it can be negated. Returns undef if nothing -# can be concluded. +=item $dep->implies($other_dep) + +Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies +NOT($other_dep). Returns undef when there is no implication. $dep and +$other_dep do not need to be of the same type. + +=cut + sub implies { my ($self, $o) = @_; if ($o->isa('Dpkg::Deps::Simple')) { @@ -868,15 +845,34 @@ sub implies { } } +=item $dep->get_deps() + +Returns a list of sub-dependencies, which for this object it means it +returns itself. + +=cut + sub get_deps { my $self = shift; return $self; } +=item $dep->sort() + +This method is a no-op for this object. + +=cut + sub sort { # Nothing to sort } +=item $dep->arch_is_concerned($arch) + +Returns true if the dependency applies to the indicated architecture. + +=cut + sub arch_is_concerned { my ($self, $host_arch) = @_; @@ -886,6 +882,14 @@ sub arch_is_concerned { return debarch_is_concerned($host_arch, @{$self->{arches}}); } +=item $dep->reduce_arch($arch) + +Simplifies the dependency to contain only information relevant to the given +architecture. This object can be left empty after this operation. This trims +off the architecture restriction list of these objects. + +=cut + sub reduce_arch { my ($self, $host_arch) = @_; if (not $self->arch_is_concerned($host_arch)) { @@ -895,6 +899,13 @@ sub reduce_arch { } } +=item $dep->has_arch_restriction() + +Returns the package name if the dependency applies only to a subset of +architectures. + +=cut + sub has_arch_restriction { my $self = shift; if (defined $self->{arches}) { @@ -904,6 +915,12 @@ sub has_arch_restriction { } } +=item $dep->profile_is_concerned() + +Returns true if the dependency applies to the indicated profile. + +=cut + sub profile_is_concerned { my ($self, $build_profiles) = @_; @@ -912,6 +929,14 @@ sub profile_is_concerned { return evaluate_restriction_formula($self->{restrictions}, $build_profiles); } +=item $dep->reduce_profiles() + +Simplifies the dependency to contain only information relevant to the given +profile. This object can be left empty after this operation. This trims off +the profile restriction list of this object. + +=cut + sub reduce_profiles { my ($self, $build_profiles) = @_; @@ -922,23 +947,56 @@ sub reduce_profiles { } } +=item $dep->get_evaluation($facts) + +Evaluates the dependency given a list of installed packages and a list of +virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts +object given as parameters. + +Returns 1 when it's true, 0 when it's false, undef when some information +is lacking to conclude. + +=cut + sub get_evaluation { my ($self, $facts) = @_; return if not defined $self->{package}; return $facts->_evaluate_simple_dep($self); } +=item $dep->simplify_deps($facts, @assumed_deps) + +Simplifies the dependency as much as possible given the list of facts (see +object Dpkg::Deps::KnownFacts) and a list of other dependencies that are +known to be true. + +=cut + sub simplify_deps { my ($self, $facts) = @_; my $eval = $self->get_evaluation($facts); $self->reset() if defined $eval and $eval == 1; } +=item $dep->is_empty() + +Returns true if the dependency is empty and doesn't contain any useful +information. This is true when the object has not yet been initialized. + +=cut + sub is_empty { my $self = shift; return not defined $self->{package}; } +=item $dep->merge_union($other_dep) + +Returns true if $dep could be modified to represent the union of both +dependencies. Otherwise returns false. + +=cut + sub merge_union { my ($self, $o) = @_; return 0 if not $o->isa('Dpkg::Deps::Simple'); @@ -975,20 +1033,19 @@ sub merge_union { return 0; } -package Dpkg::Deps::Multiple; +=back -=head2 Dpkg::Deps::Multiple +=cut -This is the base class for Dpkg::Deps::{AND,OR,Union}. It implements -the following methods: +package Dpkg::Deps::Multiple; -=over 4 +=head2 OBJECT - Dpkg::Deps::Multiple -=item $mul->add($dep) +This is the base class for Dpkg::Deps::{AND,OR,Union}. -Adds a new dependency object at the end of the list. +=head2 METHODS - Dpkg::Deps::Multiple -=back +=over 4 =cut @@ -1001,6 +1058,12 @@ use Dpkg::ErrorHandling; use parent qw(Dpkg::Interface::Storable); +=item $dep = Dpkg::Deps::Multiple->new(%opts); + +Creates a new object. + +=cut + sub new { my $this = shift; my $class = ref($this) || $this; @@ -1009,21 +1072,46 @@ sub new { return $self; } +=item $dep->reset() + +Clears any dependency information stored in $dep so that $dep->is_empty() +returns true. + +=cut + sub reset { my $self = shift; $self->{list} = []; } +=item $dep->add(@deps) + +Adds new dependency objects at the end of the list. + +=cut + sub add { my $self = shift; push @{$self->{list}}, @_; } +=item $dep->get_deps() + +Returns a list of sub-dependencies. + +=cut + sub get_deps { my $self = shift; return grep { not $_->is_empty() } @{$self->{list}}; } +=item $dep->sort() + +Sorts alphabetically the internal list of dependencies. + +=cut + sub sort { my $self = shift; my @res = (); @@ -1031,6 +1119,13 @@ sub sort { $self->{list} = [ @res ]; } +=item $dep->arch_is_concerned($arch) + +Returns true if at least one of the sub-dependencies apply to this +architecture. + +=cut + sub arch_is_concerned { my ($self, $host_arch) = @_; my $res = 0; @@ -1040,6 +1135,16 @@ sub arch_is_concerned { return $res; } +=item $dep->reduce_arch($arch) + +Simplifies the dependencies to contain only information relevant to the +given architecture. The non-relevant sub-dependencies are simply removed. + +This trims off the architecture restriction list of Dpkg::Deps::Simple +objects. + +=cut + sub reduce_arch { my ($self, $host_arch) = @_; my @new; @@ -1050,6 +1155,12 @@ sub reduce_arch { $self->{list} = [ @new ]; } +=item $dep->has_arch_restriction() + +Returns the list of package names that have such a restriction. + +=cut + sub has_arch_restriction { my $self = shift; my @res; @@ -1059,6 +1170,12 @@ sub has_arch_restriction { return @res; } +=item $dep->profile_is_concerned() + +Returns true if at least one of the sub-dependencies apply to this profile. + +=cut + sub profile_is_concerned { my ($self, $build_profiles) = @_; my $res = 0; @@ -1069,6 +1186,15 @@ sub profile_is_concerned { return $res; } +=item $dep->reduce_profiles() + +Simplifies the dependencies to contain only information relevant to the +given profile. The non-relevant sub-dependencies are simply removed. + +This trims off the profile restriction list of Dpkg::Deps::Simple objects. + +=cut + sub reduce_profiles { my ($self, $build_profiles) = @_; my @new; @@ -1080,29 +1206,43 @@ sub reduce_profiles { $self->{list} = [ @new ]; } +=item $dep->is_empty() + +Returns true if the dependency is empty and doesn't contain any useful +information. This is true when a (descendant of) Dpkg::Deps::Multiple +contains an empty list of dependencies. + +=cut + sub is_empty { my $self = shift; return scalar @{$self->{list}} == 0; } +=item $dep->merge_union($other_dep) + +This method is not meaningful for this object, and will always croak. + +=cut + sub merge_union { croak 'method merge_union() is only valid for Dpkg::Deps::Simple'; } -package Dpkg::Deps::AND; +=back -=head2 Dpkg::Deps::AND +=cut -This object represents a list of dependencies who must be met at the same -time. +package Dpkg::Deps::AND; -=over 4 +=head2 OBJECT - Dpkg::Deps::AND -=item $and->output([$fh]) +This object represents a list of dependencies that must be met at the same +time. It inherits from Dpkg::Deps::Multiple. -The output method uses ", " to join the list of sub-dependencies. +=head2 METHODS - Dpkg::Deps::AND -=back +=over 4 =cut @@ -1111,6 +1251,12 @@ use warnings; use parent -norequire, qw(Dpkg::Deps::Multiple); +=item $dep->output([$fh]) + +The output method uses ", " to join the list of sub-dependencies. + +=cut + sub output { my ($self, $fh) = @_; my $res = join(', ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps()); @@ -1120,6 +1266,14 @@ sub output { return $res; } +=item $dep->implies($other_dep) + +Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies +NOT($other_dep). Returns undef when there's no implication. $dep and +$other_dep do not need to be of the same type. + +=cut + sub implies { my ($self, $o) = @_; # If any individual member can imply $o or NOT $o, we're fine @@ -1144,6 +1298,17 @@ sub implies { return; } +=item $dep->get_evaluation($facts) + +Evaluates the dependency given a list of installed packages and a list of +virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts +object given as parameters. + +Returns 1 when it's true, 0 when it's false, undef when some information +is lacking to conclude. + +=cut + sub get_evaluation { my ($self, $facts) = @_; # Return 1 only if all members evaluates to true @@ -1164,6 +1329,14 @@ sub get_evaluation { return $result; } +=item $dep->simplify_deps($facts, @assumed_deps) + +Simplifies the dependency as much as possible given the list of facts (see +object Dpkg::Deps::KnownFacts) and a list of other dependencies that are +known to be true. + +=cut + sub simplify_deps { my ($self, $facts, @knowndeps) = @_; my @new; @@ -1193,21 +1366,20 @@ WHILELOOP: $self->{list} = [ @new ]; } +=back + +=cut package Dpkg::Deps::OR; -=head2 Dpkg::Deps::OR +=head2 OBJECT - Dpkg::Deps::OR This object represents a list of dependencies of which only one must be met -for the dependency to be true. - -=over 4 - -=item $or->output([$fh]) +for the dependency to be true. It inherits from Dpkg::Deps::Multiple. -The output method uses " | " to join the list of sub-dependencies. +=head2 METHODS - Dpkg::Deps::OR -=back +=over 4 =cut @@ -1216,6 +1388,12 @@ use warnings; use parent -norequire, qw(Dpkg::Deps::Multiple); +=item $dep->output([$fh]) + +The output method uses " | " to join the list of sub-dependencies. + +=cut + sub output { my ($self, $fh) = @_; my $res = join(' | ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps()); @@ -1225,6 +1403,14 @@ sub output { return $res; } +=item $dep->implies($other_dep) + +Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies +NOT($other_dep). Returns undef when there's no implication. $dep and +$other_dep do not need to be of the same type. + +=cut + sub implies { my ($self, $o) = @_; @@ -1252,6 +1438,17 @@ sub implies { return; } +=item $dep->get_evaluation($facts) + +Evaluates the dependency given a list of installed packages and a list of +virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts +object given as parameters. + +Returns 1 when it's true, 0 when it's false, undef when some information +is lacking to conclude. + +=cut + sub get_evaluation { my ($self, $facts) = @_; # Returns false if all members evaluates to 0 @@ -1272,6 +1469,14 @@ sub get_evaluation { return $result; } +=item $dep->simplify_deps($facts, @assumed_deps) + +Simplifies the dependency as much as possible given the list of facts (see +object Dpkg::Deps::KnownFacts) and a list of other dependencies that are +known to be true. + +=cut + sub simplify_deps { my ($self, $facts) = @_; my @new; @@ -1292,30 +1497,20 @@ WHILELOOP: $self->{list} = [ @new ]; } -package Dpkg::Deps::Union; - -=head2 Dpkg::Deps::Union - -This object represents a list of relationships. - -=over 4 - -=item $union->output([$fh]) - -The output method uses ", " to join the list of relationships. +=back -=item $union->implies($other_dep) +=cut -=item $union->get_evaluation($other_dep) +package Dpkg::Deps::Union; -Those methods are not meaningful for this object and always return undef. +=head2 OBJECT - Dpkg::Deps::Union -=item $union->simplify_deps($facts) +This object represents a list of relationships. It inherits from +Dpkg::Deps::Multiple. -The simplification is done to generate an union of all the relationships. -It uses $simple_dep->merge_union($other_dep) to get its job done. +=head2 METHODS - Dpkg::Deps::Union -=back +=over 4 =cut @@ -1324,6 +1519,12 @@ use warnings; use parent -norequire, qw(Dpkg::Deps::Multiple); +=item $dep->output([$fh]) + +The output method uses ", " to join the list of relationships. + +=cut + sub output { my ($self, $fh) = @_; my $res = join(', ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps()); @@ -1333,16 +1534,31 @@ sub output { return $res; } +=item $dep->implies($other_dep) + +=item $dep->get_evaluation($other_dep) + +These methods are not meaningful for this object and always return undef. + +=cut + sub implies { - # Implication test are not useful on Union + # Implication test is not useful on Union. return; } sub get_evaluation { - # Evaluation are not useful on Union + # Evaluation is not useful on Union. return; } +=item $dep->simplify_deps($facts) + +The simplification is done to generate an union of all the relationships. +It uses $simple_dep->merge_union($other_dep) to get its job done. + +=cut + sub simplify_deps { my ($self, $facts) = @_; my @new; @@ -1358,18 +1574,20 @@ WHILELOOP: $self->{list} = [ @new ]; } +=back + +=cut + package Dpkg::Deps::KnownFacts; -=head2 Dpkg::Deps::KnownFacts +=head2 OBJECT - Dpkg::Deps::KnownFacts This object represents a list of installed packages and a list of virtual packages provided (by the set of installed packages). -=over 4 - -=item $facts = Dpkg::Deps::KnownFacts->new(); +=head2 METHODS - Dpkg::Deps::KnownFacts -Creates a new object. +=over 4 =cut @@ -1378,6 +1596,12 @@ use warnings; use Dpkg::Version; +=item $facts = Dpkg::Deps::KnownFacts->new(); + +Creates a new object. + +=cut + sub new { my $this = shift; my $class = ref($this) || $this; @@ -1445,8 +1669,6 @@ This function is obsolete and should not be used. Dpkg::Deps::KnownFacts is only meant to be filled with data and then passed to Dpkg::Deps methods where appropriate, but it should not be directly queried. -=back - =cut sub check_package { @@ -1467,7 +1689,9 @@ sub check_package { return (0, undef); } -## The functions below are private to Dpkg::Deps +## +## The functions below are private to Dpkg::Deps::KnownFacts. +## sub _find_package { my ($self, $dep, $lackinfos) = @_; @@ -1534,6 +1758,8 @@ sub _evaluate_simple_dep { return 0; } +=back + =head1 CHANGES =head2 Version 1.06 (dpkg 1.18.7; module version bumped on dpkg 1.18.24) -- cgit v1.2.3 From 3d4afe2967eccd7805d067a3eab6938f7f099a63 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 30 Jul 2018 04:31:32 +0200 Subject: Dpkg::Deps::KnownFacts: Rename _evaluate_simple_dep to evaluate_simple_dep This method is currently used by Dpkg::Deps::Simple, and is marked as private by way of its underscore prefix. This will be a problem once we split the modules into different files, as then we are not supposed to be using private methods from external modules. Rename the method, and document it explicitly as being private, while only giving a partial prototype to deter its use. --- scripts/Dpkg/Deps.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index d6c90cf77..613ca2d7a 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -961,7 +961,7 @@ is lacking to conclude. sub get_evaluation { my ($self, $facts) = @_; return if not defined $self->{package}; - return $facts->_evaluate_simple_dep($self); + return $facts->evaluate_simple_dep($self); } =item $dep->simplify_deps($facts, @assumed_deps) @@ -1726,7 +1726,13 @@ sub _find_virtual_packages { return @{$self->{virtualpkg}{$pkg}}; } -sub _evaluate_simple_dep { +=item $facts->evaluate_simple_dep() + +This method is private and should not be used except from within Dpkg::Deps. + +=cut + +sub evaluate_simple_dep { my ($self, $dep) = @_; my ($lackinfos, $pkg) = (0, $dep->{package}); my $p = $self->_find_package($dep, \$lackinfos); -- cgit v1.2.3 From 738c8d5d545e164c3e7450751960618443bf7431 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 30 Jul 2018 01:26:08 +0200 Subject: Dpkg::Deps: Split subpackages This makes the structure easier to comprehend, and easier to read, otherwise it's difficutl to search for specific methods or functions and know immediately to what module they belong. It also makes for more structured POD. --- debian/changelog | 1 + scripts/Dpkg/Deps.pm | 1379 +-------------------------------------- scripts/Dpkg/Deps/AND.pm | 182 ++++++ scripts/Dpkg/Deps/KnownFacts.pm | 244 +++++++ scripts/Dpkg/Deps/Multiple.pm | 250 +++++++ scripts/Dpkg/Deps/OR.pm | 174 +++++ scripts/Dpkg/Deps/Simple.pm | 659 +++++++++++++++++++ scripts/Dpkg/Deps/Union.pm | 119 ++++ scripts/Makefile.am | 6 + scripts/po/POTFILES.in | 6 + 10 files changed, 1659 insertions(+), 1361 deletions(-) create mode 100644 scripts/Dpkg/Deps/AND.pm create mode 100644 scripts/Dpkg/Deps/KnownFacts.pm create mode 100644 scripts/Dpkg/Deps/Multiple.pm create mode 100644 scripts/Dpkg/Deps/OR.pm create mode 100644 scripts/Dpkg/Deps/Simple.pm create mode 100644 scripts/Dpkg/Deps/Union.pm (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 374c09cf8..d0c53872d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -130,6 +130,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::BuildFlags: Move default flags setting into the Dpkg::Vendor modules. - Dpkg::Gettext: Fix fallback textdomain() to honor its expected interface. + - Dpkg::Deps: Split subpackages into their own separate modules. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index 613ca2d7a..f3a19e78e 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -63,6 +63,11 @@ use Dpkg::Arch qw(get_host_arch get_build_arch debarch_to_debtuple); use Dpkg::BuildProfiles qw(get_build_profiles); use Dpkg::ErrorHandling; use Dpkg::Gettext; +use Dpkg::Deps::Simple; +use Dpkg::Deps::Union; +use Dpkg::Deps::AND; +use Dpkg::Deps::OR; +use Dpkg::Deps::KnownFacts; =item deps_eval_implication($rel_p, $v_p, $rel_q, $v_q) @@ -411,9 +416,6 @@ sub deps_compare { } } - -package Dpkg::Deps::Simple; - =head1 OBJECTS - Dpkg::Deps::* There are several kind of dependencies. A Dpkg::Deps::Simple dependency @@ -433,1377 +435,32 @@ dependencies and while trying to simplify them. It represents a set of installed packages along with the virtual packages that they might provide. -=head2 OBJECT - Dpkg::Deps::Simple - -This object has several interesting properties: - -=over 4 - -=item package - -The package name (can be undef if the dependency has not been initialized -or if the simplification of the dependency lead to its removal). - -=item relation - -The relational operator: "=", "<<", "<=", ">=" or ">>". It can be -undefined if the dependency had no version restriction. In that case the -following field is also undefined. - -=item version - -The version. - -=item arches - -The list of architectures where this dependency is applicable. It is -undefined when there's no restriction, otherwise it is an -array ref. It can contain an exclusion list, in that case each -architecture is prefixed with an exclamation mark. - -=item archqual - -The arch qualifier of the dependency (can be undef if there is none). -In the dependency "python:any (>= 2.6)", the arch qualifier is "any". - -=item restrictions - -The restrictions formula for this dependency. It is undefined when there -is no restriction formula. Otherwise it is an array ref. - -=back - -=head2 METHODS - Dpkg::Deps::Simple - -=over 4 - -=cut - -use strict; -use warnings; - -use Carp; - -use Dpkg::Arch qw(debarch_is_concerned debarch_list_parse); -use Dpkg::BuildProfiles qw(parse_build_profiles evaluate_restriction_formula); -use Dpkg::Version; -use Dpkg::ErrorHandling; -use Dpkg::Gettext; - -use parent qw(Dpkg::Interface::Storable); - -=item $dep = Dpkg::Deps::Simple->new(%opts); - -Creates a new object. Some options can be set through %opts: - -=over - -=item host_arch - -Sets the host architecture. - -=item build_arch - -Sets the build architecture. - -=item build_dep - -Specifies whether the parser should consider it a build dependency. -Defaults to 0. - -=item tests_dep - -Specifies whether the parser should consider it a tests dependency. -Defaults to 0. - -=back - -=cut - -sub new { - my ($this, $arg, %opts) = @_; - my $class = ref($this) || $this; - my $self = {}; - bless $self, $class; - $self->reset(); - $self->{host_arch} = $opts{host_arch}; - $self->{build_arch} = $opts{build_arch}; - $self->{build_dep} = $opts{build_dep} // 0; - $self->{tests_dep} = $opts{tests_dep} // 0; - $self->parse_string($arg) if defined($arg); - return $self; -} - -=item $dep->reset() - -Clears any dependency information stored in $dep so that $dep->is_empty() -returns true. - -=cut - -sub reset { - my $self = shift; - $self->{package} = undef; - $self->{relation} = undef; - $self->{version} = undef; - $self->{arches} = undef; - $self->{archqual} = undef; - $self->{restrictions} = undef; -} - -=item $dep->parse($fh, $desc) - -Parses a line from a filehandle. - -=cut - -sub parse { - my ($self, $fh, $desc) = @_; - my $line = <$fh>; - chomp($line); - return $self->parse_string($line); -} - -=item $dep->parse_string($dep_string) - -Parses the dependency string and modifies internal properties to match the -parsed dependency. - -=cut - -sub parse_string { - my ($self, $dep) = @_; - - my $pkgname_re; - if ($self->{tests_dep}) { - $pkgname_re = qr/[\@a-zA-Z0-9][\@a-zA-Z0-9+.-]*/; - } else { - $pkgname_re = qr/[a-zA-Z0-9][a-zA-Z0-9+.-]*/; - } - - return if not $dep =~ - m{^\s* # skip leading whitespace - ($pkgname_re) # package name - (?: # start of optional part - : # colon for architecture - ([a-zA-Z0-9][a-zA-Z0-9-]*) # architecture name - )? # end of optional part - (?: # start of optional part - \s* \( # open parenthesis for version part - \s* (<<|<=|=|>=|>>|[<>]) # relation part - \s* ([^\)\s]+) # do not attempt to parse version - \s* \) # closing parenthesis - )? # end of optional part - (?: # start of optional architecture - \s* \[ # open bracket for architecture - \s* ([^\]]+) # don't parse architectures now - \s* \] # closing bracket - )? # end of optional architecture - ( - (?: # start of optional restriction - \s* < # open bracket for restriction - \s* [^>]+ # do not parse restrictions now - \s* > # closing bracket - )+ - )? # end of optional restriction - \s*$ # trailing spaces at end - }x; - if (defined($2)) { - return if $2 eq 'native' and not $self->{build_dep}; - $self->{archqual} = $2; - } - $self->{package} = $1; - $self->{relation} = version_normalize_relation($3) if defined($3); - if (defined($4)) { - $self->{version} = Dpkg::Version->new($4); - } - if (defined($5)) { - $self->{arches} = [ debarch_list_parse($5) ]; - } - if (defined($6)) { - $self->{restrictions} = [ parse_build_profiles($6) ]; - } -} - -=item $dep->output([$fh]) - -=item "$dep" - -Returns a string representing the dependency. If $fh is set, it prints -the string to the filehandle. - -=cut - -sub output { - my ($self, $fh) = @_; - my $res = $self->{package}; - if (defined($self->{archqual})) { - $res .= ':' . $self->{archqual}; - } - if (defined($self->{relation})) { - $res .= ' (' . $self->{relation} . ' ' . $self->{version} . ')'; - } - if (defined($self->{arches})) { - $res .= ' [' . join(' ', @{$self->{arches}}) . ']'; - } - if (defined($self->{restrictions})) { - for my $restrlist (@{$self->{restrictions}}) { - $res .= ' <' . join(' ', @{$restrlist}) . '>'; - } - } - if (defined($fh)) { - print { $fh } $res; - } - return $res; -} - -# _arch_is_superset(\@p, \@q) -# -# Returns true if the arch list @p is a superset of arch list @q. -# The arguments can also be undef in case there's no explicit architecture -# restriction. -sub _arch_is_superset { - my ($p, $q) = @_; - my $p_arch_neg = defined($p) && $p->[0] =~ /^!/; - my $q_arch_neg = defined($q) && $q->[0] =~ /^!/; - - # If "p" has no arches, it is a superset of q and we should fall through - # to the version check. - if (not defined $p) { - return 1; - } - - # If q has no arches, it is a superset of p and there are no useful - # implications. - elsif (not defined $q) { - return 0; - } - - # Both have arches. If neither are negated, we know nothing useful - # unless q is a subset of p. - elsif (not $p_arch_neg and not $q_arch_neg) { - my %p_arches = map { $_ => 1 } @{$p}; - my $subset = 1; - for my $arch (@{$q}) { - $subset = 0 unless $p_arches{$arch}; - } - return 0 unless $subset; - } - - # If both are negated, we know nothing useful unless p is a subset of - # q (and therefore has fewer things excluded, and therefore is more - # general). - elsif ($p_arch_neg and $q_arch_neg) { - my %q_arches = map { $_ => 1 } @{$q}; - my $subset = 1; - for my $arch (@{$p}) { - $subset = 0 unless $q_arches{$arch}; - } - return 0 unless $subset; - } - - # If q is negated and p isn't, we'd need to know the full list of - # arches to know if there's any relationship, so bail. - elsif (not $p_arch_neg and $q_arch_neg) { - return 0; - } - - # If p is negated and q isn't, q is a subset of p if none of the - # negated arches in p are present in q. - elsif ($p_arch_neg and not $q_arch_neg) { - my %q_arches = map { $_ => 1 } @{$q}; - my $subset = 1; - for my $arch (@{$p}) { - $subset = 0 if $q_arches{substr($arch, 1)}; - } - return 0 unless $subset; - } - return 1; -} - -# _arch_qualifier_implies($p, $q) -# -# Returns true if the arch qualifier $p and $q are compatible with the -# implication $p -> $q, false otherwise. $p/$q can be undef/"any"/"native" -# or an architecture string. -# -# Because we are handling dependencies in isolation, and the full context -# of the implications are only known when doing dependency resolution at -# run-time, we can only assert that they are implied if they are equal. -# -# For example dependencies with different arch-qualifiers cannot be simplified -# as these depend on the state of Multi-Arch field in the package depended on. -sub _arch_qualifier_implies { - my ($p, $q) = @_; - - return $p eq $q if defined $p and defined $q; - return 1 if not defined $p and not defined $q; - return 0; -} - -# _restrictions_imply($p, $q) -# -# Returns true if the restrictions $p and $q are compatible with the -# implication $p -> $q, false otherwise. -# NOTE: We don't try to be very clever here, so we may conservatively -# return false when there is an implication. -sub _restrictions_imply { - my ($p, $q) = @_; - - if (not defined $p) { - return 1; - } elsif (not defined $q) { - return 0; - } else { - # Check whether set difference is empty. - my %restr; - - for my $restrlist (@{$q}) { - my $reststr = join ' ', sort @{$restrlist}; - $restr{$reststr} = 1; - } - for my $restrlist (@{$p}) { - my $reststr = join ' ', sort @{$restrlist}; - delete $restr{$reststr}; - } - - return keys %restr == 0; - } -} - -=item $dep->implies($other_dep) - -Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies -NOT($other_dep). Returns undef when there is no implication. $dep and -$other_dep do not need to be of the same type. - -=cut - -sub implies { - my ($self, $o) = @_; - if ($o->isa('Dpkg::Deps::Simple')) { - # An implication is only possible on the same package - return if $self->{package} ne $o->{package}; - - # Our architecture set must be a superset of the architectures for - # o, otherwise we can't conclude anything. - return unless _arch_is_superset($self->{arches}, $o->{arches}); - - # The arch qualifier must not forbid an implication - return unless _arch_qualifier_implies($self->{archqual}, - $o->{archqual}); - - # Our restrictions must imply the restrictions for o - return unless _restrictions_imply($self->{restrictions}, - $o->{restrictions}); - - # If o has no version clause, then our dependency is stronger - return 1 if not defined $o->{relation}; - # If o has a version clause, we must also have one, otherwise there - # can't be an implication - return if not defined $self->{relation}; - - return Dpkg::Deps::deps_eval_implication($self->{relation}, - $self->{version}, $o->{relation}, $o->{version}); - - } elsif ($o->isa('Dpkg::Deps::AND')) { - # TRUE: Need to imply all individual elements - # FALSE: Need to NOT imply at least one individual element - my $res = 1; - foreach my $dep ($o->get_deps()) { - my $implication = $self->implies($dep); - unless (defined($implication) && $implication == 1) { - $res = $implication; - last if defined $res; - } - } - return $res; - } elsif ($o->isa('Dpkg::Deps::OR')) { - # TRUE: Need to imply at least one individual element - # FALSE: Need to not apply all individual elements - # UNDEF: The rest - my $res = undef; - foreach my $dep ($o->get_deps()) { - my $implication = $self->implies($dep); - if (defined($implication)) { - if (not defined $res) { - $res = $implication; - } else { - if ($implication) { - $res = 1; - } else { - $res = 0; - } - } - last if defined($res) && $res == 1; - } - } - return $res; - } else { - croak 'Dpkg::Deps::Simple cannot evaluate implication with a ' . - ref($o); - } -} - -=item $dep->get_deps() - -Returns a list of sub-dependencies, which for this object it means it -returns itself. - -=cut - -sub get_deps { - my $self = shift; - return $self; -} - -=item $dep->sort() - -This method is a no-op for this object. - -=cut - -sub sort { - # Nothing to sort -} - -=item $dep->arch_is_concerned($arch) - -Returns true if the dependency applies to the indicated architecture. - -=cut - -sub arch_is_concerned { - my ($self, $host_arch) = @_; - - return 0 if not defined $self->{package}; # Empty dep - return 1 if not defined $self->{arches}; # Dep without arch spec - - return debarch_is_concerned($host_arch, @{$self->{arches}}); -} - -=item $dep->reduce_arch($arch) - -Simplifies the dependency to contain only information relevant to the given -architecture. This object can be left empty after this operation. This trims -off the architecture restriction list of these objects. - -=cut - -sub reduce_arch { - my ($self, $host_arch) = @_; - if (not $self->arch_is_concerned($host_arch)) { - $self->reset(); - } else { - $self->{arches} = undef; - } -} - -=item $dep->has_arch_restriction() - -Returns the package name if the dependency applies only to a subset of -architectures. - -=cut - -sub has_arch_restriction { - my $self = shift; - if (defined $self->{arches}) { - return $self->{package}; - } else { - return (); - } -} - -=item $dep->profile_is_concerned() - -Returns true if the dependency applies to the indicated profile. - -=cut - -sub profile_is_concerned { - my ($self, $build_profiles) = @_; - - return 0 if not defined $self->{package}; # Empty dep - return 1 if not defined $self->{restrictions}; # Dep without restrictions - return evaluate_restriction_formula($self->{restrictions}, $build_profiles); -} - -=item $dep->reduce_profiles() - -Simplifies the dependency to contain only information relevant to the given -profile. This object can be left empty after this operation. This trims off -the profile restriction list of this object. - -=cut - -sub reduce_profiles { - my ($self, $build_profiles) = @_; - - if (not $self->profile_is_concerned($build_profiles)) { - $self->reset(); - } else { - $self->{restrictions} = undef; - } -} - -=item $dep->get_evaluation($facts) - -Evaluates the dependency given a list of installed packages and a list of -virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts -object given as parameters. - -Returns 1 when it's true, 0 when it's false, undef when some information -is lacking to conclude. - -=cut - -sub get_evaluation { - my ($self, $facts) = @_; - return if not defined $self->{package}; - return $facts->evaluate_simple_dep($self); -} - -=item $dep->simplify_deps($facts, @assumed_deps) - -Simplifies the dependency as much as possible given the list of facts (see -object Dpkg::Deps::KnownFacts) and a list of other dependencies that are -known to be true. - -=cut - -sub simplify_deps { - my ($self, $facts) = @_; - my $eval = $self->get_evaluation($facts); - $self->reset() if defined $eval and $eval == 1; -} - -=item $dep->is_empty() - -Returns true if the dependency is empty and doesn't contain any useful -information. This is true when the object has not yet been initialized. - -=cut - -sub is_empty { - my $self = shift; - return not defined $self->{package}; -} - -=item $dep->merge_union($other_dep) - -Returns true if $dep could be modified to represent the union of both -dependencies. Otherwise returns false. - -=cut - -sub merge_union { - my ($self, $o) = @_; - return 0 if not $o->isa('Dpkg::Deps::Simple'); - return 0 if $self->is_empty() or $o->is_empty(); - return 0 if $self->{package} ne $o->{package}; - return 0 if defined $self->{arches} or defined $o->{arches}; - - if (not defined $o->{relation} and defined $self->{relation}) { - # Union is the non-versioned dependency - $self->{relation} = undef; - $self->{version} = undef; - return 1; - } - - my $implication = $self->implies($o); - my $rev_implication = $o->implies($self); - if (defined($implication)) { - if ($implication) { - $self->{relation} = $o->{relation}; - $self->{version} = $o->{version}; - return 1; - } else { - return 0; - } - } - if (defined($rev_implication)) { - if ($rev_implication) { - # Already merged... - return 1; - } else { - return 0; - } - } - return 0; -} - -=back - -=cut - -package Dpkg::Deps::Multiple; - -=head2 OBJECT - Dpkg::Deps::Multiple - -This is the base class for Dpkg::Deps::{AND,OR,Union}. - -=head2 METHODS - Dpkg::Deps::Multiple - -=over 4 - -=cut - -use strict; -use warnings; - -use Carp; - -use Dpkg::ErrorHandling; - -use parent qw(Dpkg::Interface::Storable); - -=item $dep = Dpkg::Deps::Multiple->new(%opts); - -Creates a new object. - -=cut - -sub new { - my $this = shift; - my $class = ref($this) || $this; - my $self = { list => [ @_ ] }; - bless $self, $class; - return $self; -} +=head1 CHANGES -=item $dep->reset() +=head2 Version 1.06 (dpkg 1.18.7; module version bumped on dpkg 1.18.24) -Clears any dependency information stored in $dep so that $dep->is_empty() -returns true. +New option: Add tests_dep option to Dpkg::Deps::deps_parse(). -=cut +=head2 Version 1.05 (dpkg 1.17.14) -sub reset { - my $self = shift; - $self->{list} = []; -} +New function: Dpkg::Deps::deps_iterate(). -=item $dep->add(@deps) +=head2 Version 1.04 (dpkg 1.17.10) -Adds new dependency objects at the end of the list. +New options: Add use_profiles, build_profiles, reduce_profiles and +reduce_restrictions to Dpkg::Deps::deps_parse(). -=cut +=head2 Version 1.03 (dpkg 1.17.0) -sub add { - my $self = shift; - push @{$self->{list}}, @_; -} +New option: Add build_arch option to Dpkg::Deps::deps_parse(). -=item $dep->get_deps() +=head2 Version 1.02 (dpkg 1.17.0) -Returns a list of sub-dependencies. - -=cut - -sub get_deps { - my $self = shift; - return grep { not $_->is_empty() } @{$self->{list}}; -} - -=item $dep->sort() - -Sorts alphabetically the internal list of dependencies. - -=cut - -sub sort { - my $self = shift; - my @res = (); - @res = sort { Dpkg::Deps::deps_compare($a, $b) } @{$self->{list}}; - $self->{list} = [ @res ]; -} - -=item $dep->arch_is_concerned($arch) - -Returns true if at least one of the sub-dependencies apply to this -architecture. - -=cut - -sub arch_is_concerned { - my ($self, $host_arch) = @_; - my $res = 0; - foreach my $dep (@{$self->{list}}) { - $res = 1 if $dep->arch_is_concerned($host_arch); - } - return $res; -} - -=item $dep->reduce_arch($arch) - -Simplifies the dependencies to contain only information relevant to the -given architecture. The non-relevant sub-dependencies are simply removed. - -This trims off the architecture restriction list of Dpkg::Deps::Simple -objects. - -=cut - -sub reduce_arch { - my ($self, $host_arch) = @_; - my @new; - foreach my $dep (@{$self->{list}}) { - $dep->reduce_arch($host_arch); - push @new, $dep if $dep->arch_is_concerned($host_arch); - } - $self->{list} = [ @new ]; -} - -=item $dep->has_arch_restriction() - -Returns the list of package names that have such a restriction. - -=cut - -sub has_arch_restriction { - my $self = shift; - my @res; - foreach my $dep (@{$self->{list}}) { - push @res, $dep->has_arch_restriction(); - } - return @res; -} - -=item $dep->profile_is_concerned() - -Returns true if at least one of the sub-dependencies apply to this profile. - -=cut - -sub profile_is_concerned { - my ($self, $build_profiles) = @_; - my $res = 0; - - foreach my $dep (@{$self->{list}}) { - $res = 1 if $dep->profile_is_concerned($build_profiles); - } - return $res; -} - -=item $dep->reduce_profiles() - -Simplifies the dependencies to contain only information relevant to the -given profile. The non-relevant sub-dependencies are simply removed. - -This trims off the profile restriction list of Dpkg::Deps::Simple objects. - -=cut - -sub reduce_profiles { - my ($self, $build_profiles) = @_; - my @new; - - foreach my $dep (@{$self->{list}}) { - $dep->reduce_profiles($build_profiles); - push @new, $dep if $dep->profile_is_concerned($build_profiles); - } - $self->{list} = [ @new ]; -} - -=item $dep->is_empty() - -Returns true if the dependency is empty and doesn't contain any useful -information. This is true when a (descendant of) Dpkg::Deps::Multiple -contains an empty list of dependencies. - -=cut - -sub is_empty { - my $self = shift; - return scalar @{$self->{list}} == 0; -} - -=item $dep->merge_union($other_dep) - -This method is not meaningful for this object, and will always croak. - -=cut - -sub merge_union { - croak 'method merge_union() is only valid for Dpkg::Deps::Simple'; -} - -=back - -=cut - -package Dpkg::Deps::AND; - -=head2 OBJECT - Dpkg::Deps::AND - -This object represents a list of dependencies that must be met at the same -time. It inherits from Dpkg::Deps::Multiple. - -=head2 METHODS - Dpkg::Deps::AND - -=over 4 - -=cut - -use strict; -use warnings; - -use parent -norequire, qw(Dpkg::Deps::Multiple); - -=item $dep->output([$fh]) - -The output method uses ", " to join the list of sub-dependencies. - -=cut - -sub output { - my ($self, $fh) = @_; - my $res = join(', ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps()); - if (defined($fh)) { - print { $fh } $res; - } - return $res; -} - -=item $dep->implies($other_dep) - -Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies -NOT($other_dep). Returns undef when there's no implication. $dep and -$other_dep do not need to be of the same type. - -=cut - -sub implies { - my ($self, $o) = @_; - # If any individual member can imply $o or NOT $o, we're fine - foreach my $dep ($self->get_deps()) { - my $implication = $dep->implies($o); - return 1 if defined($implication) && $implication == 1; - return 0 if defined($implication) && $implication == 0; - } - # If o is an AND, we might have an implication, if we find an - # implication within us for each predicate in o - if ($o->isa('Dpkg::Deps::AND')) { - my $subset = 1; - foreach my $odep ($o->get_deps()) { - my $found = 0; - foreach my $dep ($self->get_deps()) { - $found = 1 if $dep->implies($odep); - } - $subset = 0 if not $found; - } - return 1 if $subset; - } - return; -} - -=item $dep->get_evaluation($facts) - -Evaluates the dependency given a list of installed packages and a list of -virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts -object given as parameters. - -Returns 1 when it's true, 0 when it's false, undef when some information -is lacking to conclude. - -=cut - -sub get_evaluation { - my ($self, $facts) = @_; - # Return 1 only if all members evaluates to true - # Return 0 if at least one member evaluates to false - # Return undef otherwise - my $result = 1; - foreach my $dep ($self->get_deps()) { - my $eval = $dep->get_evaluation($facts); - if (not defined $eval) { - $result = undef; - } elsif ($eval == 0) { - $result = 0; - last; - } elsif ($eval == 1) { - # Still possible - } - } - return $result; -} - -=item $dep->simplify_deps($facts, @assumed_deps) - -Simplifies the dependency as much as possible given the list of facts (see -object Dpkg::Deps::KnownFacts) and a list of other dependencies that are -known to be true. - -=cut - -sub simplify_deps { - my ($self, $facts, @knowndeps) = @_; - my @new; - -WHILELOOP: - while (@{$self->{list}}) { - my $dep = shift @{$self->{list}}; - my $eval = $dep->get_evaluation($facts); - next if defined($eval) and $eval == 1; - foreach my $odep (@knowndeps, @new) { - next WHILELOOP if $odep->implies($dep); - } - # When a dependency is implied by another dependency that - # follows, then invert them - # "a | b, c, a" becomes "a, c" and not "c, a" - my $i = 0; - foreach my $odep (@{$self->{list}}) { - if (defined $odep and $odep->implies($dep)) { - splice @{$self->{list}}, $i, 1; - unshift @{$self->{list}}, $odep; - next WHILELOOP; - } - $i++; - } - push @new, $dep; - } - $self->{list} = [ @new ]; -} - -=back - -=cut - -package Dpkg::Deps::OR; - -=head2 OBJECT - Dpkg::Deps::OR - -This object represents a list of dependencies of which only one must be met -for the dependency to be true. It inherits from Dpkg::Deps::Multiple. - -=head2 METHODS - Dpkg::Deps::OR - -=over 4 - -=cut - -use strict; -use warnings; - -use parent -norequire, qw(Dpkg::Deps::Multiple); - -=item $dep->output([$fh]) - -The output method uses " | " to join the list of sub-dependencies. - -=cut - -sub output { - my ($self, $fh) = @_; - my $res = join(' | ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps()); - if (defined($fh)) { - print { $fh } $res; - } - return $res; -} - -=item $dep->implies($other_dep) - -Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies -NOT($other_dep). Returns undef when there's no implication. $dep and -$other_dep do not need to be of the same type. - -=cut - -sub implies { - my ($self, $o) = @_; - - # Special case for AND with a single member, replace it by its member - if ($o->isa('Dpkg::Deps::AND')) { - my @subdeps = $o->get_deps(); - if (scalar(@subdeps) == 1) { - $o = $subdeps[0]; - } - } - - # In general, an OR dependency can't imply anything except if each - # of its member implies a member in the other OR dependency - if ($o->isa('Dpkg::Deps::OR')) { - my $subset = 1; - foreach my $dep ($self->get_deps()) { - my $found = 0; - foreach my $odep ($o->get_deps()) { - $found = 1 if $dep->implies($odep); - } - $subset = 0 if not $found; - } - return 1 if $subset; - } - return; -} - -=item $dep->get_evaluation($facts) - -Evaluates the dependency given a list of installed packages and a list of -virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts -object given as parameters. - -Returns 1 when it's true, 0 when it's false, undef when some information -is lacking to conclude. - -=cut - -sub get_evaluation { - my ($self, $facts) = @_; - # Returns false if all members evaluates to 0 - # Returns true if at least one member evaluates to true - # Returns undef otherwise - my $result = 0; - foreach my $dep ($self->get_deps()) { - my $eval = $dep->get_evaluation($facts); - if (not defined $eval) { - $result = undef; - } elsif ($eval == 1) { - $result = 1; - last; - } elsif ($eval == 0) { - # Still possible to have a false evaluation - } - } - return $result; -} - -=item $dep->simplify_deps($facts, @assumed_deps) - -Simplifies the dependency as much as possible given the list of facts (see -object Dpkg::Deps::KnownFacts) and a list of other dependencies that are -known to be true. - -=cut - -sub simplify_deps { - my ($self, $facts) = @_; - my @new; - -WHILELOOP: - while (@{$self->{list}}) { - my $dep = shift @{$self->{list}}; - my $eval = $dep->get_evaluation($facts); - if (defined($eval) and $eval == 1) { - $self->{list} = []; - return; - } - foreach my $odep (@new, @{$self->{list}}) { - next WHILELOOP if $odep->implies($dep); - } - push @new, $dep; - } - $self->{list} = [ @new ]; -} - -=back - -=cut - -package Dpkg::Deps::Union; - -=head2 OBJECT - Dpkg::Deps::Union - -This object represents a list of relationships. It inherits from -Dpkg::Deps::Multiple. - -=head2 METHODS - Dpkg::Deps::Union - -=over 4 - -=cut - -use strict; -use warnings; - -use parent -norequire, qw(Dpkg::Deps::Multiple); - -=item $dep->output([$fh]) - -The output method uses ", " to join the list of relationships. - -=cut - -sub output { - my ($self, $fh) = @_; - my $res = join(', ', map { $_->output() } grep { not $_->is_empty() } $self->get_deps()); - if (defined($fh)) { - print { $fh } $res; - } - return $res; -} - -=item $dep->implies($other_dep) - -=item $dep->get_evaluation($other_dep) - -These methods are not meaningful for this object and always return undef. - -=cut - -sub implies { - # Implication test is not useful on Union. - return; -} - -sub get_evaluation { - # Evaluation is not useful on Union. - return; -} - -=item $dep->simplify_deps($facts) - -The simplification is done to generate an union of all the relationships. -It uses $simple_dep->merge_union($other_dep) to get its job done. - -=cut - -sub simplify_deps { - my ($self, $facts) = @_; - my @new; - -WHILELOOP: - while (@{$self->{list}}) { - my $odep = shift @{$self->{list}}; - foreach my $dep (@new) { - next WHILELOOP if $dep->merge_union($odep); - } - push @new, $odep; - } - $self->{list} = [ @new ]; -} - -=back - -=cut - -package Dpkg::Deps::KnownFacts; - -=head2 OBJECT - Dpkg::Deps::KnownFacts - -This object represents a list of installed packages and a list of virtual -packages provided (by the set of installed packages). - -=head2 METHODS - Dpkg::Deps::KnownFacts - -=over 4 - -=cut - -use strict; -use warnings; - -use Dpkg::Version; - -=item $facts = Dpkg::Deps::KnownFacts->new(); - -Creates a new object. - -=cut - -sub new { - my $this = shift; - my $class = ref($this) || $this; - my $self = { - pkg => {}, - virtualpkg => {}, - }; - bless $self, $class; - return $self; -} - -=item $facts->add_installed_package($package, $version, $arch, $multiarch) - -Records that the given version of the package is installed. If -$version/$arch is undefined we know that the package is installed but we -don't know which version/architecture it is. $multiarch is the Multi-Arch -field of the package. If $multiarch is undef, it will be equivalent to -"Multi-Arch: no". - -Note that $multiarch is only used if $arch is provided. - -=cut - -sub add_installed_package { - my ($self, $pkg, $ver, $arch, $multiarch) = @_; - my $p = { - package => $pkg, - version => $ver, - architecture => $arch, - multiarch => $multiarch // 'no', - }; - $self->{pkg}{"$pkg:$arch"} = $p if defined $arch; - push @{$self->{pkg}{$pkg}}, $p; -} - -=item $facts->add_provided_package($virtual, $relation, $version, $by) - -Records that the "$by" package provides the $virtual package. $relation -and $version correspond to the associated relation given in the Provides -field (if present). - -=cut - -sub add_provided_package { - my ($self, $pkg, $rel, $ver, $by) = @_; - my $v = { - package => $pkg, - relation => $rel, - version => $ver, - provider => $by, - }; - - $self->{virtualpkg}{$pkg} //= []; - push @{$self->{virtualpkg}{$pkg}}, $v; -} - -=item ($check, $param) = $facts->check_package($package) - -$check is one when the package is found. For a real package, $param -contains the version. For a virtual package, $param contains an array -reference containing the list of packages that provide it (each package is -listed as [ $provider, $relation, $version ]). - -This function is obsolete and should not be used. Dpkg::Deps::KnownFacts -is only meant to be filled with data and then passed to Dpkg::Deps -methods where appropriate, but it should not be directly queried. - -=cut - -sub check_package { - my ($self, $pkg) = @_; - - warnings::warnif('deprecated', 'obsolete function, pass ' . - 'Dpkg::Deps::KnownFacts to Dpkg::Deps methods instead'); - - if (exists $self->{pkg}{$pkg}) { - return (1, $self->{pkg}{$pkg}[0]{version}); - } - if (exists $self->{virtualpkg}{$pkg}) { - my $arrayref = [ map { [ - $_->{provider}, $_->{relation}, $_->{version} - ] } @{$self->{virtualpkg}{$pkg}} ]; - return (1, $arrayref); - } - return (0, undef); -} - -## -## The functions below are private to Dpkg::Deps::KnownFacts. -## - -sub _find_package { - my ($self, $dep, $lackinfos) = @_; - my ($pkg, $archqual) = ($dep->{package}, $dep->{archqual}); - return if not exists $self->{pkg}{$pkg}; - my $host_arch = $dep->{host_arch} // Dpkg::Arch::get_host_arch(); - my $build_arch = $dep->{build_arch} // Dpkg::Arch::get_build_arch(); - foreach my $p (@{$self->{pkg}{$pkg}}) { - my $a = $p->{architecture}; - my $ma = $p->{multiarch}; - if (not defined $a) { - $$lackinfos = 1; - next; - } - if (not defined $archqual) { - return $p if $ma eq 'foreign'; - return $p if $a eq $host_arch or $a eq 'all'; - } elsif ($archqual eq 'any') { - return $p if $ma eq 'allowed'; - } elsif ($archqual eq 'native') { - return $p if $a eq $build_arch and $ma ne 'foreign'; - } else { - return $p if $a eq $archqual; - } - } - return; -} - -sub _find_virtual_packages { - my ($self, $pkg) = @_; - return () if not exists $self->{virtualpkg}{$pkg}; - return @{$self->{virtualpkg}{$pkg}}; -} - -=item $facts->evaluate_simple_dep() - -This method is private and should not be used except from within Dpkg::Deps. - -=cut - -sub evaluate_simple_dep { - my ($self, $dep) = @_; - my ($lackinfos, $pkg) = (0, $dep->{package}); - my $p = $self->_find_package($dep, \$lackinfos); - if ($p) { - if (defined $dep->{relation}) { - if (defined $p->{version}) { - return 1 if version_compare_relation($p->{version}, - $dep->{relation}, $dep->{version}); - } else { - $lackinfos = 1; - } - } else { - return 1; - } - } - foreach my $virtpkg ($self->_find_virtual_packages($pkg)) { - next if defined $virtpkg->{relation} and $virtpkg->{relation} ne REL_EQ; - - if (defined $dep->{relation}) { - next if not defined $virtpkg->{version}; - return 1 if version_compare_relation($virtpkg->{version}, - $dep->{relation}, - $dep->{version}); - } else { - return 1; - } - } - return if $lackinfos; - return 0; -} - -=back - -=head1 CHANGES - -=head2 Version 1.06 (dpkg 1.18.7; module version bumped on dpkg 1.18.24) - -New option: Add tests_dep option to Dpkg::Deps::deps_parse(). - -=head2 Version 1.05 (dpkg 1.17.14) - -New function: Dpkg::Deps::deps_iterate(). - -=head2 Version 1.04 (dpkg 1.17.10) - -New options: Add use_profiles, build_profiles, reduce_profiles and -reduce_restrictions to Dpkg::Deps::deps_parse(). - -New methods: Add $dep->profile_is_concerned() and $dep->reduce_profiles() -for all dependency objects. - -=head2 Version 1.03 (dpkg 1.17.0) - -New option: Add build_arch option to Dpkg::Deps::deps_parse(). - -=head2 Version 1.02 (dpkg 1.17.0) - -New function: Dpkg::Deps::deps_concat() +New function: Dpkg::Deps::deps_concat() =head2 Version 1.01 (dpkg 1.16.1) -New method: Add $dep->reset() for all dependency objects. - -New property: Dpkg::Deps::Simple now recognizes the arch qualifier "any" -and stores it in the "archqual" property when present. - -New option: Dpkg::Deps::KnownFacts->add_installed_package() now accepts 2 -supplementary parameters ($arch and $multiarch). - -Deprecated method: Dpkg::Deps::KnownFacts->check_package() is obsolete, -it should not have been part of the public API. + =head2 Version 1.00 (dpkg 1.15.6) diff --git a/scripts/Dpkg/Deps/AND.pm b/scripts/Dpkg/Deps/AND.pm new file mode 100644 index 000000000..e16a2cf35 --- /dev/null +++ b/scripts/Dpkg/Deps/AND.pm @@ -0,0 +1,182 @@ +# Copyright © 1998 Richard Braakman +# Copyright © 1999 Darren Benham +# Copyright © 2000 Sean 'Shaleh' Perry +# Copyright © 2004 Frank Lichtenheld +# Copyright © 2006 Russ Allbery +# Copyright © 2007-2009 Raphaël Hertzog +# Copyright © 2008-2009, 2012-2014 Guillem Jover +# +# This program is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Dpkg::Deps::AND; + +=encoding utf8 + +=head1 NAME + +Dpkg::Deps::AND - list of AND dependencies + +=head1 DESCRIPTION + +This object represents a list of dependencies that must be met at the same +time. It inherits from Dpkg::Deps::Multiple. + +=cut + +use strict; +use warnings; + +our $VERSION = '1.00'; + +use parent qw(Dpkg::Deps::Multiple); + +=head1 METHODS + +=over 4 + +=item $dep->output([$fh]) + +The output method uses ", " to join the list of sub-dependencies. + +=cut + +sub output { + my ($self, $fh) = @_; + + my $res = join(', ', map { + $_->output() + } grep { + not $_->is_empty() + } $self->get_deps()); + + if (defined $fh) { + print { $fh } $res; + } + return $res; +} + +=item $dep->implies($other_dep) + +Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies +NOT($other_dep). Returns undef when there's no implication. $dep and +$other_dep do not need to be of the same type. + +=cut + +sub implies { + my ($self, $o) = @_; + + # If any individual member can imply $o or NOT $o, we're fine + foreach my $dep ($self->get_deps()) { + my $implication = $dep->implies($o); + return 1 if defined $implication and $implication == 1; + return 0 if defined $implication and $implication == 0; + } + + # If o is an AND, we might have an implication, if we find an + # implication within us for each predicate in o + if ($o->isa('Dpkg::Deps::AND')) { + my $subset = 1; + foreach my $odep ($o->get_deps()) { + my $found = 0; + foreach my $dep ($self->get_deps()) { + $found = 1 if $dep->implies($odep); + } + $subset = 0 if not $found; + } + return 1 if $subset; + } + return; +} + +=item $dep->get_evaluation($facts) + +Evaluates the dependency given a list of installed packages and a list of +virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts +object given as parameters. + +Returns 1 when it's true, 0 when it's false, undef when some information +is lacking to conclude. + +=cut + +sub get_evaluation { + my ($self, $facts) = @_; + + # Return 1 only if all members evaluates to true + # Return 0 if at least one member evaluates to false + # Return undef otherwise + my $result = 1; + foreach my $dep ($self->get_deps()) { + my $eval = $dep->get_evaluation($facts); + if (not defined $eval) { + $result = undef; + } elsif ($eval == 0) { + $result = 0; + last; + } elsif ($eval == 1) { + # Still possible + } + } + return $result; +} + +=item $dep->simplify_deps($facts, @assumed_deps) + +Simplifies the dependency as much as possible given the list of facts (see +object Dpkg::Deps::KnownFacts) and a list of other dependencies that are +known to be true. + +=cut + +sub simplify_deps { + my ($self, $facts, @knowndeps) = @_; + my @new; + +WHILELOOP: + while (@{$self->{list}}) { + my $dep = shift @{$self->{list}}; + my $eval = $dep->get_evaluation($facts); + next if defined $eval and $eval == 1; + foreach my $odep (@knowndeps, @new) { + next WHILELOOP if $odep->implies($dep); + } + # When a dependency is implied by another dependency that + # follows, then invert them + # "a | b, c, a" becomes "a, c" and not "c, a" + my $i = 0; + foreach my $odep (@{$self->{list}}) { + if (defined $odep and $odep->implies($dep)) { + splice @{$self->{list}}, $i, 1; + unshift @{$self->{list}}, $odep; + next WHILELOOP; + } + $i++; + } + push @new, $dep; + } + $self->{list} = [ @new ]; +} + +=back + +=head1 CHANGES + +=head2 Version 1.00 (dpkg 1.15.6) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Dpkg/Deps/KnownFacts.pm b/scripts/Dpkg/Deps/KnownFacts.pm new file mode 100644 index 000000000..95770ec00 --- /dev/null +++ b/scripts/Dpkg/Deps/KnownFacts.pm @@ -0,0 +1,244 @@ +# Copyright © 1998 Richard Braakman +# Copyright © 1999 Darren Benham +# Copyright © 2000 Sean 'Shaleh' Perry +# Copyright © 2004 Frank Lichtenheld +# Copyright © 2006 Russ Allbery +# Copyright © 2007-2009 Raphaël Hertzog +# Copyright © 2008-2009, 2012-2014 Guillem Jover +# +# This program is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Dpkg::Deps::KnownFacts; + +=encoding utf8 + +=head1 NAME + +Dpkg::Deps::KnownFacts - list of installed real and virtual packages + +=head1 DESCRIPTION + +This object represents a list of installed packages and a list of virtual +packages provided (by the set of installed packages). + +=cut + +use strict; +use warnings; + +our $VERSION = '1.01'; + +use Dpkg::Version; + +=head1 METHODS + +=over 4 + +=item $facts = Dpkg::Deps::KnownFacts->new(); + +Creates a new object. + +=cut + +sub new { + my $this = shift; + my $class = ref($this) || $this; + my $self = { + pkg => {}, + virtualpkg => {}, + }; + + bless $self, $class; + return $self; +} + +=item $facts->add_installed_package($package, $version, $arch, $multiarch) + +Records that the given version of the package is installed. If +$version/$arch is undefined we know that the package is installed but we +don't know which version/architecture it is. $multiarch is the Multi-Arch +field of the package. If $multiarch is undef, it will be equivalent to +"Multi-Arch: no". + +Note that $multiarch is only used if $arch is provided. + +=cut + +sub add_installed_package { + my ($self, $pkg, $ver, $arch, $multiarch) = @_; + my $p = { + package => $pkg, + version => $ver, + architecture => $arch, + multiarch => $multiarch // 'no', + }; + + $self->{pkg}{"$pkg:$arch"} = $p if defined $arch; + push @{$self->{pkg}{$pkg}}, $p; +} + +=item $facts->add_provided_package($virtual, $relation, $version, $by) + +Records that the "$by" package provides the $virtual package. $relation +and $version correspond to the associated relation given in the Provides +field (if present). + +=cut + +sub add_provided_package { + my ($self, $pkg, $rel, $ver, $by) = @_; + my $v = { + package => $pkg, + relation => $rel, + version => $ver, + provider => $by, + }; + + $self->{virtualpkg}{$pkg} //= []; + push @{$self->{virtualpkg}{$pkg}}, $v; +} + +=item ($check, $param) = $facts->check_package($package) + +$check is one when the package is found. For a real package, $param +contains the version. For a virtual package, $param contains an array +reference containing the list of packages that provide it (each package is +listed as [ $provider, $relation, $version ]). + +This function is obsolete and should not be used. Dpkg::Deps::KnownFacts +is only meant to be filled with data and then passed to Dpkg::Deps +methods where appropriate, but it should not be directly queried. + +=cut + +sub check_package { + my ($self, $pkg) = @_; + + warnings::warnif('deprecated', 'obsolete function, pass ' . + 'Dpkg::Deps::KnownFacts to Dpkg::Deps methods instead'); + + if (exists $self->{pkg}{$pkg}) { + return (1, $self->{pkg}{$pkg}[0]{version}); + } + if (exists $self->{virtualpkg}{$pkg}) { + my $arrayref = [ map { [ + $_->{provider}, $_->{relation}, $_->{version} + ] } @{$self->{virtualpkg}{$pkg}} ]; + return (1, $arrayref); + } + return (0, undef); +} + +## +## The functions below are private to Dpkg::Deps::KnownFacts. +## + +sub _find_package { + my ($self, $dep, $lackinfos) = @_; + my ($pkg, $archqual) = ($dep->{package}, $dep->{archqual}); + + return if not exists $self->{pkg}{$pkg}; + + my $host_arch = $dep->{host_arch} // Dpkg::Arch::get_host_arch(); + my $build_arch = $dep->{build_arch} // Dpkg::Arch::get_build_arch(); + + foreach my $p (@{$self->{pkg}{$pkg}}) { + my $a = $p->{architecture}; + my $ma = $p->{multiarch}; + + if (not defined $a) { + $$lackinfos = 1; + next; + } + if (not defined $archqual) { + return $p if $ma eq 'foreign'; + return $p if $a eq $host_arch or $a eq 'all'; + } elsif ($archqual eq 'any') { + return $p if $ma eq 'allowed'; + } elsif ($archqual eq 'native') { + return $p if $a eq $build_arch and $ma ne 'foreign'; + } else { + return $p if $a eq $archqual; + } + } + return; +} + +sub _find_virtual_packages { + my ($self, $pkg) = @_; + + return () if not exists $self->{virtualpkg}{$pkg}; + return @{$self->{virtualpkg}{$pkg}}; +} + +=item $facts->evaluate_simple_dep() + +This method is private and should not be used except from within Dpkg::Deps. + +=cut + +sub evaluate_simple_dep { + my ($self, $dep) = @_; + my ($lackinfos, $pkg) = (0, $dep->{package}); + + my $p = $self->_find_package($dep, \$lackinfos); + if ($p) { + if (defined $dep->{relation}) { + if (defined $p->{version}) { + return 1 if version_compare_relation($p->{version}, + $dep->{relation}, + $dep->{version}); + } else { + $lackinfos = 1; + } + } else { + return 1; + } + } + foreach my $virtpkg ($self->_find_virtual_packages($pkg)) { + next if defined $virtpkg->{relation} and + $virtpkg->{relation} ne REL_EQ; + + if (defined $dep->{relation}) { + next if not defined $virtpkg->{version}; + return 1 if version_compare_relation($virtpkg->{version}, + $dep->{relation}, + $dep->{version}); + } else { + return 1; + } + } + return if $lackinfos; + return 0; +} + +=back + +=head1 CHANGES + +=head2 Version 1.01 (dpkg 1.16.1) + +New option: Dpkg::Deps::KnownFacts->add_installed_package() now accepts 2 +supplementary parameters ($arch and $multiarch). + +Deprecated method: Dpkg::Deps::KnownFacts->check_package() is obsolete, +it should not have been part of the public API. + +=head2 Version 1.00 (dpkg 1.15.6) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Dpkg/Deps/Multiple.pm b/scripts/Dpkg/Deps/Multiple.pm new file mode 100644 index 000000000..da12f5184 --- /dev/null +++ b/scripts/Dpkg/Deps/Multiple.pm @@ -0,0 +1,250 @@ +# Copyright © 1998 Richard Braakman +# Copyright © 1999 Darren Benham +# Copyright © 2000 Sean 'Shaleh' Perry +# Copyright © 2004 Frank Lichtenheld +# Copyright © 2006 Russ Allbery +# Copyright © 2007-2009 Raphaël Hertzog +# Copyright © 2008-2009, 2012-2014 Guillem Jover +# +# This program is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Dpkg::Deps::Multiple; + +=encoding utf8 + +=head1 NAME + +Dpkg::Deps::Multiple - base module to represent multiple dependencies + +=head1 DESCRIPTION + +The Dpkg::Deps::Multiple module provides objects implementing various types +of dependencies. It is the base class for Dpkg::Deps::{AND,OR,Union}. + +=cut + +use strict; +use warnings; + +our $VERSION = '1.02'; + +use Carp; + +use Dpkg::ErrorHandling; + +use parent qw(Dpkg::Interface::Storable); + +=head1 METHODS + +=over 4 + +=item $dep = Dpkg::Deps::Multiple->new(%opts); + +Creates a new object. + +=cut + +sub new { + my $this = shift; + my $class = ref($this) || $this; + my $self = { list => [ @_ ] }; + + bless $self, $class; + return $self; +} + +=item $dep->reset() + +Clears any dependency information stored in $dep so that $dep->is_empty() +returns true. + +=cut + +sub reset { + my $self = shift; + + $self->{list} = []; +} + +=item $dep->add(@deps) + +Adds new dependency objects at the end of the list. + +=cut + +sub add { + my $self = shift; + + push @{$self->{list}}, @_; +} + +=item $dep->get_deps() + +Returns a list of sub-dependencies. + +=cut + +sub get_deps { + my $self = shift; + + return grep { not $_->is_empty() } @{$self->{list}}; +} + +=item $dep->sort() + +Sorts alphabetically the internal list of dependencies. + +=cut + +sub sort { + my $self = shift; + + my @res = (); + @res = sort { Dpkg::Deps::deps_compare($a, $b) } @{$self->{list}}; + $self->{list} = [ @res ]; +} + +=item $dep->arch_is_concerned($arch) + +Returns true if at least one of the sub-dependencies apply to this +architecture. + +=cut + +sub arch_is_concerned { + my ($self, $host_arch) = @_; + + my $res = 0; + foreach my $dep (@{$self->{list}}) { + $res = 1 if $dep->arch_is_concerned($host_arch); + } + return $res; +} + +=item $dep->reduce_arch($arch) + +Simplifies the dependencies to contain only information relevant to the +given architecture. The non-relevant sub-dependencies are simply removed. + +This trims off the architecture restriction list of Dpkg::Deps::Simple +objects. + +=cut + +sub reduce_arch { + my ($self, $host_arch) = @_; + + my @new; + foreach my $dep (@{$self->{list}}) { + $dep->reduce_arch($host_arch); + push @new, $dep if $dep->arch_is_concerned($host_arch); + } + $self->{list} = [ @new ]; +} + +=item $dep->has_arch_restriction() + +Returns the list of package names that have such a restriction. + +=cut + +sub has_arch_restriction { + my $self = shift; + + my @res; + foreach my $dep (@{$self->{list}}) { + push @res, $dep->has_arch_restriction(); + } + return @res; +} + +=item $dep->profile_is_concerned() + +Returns true if at least one of the sub-dependencies apply to this profile. + +=cut + +sub profile_is_concerned { + my ($self, $build_profiles) = @_; + + my $res = 0; + foreach my $dep (@{$self->{list}}) { + $res = 1 if $dep->profile_is_concerned($build_profiles); + } + return $res; +} + +=item $dep->reduce_profiles() + +Simplifies the dependencies to contain only information relevant to the +given profile. The non-relevant sub-dependencies are simply removed. + +This trims off the profile restriction list of Dpkg::Deps::Simple objects. + +=cut + +sub reduce_profiles { + my ($self, $build_profiles) = @_; + + my @new; + foreach my $dep (@{$self->{list}}) { + $dep->reduce_profiles($build_profiles); + push @new, $dep if $dep->profile_is_concerned($build_profiles); + } + $self->{list} = [ @new ]; +} + +=item $dep->is_empty() + +Returns true if the dependency is empty and doesn't contain any useful +information. This is true when a (descendant of) Dpkg::Deps::Multiple +contains an empty list of dependencies. + +=cut + +sub is_empty { + my $self = shift; + + return scalar @{$self->{list}} == 0; +} + +=item $dep->merge_union($other_dep) + +This method is not meaningful for this object, and will always croak. + +=cut + +sub merge_union { + croak 'method merge_union() is only valid for Dpkg::Deps::Simple'; +} + +=back + +=head1 CHANGES + +=head2 Version 1.02 (dpkg 1.17.10) + +New methods: Add $dep->profile_is_concerned() and $dep->reduce_profiles(). + +=head2 Version 1.01 (dpkg 1.16.1) + +New method: Add $dep->reset(). + +=head2 Version 1.00 (dpkg 1.15.6) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Dpkg/Deps/OR.pm b/scripts/Dpkg/Deps/OR.pm new file mode 100644 index 000000000..b2f8d03ed --- /dev/null +++ b/scripts/Dpkg/Deps/OR.pm @@ -0,0 +1,174 @@ +# Copyright © 1998 Richard Braakman +# Copyright © 1999 Darren Benham +# Copyright © 2000 Sean 'Shaleh' Perry +# Copyright © 2004 Frank Lichtenheld +# Copyright © 2006 Russ Allbery +# Copyright © 2007-2009 Raphaël Hertzog +# Copyright © 2008-2009, 2012-2014 Guillem Jover +# +# This program is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Dpkg::Deps::OR; + +=encoding utf8 + +=head1 NAME + +Dpkg::Deps::OR - list of OR dependencies + +=head1 DESCRIPTION + +This object represents a list of dependencies of which only one must be met +for the dependency to be true. It inherits from Dpkg::Deps::Multiple. + +=cut + +use strict; +use warnings; + +our $VERSION = '1.00'; + +use parent qw(Dpkg::Deps::Multiple); + +=head1 METHODS + +=over 4 + +=item $dep->output([$fh]) + +The output method uses " | " to join the list of sub-dependencies. + +=cut + +sub output { + my ($self, $fh) = @_; + + my $res = join(' | ', map { + $_->output() + } grep { + not $_->is_empty() + } $self->get_deps()); + + if (defined $fh) { + print { $fh } $res; + } + return $res; +} + +=item $dep->implies($other_dep) + +Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies +NOT($other_dep). Returns undef when there's no implication. $dep and +$other_dep do not need to be of the same type. + +=cut + +sub implies { + my ($self, $o) = @_; + + # Special case for AND with a single member, replace it by its member + if ($o->isa('Dpkg::Deps::AND')) { + my @subdeps = $o->get_deps(); + if (scalar(@subdeps) == 1) { + $o = $subdeps[0]; + } + } + + # In general, an OR dependency can't imply anything except if each + # of its member implies a member in the other OR dependency + if ($o->isa('Dpkg::Deps::OR')) { + my $subset = 1; + foreach my $dep ($self->get_deps()) { + my $found = 0; + foreach my $odep ($o->get_deps()) { + $found = 1 if $dep->implies($odep); + } + $subset = 0 if not $found; + } + return 1 if $subset; + } + return; +} + +=item $dep->get_evaluation($facts) + +Evaluates the dependency given a list of installed packages and a list of +virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts +object given as parameters. + +Returns 1 when it's true, 0 when it's false, undef when some information +is lacking to conclude. + +=cut + +sub get_evaluation { + my ($self, $facts) = @_; + + # Returns false if all members evaluates to 0 + # Returns true if at least one member evaluates to true + # Returns undef otherwise + my $result = 0; + foreach my $dep ($self->get_deps()) { + my $eval = $dep->get_evaluation($facts); + if (not defined $eval) { + $result = undef; + } elsif ($eval == 1) { + $result = 1; + last; + } elsif ($eval == 0) { + # Still possible to have a false evaluation + } + } + return $result; +} + +=item $dep->simplify_deps($facts, @assumed_deps) + +Simplifies the dependency as much as possible given the list of facts (see +object Dpkg::Deps::KnownFacts) and a list of other dependencies that are +known to be true. + +=cut + +sub simplify_deps { + my ($self, $facts) = @_; + my @new; + +WHILELOOP: + while (@{$self->{list}}) { + my $dep = shift @{$self->{list}}; + my $eval = $dep->get_evaluation($facts); + if (defined $eval and $eval == 1) { + $self->{list} = []; + return; + } + foreach my $odep (@new, @{$self->{list}}) { + next WHILELOOP if $odep->implies($dep); + } + push @new, $dep; + } + $self->{list} = [ @new ]; +} + +=back + +=head1 CHANGES + +=head2 Version 1.00 (dpkg 1.15.6) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Dpkg/Deps/Simple.pm b/scripts/Dpkg/Deps/Simple.pm new file mode 100644 index 000000000..0557c7cfc --- /dev/null +++ b/scripts/Dpkg/Deps/Simple.pm @@ -0,0 +1,659 @@ +# Copyright © 1998 Richard Braakman +# Copyright © 1999 Darren Benham +# Copyright © 2000 Sean 'Shaleh' Perry +# Copyright © 2004 Frank Lichtenheld +# Copyright © 2006 Russ Allbery +# Copyright © 2007-2009 Raphaël Hertzog +# Copyright © 2008-2009, 2012-2014 Guillem Jover +# +# This program is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Dpkg::Deps::Simple; + +=encoding utf8 + +=head1 NAME + +Dpkg::Deps::Simple - represents a single dependency statement + +=head1 DESCRIPTION + +This object has several interesting properties: + +=over 4 + +=item package + +The package name (can be undef if the dependency has not been initialized +or if the simplification of the dependency lead to its removal). + +=item relation + +The relational operator: "=", "<<", "<=", ">=" or ">>". It can be +undefined if the dependency had no version restriction. In that case the +following field is also undefined. + +=item version + +The version. + +=item arches + +The list of architectures where this dependency is applicable. It is +undefined when there's no restriction, otherwise it is an +array ref. It can contain an exclusion list, in that case each +architecture is prefixed with an exclamation mark. + +=item archqual + +The arch qualifier of the dependency (can be undef if there is none). +In the dependency "python:any (>= 2.6)", the arch qualifier is "any". + +=item restrictions + +The restrictions formula for this dependency. It is undefined when there +is no restriction formula. Otherwise it is an array ref. + +=back + +=head1 METHODS + +=over 4 + +=cut + +use strict; +use warnings; + +our $VERSION = '1.02'; + +use Carp; + +use Dpkg::Arch qw(debarch_is_concerned debarch_list_parse); +use Dpkg::BuildProfiles qw(parse_build_profiles evaluate_restriction_formula); +use Dpkg::Version; +use Dpkg::ErrorHandling; +use Dpkg::Gettext; + +use parent qw(Dpkg::Interface::Storable); + +=item $dep = Dpkg::Deps::Simple->new(%opts); + +Creates a new object. Some options can be set through %opts: + +=over + +=item host_arch + +Sets the host architecture. + +=item build_arch + +Sets the build architecture. + +=item build_dep + +Specifies whether the parser should consider it a build dependency. +Defaults to 0. + +=item tests_dep + +Specifies whether the parser should consider it a tests dependency. +Defaults to 0. + +=back + +=cut + +sub new { + my ($this, $arg, %opts) = @_; + my $class = ref($this) || $this; + my $self = {}; + + bless $self, $class; + $self->reset(); + $self->{host_arch} = $opts{host_arch}; + $self->{build_arch} = $opts{build_arch}; + $self->{build_dep} = $opts{build_dep} // 0; + $self->{tests_dep} = $opts{tests_dep} // 0; + $self->parse_string($arg) if defined $arg; + return $self; +} + +=item $dep->reset() + +Clears any dependency information stored in $dep so that $dep->is_empty() +returns true. + +=cut + +sub reset { + my $self = shift; + + $self->{package} = undef; + $self->{relation} = undef; + $self->{version} = undef; + $self->{arches} = undef; + $self->{archqual} = undef; + $self->{restrictions} = undef; +} + +=item $dep->parse($fh, $desc) + +Parses a line from a filehandle. + +=cut + +sub parse { + my ($self, $fh, $desc) = @_; + + my $line = <$fh>; + chomp $line; + return $self->parse_string($line); +} + +=item $dep->parse_string($dep_string) + +Parses the dependency string and modifies internal properties to match the +parsed dependency. + +=cut + +sub parse_string { + my ($self, $dep) = @_; + + my $pkgname_re; + if ($self->{tests_dep}) { + $pkgname_re = qr/[\@a-zA-Z0-9][\@a-zA-Z0-9+.-]*/; + } else { + $pkgname_re = qr/[a-zA-Z0-9][a-zA-Z0-9+.-]*/; + } + + return if not $dep =~ + m{^\s* # skip leading whitespace + ($pkgname_re) # package name + (?: # start of optional part + : # colon for architecture + ([a-zA-Z0-9][a-zA-Z0-9-]*) # architecture name + )? # end of optional part + (?: # start of optional part + \s* \( # open parenthesis for version part + \s* (<<|<=|=|>=|>>|[<>]) # relation part + \s* ([^\)\s]+) # do not attempt to parse version + \s* \) # closing parenthesis + )? # end of optional part + (?: # start of optional architecture + \s* \[ # open bracket for architecture + \s* ([^\]]+) # don't parse architectures now + \s* \] # closing bracket + )? # end of optional architecture + ( + (?: # start of optional restriction + \s* < # open bracket for restriction + \s* [^>]+ # do not parse restrictions now + \s* > # closing bracket + )+ + )? # end of optional restriction + \s*$ # trailing spaces at end + }x; + if (defined $2) { + return if $2 eq 'native' and not $self->{build_dep}; + $self->{archqual} = $2; + } + $self->{package} = $1; + $self->{relation} = version_normalize_relation($3) if defined $3; + if (defined $4) { + $self->{version} = Dpkg::Version->new($4); + } + if (defined $5) { + $self->{arches} = [ debarch_list_parse($5) ]; + } + if (defined $6) { + $self->{restrictions} = [ parse_build_profiles($6) ]; + } +} + +=item $dep->output([$fh]) + +=item "$dep" + +Returns a string representing the dependency. If $fh is set, it prints +the string to the filehandle. + +=cut + +sub output { + my ($self, $fh) = @_; + + my $res = $self->{package}; + if (defined $self->{archqual}) { + $res .= ':' . $self->{archqual}; + } + if (defined $self->{relation}) { + $res .= ' (' . $self->{relation} . ' ' . $self->{version} . ')'; + } + if (defined $self->{arches}) { + $res .= ' [' . join(' ', @{$self->{arches}}) . ']'; + } + if (defined $self->{restrictions}) { + for my $restrlist (@{$self->{restrictions}}) { + $res .= ' <' . join(' ', @{$restrlist}) . '>'; + } + } + if (defined $fh) { + print { $fh } $res; + } + return $res; +} + +# _arch_is_superset(\@p, \@q) +# +# Returns true if the arch list @p is a superset of arch list @q. +# The arguments can also be undef in case there's no explicit architecture +# restriction. +sub _arch_is_superset { + my ($p, $q) = @_; + my $p_arch_neg = defined $p and $p->[0] =~ /^!/; + my $q_arch_neg = defined $q and $q->[0] =~ /^!/; + + # If "p" has no arches, it is a superset of q and we should fall through + # to the version check. + if (not defined $p) { + return 1; + } + # If q has no arches, it is a superset of p and there are no useful + # implications. + elsif (not defined $q) { + return 0; + } + # Both have arches. If neither are negated, we know nothing useful + # unless q is a subset of p. + elsif (not $p_arch_neg and not $q_arch_neg) { + my %p_arches = map { $_ => 1 } @{$p}; + my $subset = 1; + for my $arch (@{$q}) { + $subset = 0 unless $p_arches{$arch}; + } + return 0 unless $subset; + } + # If both are negated, we know nothing useful unless p is a subset of + # q (and therefore has fewer things excluded, and therefore is more + # general). + elsif ($p_arch_neg and $q_arch_neg) { + my %q_arches = map { $_ => 1 } @{$q}; + my $subset = 1; + for my $arch (@{$p}) { + $subset = 0 unless $q_arches{$arch}; + } + return 0 unless $subset; + } + # If q is negated and p isn't, we'd need to know the full list of + # arches to know if there's any relationship, so bail. + elsif (not $p_arch_neg and $q_arch_neg) { + return 0; + } + # If p is negated and q isn't, q is a subset of p if none of the + # negated arches in p are present in q. + elsif ($p_arch_neg and not $q_arch_neg) { + my %q_arches = map { $_ => 1 } @{$q}; + my $subset = 1; + for my $arch (@{$p}) { + $subset = 0 if $q_arches{substr($arch, 1)}; + } + return 0 unless $subset; + } + return 1; +} + +# _arch_qualifier_implies($p, $q) +# +# Returns true if the arch qualifier $p and $q are compatible with the +# implication $p -> $q, false otherwise. $p/$q can be undef/"any"/"native" +# or an architecture string. +# +# Because we are handling dependencies in isolation, and the full context +# of the implications are only known when doing dependency resolution at +# run-time, we can only assert that they are implied if they are equal. +# +# For example dependencies with different arch-qualifiers cannot be simplified +# as these depend on the state of Multi-Arch field in the package depended on. +sub _arch_qualifier_implies { + my ($p, $q) = @_; + + return $p eq $q if defined $p and defined $q; + return 1 if not defined $p and not defined $q; + return 0; +} + +# _restrictions_imply($p, $q) +# +# Returns true if the restrictions $p and $q are compatible with the +# implication $p -> $q, false otherwise. +# NOTE: We don't try to be very clever here, so we may conservatively +# return false when there is an implication. +sub _restrictions_imply { + my ($p, $q) = @_; + + if (not defined $p) { + return 1; + } elsif (not defined $q) { + return 0; + } else { + # Check whether set difference is empty. + my %restr; + + for my $restrlist (@{$q}) { + my $reststr = join ' ', sort @{$restrlist}; + $restr{$reststr} = 1; + } + for my $restrlist (@{$p}) { + my $reststr = join ' ', sort @{$restrlist}; + delete $restr{$reststr}; + } + + return keys %restr == 0; + } +} + +=item $dep->implies($other_dep) + +Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies +NOT($other_dep). Returns undef when there is no implication. $dep and +$other_dep do not need to be of the same type. + +=cut + +sub implies { + my ($self, $o) = @_; + + if ($o->isa('Dpkg::Deps::Simple')) { + # An implication is only possible on the same package + return if $self->{package} ne $o->{package}; + + # Our architecture set must be a superset of the architectures for + # o, otherwise we can't conclude anything. + return unless _arch_is_superset($self->{arches}, $o->{arches}); + + # The arch qualifier must not forbid an implication + return unless _arch_qualifier_implies($self->{archqual}, + $o->{archqual}); + + # Our restrictions must imply the restrictions for o + return unless _restrictions_imply($self->{restrictions}, + $o->{restrictions}); + + # If o has no version clause, then our dependency is stronger + return 1 if not defined $o->{relation}; + # If o has a version clause, we must also have one, otherwise there + # can't be an implication + return if not defined $self->{relation}; + + return Dpkg::Deps::deps_eval_implication($self->{relation}, + $self->{version}, $o->{relation}, $o->{version}); + } elsif ($o->isa('Dpkg::Deps::AND')) { + # TRUE: Need to imply all individual elements + # FALSE: Need to NOT imply at least one individual element + my $res = 1; + foreach my $dep ($o->get_deps()) { + my $implication = $self->implies($dep); + unless (defined $implication and $implication == 1) { + $res = $implication; + last if defined $res; + } + } + return $res; + } elsif ($o->isa('Dpkg::Deps::OR')) { + # TRUE: Need to imply at least one individual element + # FALSE: Need to not apply all individual elements + # UNDEF: The rest + my $res = undef; + foreach my $dep ($o->get_deps()) { + my $implication = $self->implies($dep); + if (defined $implication) { + if (not defined $res) { + $res = $implication; + } else { + if ($implication) { + $res = 1; + } else { + $res = 0; + } + } + last if defined $res and $res == 1; + } + } + return $res; + } else { + croak 'Dpkg::Deps::Simple cannot evaluate implication with a ' . + ref($o); + } +} + +=item $dep->get_deps() + +Returns a list of sub-dependencies, which for this object it means it +returns itself. + +=cut + +sub get_deps { + my $self = shift; + + return $self; +} + +=item $dep->sort() + +This method is a no-op for this object. + +=cut + +sub sort { + # Nothing to sort +} + +=item $dep->arch_is_concerned($arch) + +Returns true if the dependency applies to the indicated architecture. + +=cut + +sub arch_is_concerned { + my ($self, $host_arch) = @_; + + return 0 if not defined $self->{package}; # Empty dep + return 1 if not defined $self->{arches}; # Dep without arch spec + + return debarch_is_concerned($host_arch, @{$self->{arches}}); +} + +=item $dep->reduce_arch($arch) + +Simplifies the dependency to contain only information relevant to the given +architecture. This object can be left empty after this operation. This trims +off the architecture restriction list of these objects. + +=cut + +sub reduce_arch { + my ($self, $host_arch) = @_; + + if (not $self->arch_is_concerned($host_arch)) { + $self->reset(); + } else { + $self->{arches} = undef; + } +} + +=item $dep->has_arch_restriction() + +Returns the package name if the dependency applies only to a subset of +architectures. + +=cut + +sub has_arch_restriction { + my $self = shift; + + if (defined $self->{arches}) { + return $self->{package}; + } else { + return (); + } +} + +=item $dep->profile_is_concerned() + +Returns true if the dependency applies to the indicated profile. + +=cut + +sub profile_is_concerned { + my ($self, $build_profiles) = @_; + + return 0 if not defined $self->{package}; # Empty dep + return 1 if not defined $self->{restrictions}; # Dep without restrictions + return evaluate_restriction_formula($self->{restrictions}, $build_profiles); +} + +=item $dep->reduce_profiles() + +Simplifies the dependency to contain only information relevant to the given +profile. This object can be left empty after this operation. This trims off +the profile restriction list of this object. + +=cut + +sub reduce_profiles { + my ($self, $build_profiles) = @_; + + if (not $self->profile_is_concerned($build_profiles)) { + $self->reset(); + } else { + $self->{restrictions} = undef; + } +} + +=item $dep->get_evaluation($facts) + +Evaluates the dependency given a list of installed packages and a list of +virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts +object given as parameters. + +Returns 1 when it's true, 0 when it's false, undef when some information +is lacking to conclude. + +=cut + +sub get_evaluation { + my ($self, $facts) = @_; + + return if not defined $self->{package}; + return $facts->evaluate_simple_dep($self); +} + +=item $dep->simplify_deps($facts, @assumed_deps) + +Simplifies the dependency as much as possible given the list of facts (see +object Dpkg::Deps::KnownFacts) and a list of other dependencies that are +known to be true. + +=cut + +sub simplify_deps { + my ($self, $facts) = @_; + + my $eval = $self->get_evaluation($facts); + $self->reset() if defined $eval and $eval == 1; +} + +=item $dep->is_empty() + +Returns true if the dependency is empty and doesn't contain any useful +information. This is true when the object has not yet been initialized. + +=cut + +sub is_empty { + my $self = shift; + + return not defined $self->{package}; +} + +=item $dep->merge_union($other_dep) + +Returns true if $dep could be modified to represent the union of both +dependencies. Otherwise returns false. + +=cut + +sub merge_union { + my ($self, $o) = @_; + + return 0 if not $o->isa('Dpkg::Deps::Simple'); + return 0 if $self->is_empty() or $o->is_empty(); + return 0 if $self->{package} ne $o->{package}; + return 0 if defined $self->{arches} or defined $o->{arches}; + + if (not defined $o->{relation} and defined $self->{relation}) { + # Union is the non-versioned dependency + $self->{relation} = undef; + $self->{version} = undef; + return 1; + } + + my $implication = $self->implies($o); + my $rev_implication = $o->implies($self); + if (defined $implication) { + if ($implication) { + $self->{relation} = $o->{relation}; + $self->{version} = $o->{version}; + return 1; + } else { + return 0; + } + } + if (defined $rev_implication) { + if ($rev_implication) { + # Already merged... + return 1; + } else { + return 0; + } + } + return 0; +} + +=back + +=head1 CHANGES + +=head2 Version 1.02 (dpkg 1.17.10) + +New methods: Add $dep->profile_is_concerned() and $dep->reduce_profiles(). + +=head2 Version 1.01 (dpkg 1.16.1) + +New method: Add $dep->reset(). + +New property: recognizes the arch qualifier "any" and stores it in the +"archqual" property when present. + +=head2 Version 1.00 (dpkg 1.15.6) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Dpkg/Deps/Union.pm b/scripts/Dpkg/Deps/Union.pm new file mode 100644 index 000000000..62cf5c38a --- /dev/null +++ b/scripts/Dpkg/Deps/Union.pm @@ -0,0 +1,119 @@ +# Copyright © 1998 Richard Braakman +# Copyright © 1999 Darren Benham +# Copyright © 2000 Sean 'Shaleh' Perry +# Copyright © 2004 Frank Lichtenheld +# Copyright © 2006 Russ Allbery +# Copyright © 2007-2009 Raphaël Hertzog +# Copyright © 2008-2009, 2012-2014 Guillem Jover +# +# This program is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Dpkg::Deps::Union; + +=encoding utf8 + +=head1 NAME + +Dpkg::Deps::Union - list of unrelated dependencies + +=head1 DESCRIPTION + +This object represents a list of relationships. It inherits from +Dpkg::Deps::Multiple. + +=cut + +use strict; +use warnings; + +our $VERSION = '1.00'; + +use parent qw(Dpkg::Deps::Multiple); + +=head1 METHODS + +=over 4 + +=item $dep->output([$fh]) + +The output method uses ", " to join the list of relationships. + +=cut + +sub output { + my ($self, $fh) = @_; + + my $res = join(', ', map { + $_->output() + } grep { + not $_->is_empty() + } $self->get_deps()); + + if (defined $fh) { + print { $fh } $res; + } + return $res; +} + +=item $dep->implies($other_dep) + +=item $dep->get_evaluation($other_dep) + +These methods are not meaningful for this object and always return undef. + +=cut + +sub implies { + # Implication test is not useful on Union. + return; +} + +sub get_evaluation { + # Evaluation is not useful on Union. + return; +} + +=item $dep->simplify_deps($facts) + +The simplification is done to generate an union of all the relationships. +It uses $simple_dep->merge_union($other_dep) to get its job done. + +=cut + +sub simplify_deps { + my ($self, $facts) = @_; + my @new; + +WHILELOOP: + while (@{$self->{list}}) { + my $odep = shift @{$self->{list}}; + foreach my $dep (@new) { + next WHILELOOP if $dep->merge_union($odep); + } + push @new, $odep; + } + $self->{list} = [ @new ]; +} + +=back + +=head1 CHANGES + +=head2 Version 1.00 (dpkg 1.15.6) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 28bb4a742..d8160749b 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -79,6 +79,12 @@ nobase_dist_perllib_DATA = \ Dpkg/Control/Tests/Entry.pm \ Dpkg/Control/Types.pm \ Dpkg/Deps.pm \ + Dpkg/Deps/AND.pm \ + Dpkg/Deps/KnownFacts.pm \ + Dpkg/Deps/Multiple.pm \ + Dpkg/Deps/OR.pm \ + Dpkg/Deps/Simple.pm \ + Dpkg/Deps/Union.pm \ Dpkg/Dist/Files.pm \ Dpkg/ErrorHandling.pm \ Dpkg/Exit.pm \ diff --git a/scripts/po/POTFILES.in b/scripts/po/POTFILES.in index dea8cde0e..638fd8b97 100644 --- a/scripts/po/POTFILES.in +++ b/scripts/po/POTFILES.in @@ -46,6 +46,12 @@ scripts/Dpkg/Control/Tests.pm scripts/Dpkg/Control/Tests/Entry.pm scripts/Dpkg/Control/Types.pm scripts/Dpkg/Deps.pm +scripts/Dpkg/Deps/AND.pm +scripts/Dpkg/Deps/KnownFacts.pm +scripts/Dpkg/Deps/Multiple.pm +scripts/Dpkg/Deps/OR.pm +scripts/Dpkg/Deps/Simple.pm +scripts/Dpkg/Deps/Union.pm scripts/Dpkg/Dist/Files.pm scripts/Dpkg/ErrorHandling.pm scripts/Dpkg/Exit.pm -- cgit v1.2.3 From 9ab6c592c04c06952019e5c9bba57b2b54aa3fae Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 8 Jun 2018 03:22:36 +0200 Subject: Dpkg::Source: Do not change patch permissions if not necessary To be able to build a source tree, a user needs write permisions on it, but not necessarily ownership of those files. We check the existing file permissions and avoid changing them if not necessary, which helps in the case where the user does not have ownership of those files, and they were already present. Closes: #898010 Naming-by: Julian Andres Klode --- debian/changelog | 2 ++ scripts/Dpkg/Source/Functions.pm | 13 +++++++++++++ scripts/Dpkg/Source/Package/V2.pm | 4 ++-- scripts/Dpkg/Source/Package/V3/Quilt.pm | 4 ++-- scripts/Dpkg/Source/Quilt.pm | 4 ++-- 5 files changed, 21 insertions(+), 6 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index d0c53872d..28568a5c4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -131,6 +131,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium modules. - Dpkg::Gettext: Fix fallback textdomain() to honor its expected interface. - Dpkg::Deps: Split subpackages into their own separate modules. + - Dpkg::Source: Do not change patch permissions if not necessary. + Closes: #898010 * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Source/Functions.pm b/scripts/Dpkg/Source/Functions.pm index 0a940463e..dcb957e13 100644 --- a/scripts/Dpkg/Source/Functions.pm +++ b/scripts/Dpkg/Source/Functions.pm @@ -22,6 +22,7 @@ our $VERSION = '0.01'; our @EXPORT_OK = qw( erasedir fixperms + chmod_if_needed fs_time is_binary ); @@ -70,6 +71,18 @@ sub fixperms { subprocerr("chmod -R -- $modes_set $dir") if $?; } +# Only change the pathname permissions if they differ from the desired. +# +# To be able to build a source tree, a user needs write permisions on it, +# but not necessarily ownership of those files. +sub chmod_if_needed { + my ($newperms, $pathname) = @_; + my $oldperms = (stat $pathname)[2] & 07777; + + return 1 if $oldperms == $newperms; + return chmod $newperms, $pathname; +} + # Touch the file and read the resulting mtime. # # If the file doesn't exist, create it, read the mtime and unlink it. diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index 13e5d7456..2c8529bc1 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -38,7 +38,7 @@ use Dpkg::Compression; use Dpkg::Source::Archive; use Dpkg::Source::Patch; use Dpkg::Exit qw(push_exit_handler pop_exit_handler); -use Dpkg::Source::Functions qw(erasedir is_binary fs_time); +use Dpkg::Source::Functions qw(erasedir chmod_if_needed is_binary fs_time); use Dpkg::Vendor qw(run_vendor_hook); use Dpkg::Control; use Dpkg::Changelog::Parse; @@ -673,7 +673,7 @@ sub register_patch { if (-s $patch_file) { copy($patch_file, $patch) or syserr(g_('failed to copy %s to %s'), $patch_file, $patch); - chmod(0666 & ~ umask(), $patch) + chmod_if_needed(0666 & ~ umask(), $patch) or syserr(g_("unable to change permission of '%s'"), $patch); my $applied = File::Spec->catfile($dir, 'debian', 'patches', '.dpkg-source-applied'); open(my $applied_fh, '>>', $applied) diff --git a/scripts/Dpkg/Source/Package/V3/Quilt.pm b/scripts/Dpkg/Source/Package/V3/Quilt.pm index 9718ffa2d..7c6137c28 100644 --- a/scripts/Dpkg/Source/Package/V3/Quilt.pm +++ b/scripts/Dpkg/Source/Package/V3/Quilt.pm @@ -28,7 +28,7 @@ use Dpkg::Gettext; use Dpkg::ErrorHandling; use Dpkg::Version; use Dpkg::Source::Patch; -use Dpkg::Source::Functions qw(erasedir fs_time); +use Dpkg::Source::Functions qw(erasedir chmod_if_needed fs_time); use Dpkg::Source::Quilt; use Dpkg::Exit; @@ -249,7 +249,7 @@ sub register_patch { if (-s $tmpdiff) { copy($tmpdiff, $patch) or syserr(g_('failed to copy %s to %s'), $tmpdiff, $patch); - chmod(0666 & ~ umask(), $patch) + chmod_if_needed(0666 & ~ umask(), $patch) or syserr(g_("unable to change permission of '%s'"), $patch); } elsif (-e $patch) { unlink($patch) or syserr(g_('cannot remove %s'), $patch); diff --git a/scripts/Dpkg/Source/Quilt.pm b/scripts/Dpkg/Source/Quilt.pm index 55b3fbaf8..78a4fdf9a 100644 --- a/scripts/Dpkg/Source/Quilt.pm +++ b/scripts/Dpkg/Source/Quilt.pm @@ -30,7 +30,7 @@ use File::Basename; use Dpkg::Gettext; use Dpkg::ErrorHandling; use Dpkg::Source::Patch; -use Dpkg::Source::Functions qw(erasedir fs_time); +use Dpkg::Source::Functions qw(erasedir chmod_if_needed fs_time); use Dpkg::Vendor qw(get_current_vendor); sub new { @@ -374,7 +374,7 @@ sub restore_quilt_backup_files { unless (link($_, $target)) { copy($_, $target) or syserr(g_('failed to copy %s to %s'), $_, $target); - chmod((stat(_))[2], $target) + chmod_if_needed((stat _)[2], $target) or syserr(g_("unable to change permission of '%s'"), $target); } } else { -- cgit v1.2.3 From a4f0c6f04636ed066eb7e5162403d20a369fceec Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 11 Aug 2018 03:32:37 +0200 Subject: Fix some typos Thanks-to: Niels Thykier (for typo in dpkg(1)) --- ChangeLog.old | 12 ++++++------ debian/changelog | 4 ++-- debian/control | 2 +- doc/rootless-builds.txt | 2 +- lib/compat/getopt.c | 2 +- lib/dpkg/path-remove.c | 2 +- man/dpkg.man | 2 +- scripts/Dpkg/Source/Functions.pm | 2 +- scripts/dpkg-buildpackage.pl | 4 ++-- scripts/t/Dpkg_Changelog/shadow | 8 ++++---- t/pod-coverage.t | 2 +- 11 files changed, 21 insertions(+), 21 deletions(-) (limited to 'scripts/Dpkg') diff --git a/ChangeLog.old b/ChangeLog.old index 770c9d630..252d901b7 100644 --- a/ChangeLog.old +++ b/ChangeLog.old @@ -1361,7 +1361,7 @@ 2008-08-05 Guillem Jover - * scripts/dpkg-distaddfile.pl: Use _g() instead of mispelled gettext(). + * scripts/dpkg-distaddfile.pl: Use _g() instead of misspelled gettext(). 2008-08-03 Guillem Jover @@ -7444,7 +7444,7 @@ 2006-02-08 Guillem Jover - * debian/contrl (Build-Depends): Depend on version >= 1.28-4 of + * debian/control (Build-Depends): Depend on version >= 1.28-4 of libselinux1-dev as it has pkg-config support. Remove libsepol1-dev, now dragged by libselinux1-dev. Add pkg-config. * m4/libs.m4 (DPKG_LIB_SELINUX): Use pkg-config to get the static @@ -7689,7 +7689,7 @@ 2006-01-23 Bart Martens , Guillem Jover - * debian/contrl (Build-Depends): Add libsepol1-dev as a temporary + * debian/control (Build-Depends): Add libsepol1-dev as a temporary workaround until libselinux1-dev has pkg-config support. * m4/libs.m4 (DPKG_LIB_SELINUX): Explicitly statically link against libsepol. @@ -11001,7 +11001,7 @@ Sun May 19 04:09:25 CDT 2002 Adam Heath * debian/rules: Fix targets, so that if configure fails, but actually succeeds in creating config.status(as might happen if one has a - c-style comment in configure.in, and the shell trys running /foo), then + c-style comment in configure.in, and the shell tries running /foo), then the build will actually fail correctly. Sun May 19 02:31:11 CDT 2002 Adam Heath @@ -13730,7 +13730,7 @@ Tue Feb 8 21:33:58 EST 2000 Ben Collins * main/{processarc,archive}.c: Make the conflictor an array of structs and make sure that check_conflicts uses that and increments a global indexs for the array. The reason that multiple conflicts/replaces were getting - borked had something to do with thre first one in the hash not being + borked had something to do with the first one in the hash not being processed. This was the result of bad pointer games, so this makes it a lot cleaner. @@ -16705,7 +16705,7 @@ Changes in dpkg 0.93.15: * Put packages in `purge' state even if `deinstall' requested if they have no postrm and no conffiles. * Version number comparisons fixed. -* insert-version.pl now installes lib.pl filename too. +* insert-version.pl now installs lib.pl filename too. * Strip trailing slashes when reading files from file lists. Changes in dpkg 0.93.14: diff --git a/debian/changelog b/debian/changelog index b42616b84..fd30747c2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -485,7 +485,7 @@ dpkg (1.18.24) unstable; urgency=medium on not cleaning the source tree. * Documentation: - Many spelling fixes. Thanks to Josh Soref . - - Do not include mispellings in changelogs, as that makes detecting them + - Do not include misspellings in changelogs, as that makes detecting them more difficult. * Build system: - Use libexec variable for auxiliary internal programs, and set it to @@ -12719,7 +12719,7 @@ Changes in dpkg 0.93.15: * Put packages in `purge' state even if `deinstall' requested if they have no postrm and no conffiles. * Version number comparisons fixed. -* insert-version.pl now installes lib.pl filename too. +* insert-version.pl now installs lib.pl filename too. * Strip trailing slashes when reading files from file lists. Changes in dpkg 0.93.14: diff --git a/debian/control b/debian/control index 29f9fc5ee..a3f819118 100644 --- a/debian/control +++ b/debian/control @@ -165,7 +165,7 @@ Description: Dpkg perl modules - Dpkg::Build::Info: build information functions - Dpkg::BuildFlags: set, modify and query compilation build flags - Dpkg::BuildOptions: parse and manipulate DEB_BUILD_OPTIONS - - Dpkg::BuildProfile: parse and manipulate build profiles + - Dpkg::BuildProfiles: parse and manipulate build profiles - Dpkg::Changelog: parse changelogs - Dpkg::Changelog::Entry: represents a changelog entry - Dpkg::Changelog::Parse: generic changelog parser for dpkg-parsechangelog diff --git a/doc/rootless-builds.txt b/doc/rootless-builds.txt index 0157879a4..0b6b9d849 100644 --- a/doc/rootless-builds.txt +++ b/doc/rootless-builds.txt @@ -57,7 +57,7 @@ When the builder supports this specification, it MUST notify this fact to the rules file via the "DEB_RULES_REQUIRES_ROOT" environment variable, with the value it has obtained from the Rules-Requires-Root field or some builder specific override mechanism, which will denote the level of support the -builder has choosen to commit to take effect during the build. When set, +builder has chosen to commit to take effect during the build. When set, it MUST be a valid value for the Rules-Requires-Root field. If unset, the build system SHOULD assume that the builder does not recognize the Rules-Requires-Root field at all. diff --git a/lib/compat/getopt.c b/lib/compat/getopt.c index 4c52b8b82..b13f81454 100644 --- a/lib/compat/getopt.c +++ b/lib/compat/getopt.c @@ -88,7 +88,7 @@ USA. */ #endif /* XXX: Disable intl support, because we do not carry the translations anyway - * and this pulls indirectly libintl, wich we do not want to impose. */ + * and this pulls indirectly libintl, which we do not want to impose. */ #ifndef _ #define _(msgid) (msgid) #endif diff --git a/lib/dpkg/path-remove.c b/lib/dpkg/path-remove.c index ef9cde7b5..6afb37607 100644 --- a/lib/dpkg/path-remove.c +++ b/lib/dpkg/path-remove.c @@ -1,6 +1,6 @@ /* * libdpkg - Debian packaging suite library routines - * path-remove.c - path removal functionss + * path-remove.c - path removal functions * * Copyright © 1994-1995 Ian Jackson * Copyright © 2007-2015 Guillem Jover diff --git a/man/dpkg.man b/man/dpkg.man index fdaa87b1c..772c1b324 100644 --- a/man/dpkg.man +++ b/man/dpkg.man @@ -623,7 +623,7 @@ any software not doing syncs before atomic renames. losing data, use with care.\fP \fBscript-chrootless\fP: -Run maintainer scrips without \fBchroot\fP(2)ing into \fBinstdir\fP even +Run maintainer scripts without \fBchroot\fP(2)ing into \fBinstdir\fP even if the package does not support this mode of operation (since dpkg 1.18.5). \fIWarning: This can destroy your host system, use with extreme care.\fP diff --git a/scripts/Dpkg/Source/Functions.pm b/scripts/Dpkg/Source/Functions.pm index dcb957e13..262b80ad1 100644 --- a/scripts/Dpkg/Source/Functions.pm +++ b/scripts/Dpkg/Source/Functions.pm @@ -73,7 +73,7 @@ sub fixperms { # Only change the pathname permissions if they differ from the desired. # -# To be able to build a source tree, a user needs write permisions on it, +# To be able to build a source tree, a user needs write permissions on it, # but not necessarily ownership of those files. sub chmod_if_needed { my ($newperms, $pathname) = @_; diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl index 9cc6969d3..c50416580 100755 --- a/scripts/dpkg-buildpackage.pl +++ b/scripts/dpkg-buildpackage.pl @@ -629,7 +629,7 @@ if ($signsource) { error(g_('failed to sign %s file'), '.dsc'); } - # Recompute the checksums as the .dsc have changed now. + # Recompute the checksums as the .dsc has changed now. my $buildinfo = Dpkg::Control->new(type => CTRL_FILE_BUILDINFO); $buildinfo->load("../$pva.buildinfo"); my $checksums = Dpkg::Checksums->new(); @@ -731,7 +731,7 @@ sub parse_rules_requires_root { setup_rootcommand(); } - # Notify the childs we do support R³. + # Notify the children we do support R³. $ENV{DEB_RULES_REQUIRES_ROOT} = join ' ', sort keys %rrr; if ($keywords_base > 1 or $keywords_base and $keywords_impl) { diff --git a/scripts/t/Dpkg_Changelog/shadow b/scripts/t/Dpkg_Changelog/shadow index f9b2236f5..5f4bddb85 100644 --- a/scripts/t/Dpkg_Changelog/shadow +++ b/scripts/t/Dpkg_Changelog/shadow @@ -896,7 +896,7 @@ shadow (1:4.0.3-12) unstable; urgency=low shadow (1:4.0.3-11) unstable; urgency=low * update Japanese debconf translation. closes: #210382 - * update Brazilian Portugese debconf translation. closes: #208122 + * update Brazilian Portuguese debconf translation. closes: #208122 * run pam cleanup code as root. closes: #195048 -- Karl Ramm Sat, 13 Sep 2003 17:49:29 -0400 @@ -1108,7 +1108,7 @@ shadow (20000902-7) unstable; urgency=low * Cancel login timeout after authentication so that patient people timing out on network directory services can log in with local accounts. Closes: #107148 - * Add Brazillian Portugese debconf template translation for passwd. + * Add Brazillian Portuguese debconf template translation for passwd. Closes: #105292, #93223 * Pull /usr/share/doc/$package/README.shadow-paper.gz. Closes: #98058 * Use getent instead of group to verify existence of shadow group @@ -1382,7 +1382,7 @@ shadow (19990827-9) unstable; urgency=low shadow (19990827-8) unstable; urgency=low - * src/login.c: fixed loggin of username on successful login (was using + * src/login.c: fixed login of username on successful login (was using the normal username, when it should have used pam_user), closes: #47819 * src/login.c: check for hushed login and pass PAM_SILENT if true, @@ -1586,7 +1586,7 @@ shadow (19990827-1) unstable; urgency=low also call pam_fail_delay() with FAIL_DELAY as the arg before authentication. * etc/login.defs.pam.linux: new file, reflects options that PAM takesover * etc/login.defs.pam.hurd: new file, same for Hurd - * debian/passwd.mk: make sure that login.defs.5 get's installed for Hurd + * debian/passwd.mk: make sure that login.defs.5 gets installed for Hurd * pam.d/: Modified defaults for each service to reflect the old style and also added commented options on how to enable obsoleted options from login.defs in the PAM Way(tm). diff --git a/t/pod-coverage.t b/t/pod-coverage.t index 3cecd8b59..113feb264 100644 --- a/t/pod-coverage.t +++ b/t/pod-coverage.t @@ -34,7 +34,7 @@ sub all_pod_modules my $scan_perl_modules = sub { my $module = $File::Find::name; - # Only chack modules, scripts are documented in man pages. + # Only check modules, scripts are documented in man pages. return unless $module =~ s/\.pm$//; my $mod = Module::Metadata->new_from_file($File::Find::name); -- cgit v1.2.3 From 6227aa720d9ce637e676bdc0096fb8316576348f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 23 Jul 2018 12:13:31 +0200 Subject: Dpkg::Substvars: Reword used/unused warnings to clarify their meaning Clarify the unknown and unused substitution variable warnings, to try to make them more clear as to what each implies. Closes: #904258 --- debian/changelog | 2 ++ scripts/Dpkg/Substvars.pm | 6 ++++-- scripts/t/Dpkg_Substvars.t | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index fd30747c2..19fa87c6a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -134,6 +134,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::Deps: Split subpackages into their own separate modules. - Dpkg::Source: Do not change patch permissions if not necessary. Closes: #898010 + - Dpkg::Substvars: Reword used/unused warnings to clarify their meaning. + Closes: #904258 * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index 1e9f90173..637072846 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -342,7 +342,8 @@ sub substvars { g_('obsolete substitution variable ${%s}'), $vn); } } else { - warning($opts{msg_prefix} . g_('unknown substitution variable ${%s}'), + warning($opts{msg_prefix} . + g_('substitution variable ${%s} used, but is not defined'), $vn) unless $opts{no_warn}; $v = $lhs . $rhs; } @@ -366,7 +367,8 @@ sub warn_about_unused { # that they are not required in the current situation # (example: debhelper's misc:Depends in many cases) next if $self->{vars}{$vn} eq ''; - warning($opts{msg_prefix} . g_('unused substitution variable ${%s}'), + warning($opts{msg_prefix} . + g_('substitution variable ${%s} unused, but is defined'), $vn); } } diff --git a/scripts/t/Dpkg_Substvars.t b/scripts/t/Dpkg_Substvars.t index bb8e14039..6c7be24f2 100644 --- a/scripts/t/Dpkg_Substvars.t +++ b/scripts/t/Dpkg_Substvars.t @@ -97,7 +97,7 @@ is($s->substvars('This is a string with unknown variable ${blubb}'), 'substvars missing'); delete $SIG{__WARN__}; is($output, - 'Dpkg_Substvars.t: warning: test unknown substitution variable ${blubb}' . "\n", + 'Dpkg_Substvars.t: warning: test substitution variable ${blubb} used, but is not defined' . "\n", 'missing variables warning'); # Recursive replace @@ -117,7 +117,7 @@ $SIG{__WARN__} = sub { $output .= $_[0] }; $s->warn_about_unused(); delete $SIG{__WARN__}; is($output, - 'Dpkg_Substvars.t: warning: test unused substitution variable ${var2}' . "\n", + 'Dpkg_Substvars.t: warning: test substitution variable ${var2} unused, but is defined' . "\n", 'unused variables warnings'); # Disable warnings for a certain variable -- cgit v1.2.3 From 174a5bd2a080847d0ed901d269a2ba74476eba8b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 11 Aug 2018 03:35:01 +0200 Subject: Dpkg::Shlibs: Warn when using LD_LIBRARY_PATH with a descendent of cwd This makes the deprecation explicit, so that we can start noticing what is inappropriately setting this variable for a purpose it was not designed for. --- debian/changelog | 2 ++ scripts/Dpkg/Shlibs.pm | 10 ++++++++++ 2 files changed, 12 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 90f81981d..a335036fb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -152,6 +152,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium Closes: #898010 - Dpkg::Substvars: Reword used/unused warnings to clarify their meaning. Closes: #904258 + - Dpkg::Shlibs: Warn when using LD_LIBRARY_PATH with a private library + directory which is a descendent of the current working directory. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Shlibs.pm b/scripts/Dpkg/Shlibs.pm index c8b43ab9d..b5d5bdf64 100644 --- a/scripts/Dpkg/Shlibs.pm +++ b/scripts/Dpkg/Shlibs.pm @@ -90,8 +90,18 @@ sub setup_library_paths { # XXX: Deprecated. Update library paths with LD_LIBRARY_PATH. if ($ENV{LD_LIBRARY_PATH}) { + require Cwd; + my $cwd = Cwd::getcwd; + foreach my $path (split /:/, $ENV{LD_LIBRARY_PATH}) { $path =~ s{/+$}{}; + + if (Cwd::realpath($path) =~ m/^\Q$cwd\E/) { + warning(g_('deprecated use of LD_LIBRARY_PATH with private ' . + 'library directory which interferes with ' . + 'cross-building, please use -l option instead')); + } + # XXX: This should be added to @custom_librarypaths, but as this # is deprecated we do not care as the code will go away. push @system_librarypaths, $path; -- cgit v1.2.3 From b741076e2a70dfa9f385b6baa9bfc6b496bd902f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 20 Aug 2018 16:37:18 +0200 Subject: Dpkg::Source::Package::V3::Quilt: Print series file used when applying patches We might use a vendor specific series file, so we should print the one being used to notify if this fact. --- debian/changelog | 2 ++ scripts/Dpkg/Source/Package/V3/Quilt.pm | 2 ++ 2 files changed, 4 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index a335036fb..dc0c41ba6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -154,6 +154,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium Closes: #904258 - Dpkg::Shlibs: Warn when using LD_LIBRARY_PATH with a private library directory which is a descendent of the current working directory. + - Dpkg::Source::Package::V3::Quilt: Print series file used when applying + patches. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Source/Package/V3/Quilt.pm b/scripts/Dpkg/Source/Package/V3/Quilt.pm index 7c6137c28..45237d26a 100644 --- a/scripts/Dpkg/Source/Package/V3/Quilt.pm +++ b/scripts/Dpkg/Source/Package/V3/Quilt.pm @@ -142,6 +142,8 @@ sub apply_patches { return unless scalar($quilt->series()); + info(g_('using patch list from %s'), "debian/patches/$basename"); + if ($opts{usage} eq 'preparation' and $self->{options}{unapply_patches} eq 'auto') { # We're applying the patches in --before-build, remember to unapply -- cgit v1.2.3 From fd1b41d81578a97399284f72ae703c0a32e3f905 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 24 Aug 2018 21:18:12 +0200 Subject: Dpkg::OpenPGP: Return the destination path on successful ASCII armor conversion This way we can distinguish the failure from the success case. --- debian/changelog | 2 ++ scripts/Dpkg/OpenPGP.pm | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index dc0c41ba6..9f5e81dfa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -156,6 +156,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium directory which is a descendent of the current working directory. - Dpkg::Source::Package::V3::Quilt: Print series file used when applying patches. + - Dpkg::OpenPGP: Return the destination path on successful ASCII armor + conversion. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm index 858d3efcf..8d85e845d 100644 --- a/scripts/Dpkg/OpenPGP.pm +++ b/scripts/Dpkg/OpenPGP.pm @@ -49,7 +49,7 @@ sub openpgp_sig_to_asc if ($is_openpgp_ascii_armor) { notice(g_('signature file is already OpenPGP ASCII armor, copying')); copy($sig, $asc); - return; + return $asc; } if (not find_command('gpg')) { @@ -71,7 +71,7 @@ sub openpgp_sig_to_asc close $fh_gpg or subprocerr('gpg'); close $fh_asc or syserr(g_('cannot write signature file %s'), $asc); - return $sig; + return $asc; } return; -- cgit v1.2.3 From 786870e4bb9656b39df2bdeff5cc747e41d734c4 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 25 Aug 2018 01:28:17 +0200 Subject: Dpkg::Control::Fields: Do not use & sigil for function calls Warned-by: perlcritic Fixes: Subroutines::ProhibitAmpersandSigils --- debian/changelog | 1 + scripts/Dpkg/Control/Fields.pm | 9 ++++++--- t/critic.t | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 9f5e81dfa..2d9d9e0e4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -158,6 +158,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium patches. - Dpkg::OpenPGP: Return the destination path on successful ASCII armor conversion. + - Dpkg::Control::Fields: Do not use & sigil for function calls. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Control/Fields.pm b/scripts/Dpkg/Control/Fields.pm index 4a584e413..33beeec56 100644 --- a/scripts/Dpkg/Control/Fields.pm +++ b/scripts/Dpkg/Control/Fields.pm @@ -32,11 +32,14 @@ foreach my $op (run_vendor_hook('register-custom-fields')) { next if not (defined $op and ref $op); # Skip when not implemented by vendor my $func = shift @$op; if ($func eq 'register') { - &field_register(@$op); + my ($field, $allowed_type, @opts) = @{$op}; + field_register($field, $allowed_type, @opts); } elsif ($func eq 'insert_before') { - &field_insert_before(@$op); + my ($type, $ref, @fields) = @{$op}; + field_insert_before($type, $ref, @fields); } elsif ($func eq 'insert_after') { - &field_insert_after(@$op); + my ($type, $ref, @fields) = @{$op}; + field_insert_after($type, $ref, @fields); } else { croak "vendor hook register-custom-fields sent bad data: @$op"; } diff --git a/t/critic.t b/t/critic.t index 0221c1b22..acb841f38 100644 --- a/t/critic.t +++ b/t/critic.t @@ -79,6 +79,7 @@ my @policies = qw( RegularExpressions::ProhibitUselessTopic RegularExpressions::RequireBracesForMultiline RegularExpressions::RequireExtendedFormatting + Subroutines::ProhibitAmpersandSigils Subroutines::ProhibitExplicitReturnUndef Subroutines::ProhibitManyArgs Subroutines::ProhibitNestedSubs -- cgit v1.2.3 From 56810aa960e9ac8a51da178bb32e487726f60530 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 1 Sep 2018 22:37:43 +0200 Subject: Dpkg::Substvars: Fix typo --- scripts/Dpkg/Substvars.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index 637072846..650eae7fa 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -39,8 +39,7 @@ Dpkg::Substvars - handle variable substitution in strings =head1 DESCRIPTION -It provides some an object which is able to substitute variables in -strings. +It provides an object which is able to substitute variables in strings. =cut -- cgit v1.2.3 From 8fe2c1ebf907f325b6985f471a00843eca77992b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 3 Sep 2018 19:28:01 +0200 Subject: Dpkg::Shlibs: Ignore nonexistent directories present in LD_LIBRARY_PATH We were trying to use realpath() on nonexistent directories, which means we'd get undef. Instead just completely ignore nonexistent directories from any processing. Fixes: commit 174a5bd2a080847d0ed901d269a2ba74476eba8b --- debian/changelog | 1 + scripts/Dpkg/Shlibs.pm | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index f2eef27f2..5030f6a7a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -160,6 +160,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Dpkg::OpenPGP: Return the destination path on successful ASCII armor conversion. - Dpkg::Control::Fields: Do not use & sigil for function calls. + - Dpkg::Shlibs: Ignore nonexistent directories present in LD_LIBRARY_PATH. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Shlibs.pm b/scripts/Dpkg/Shlibs.pm index b5d5bdf64..2b19d14a7 100644 --- a/scripts/Dpkg/Shlibs.pm +++ b/scripts/Dpkg/Shlibs.pm @@ -96,7 +96,9 @@ sub setup_library_paths { foreach my $path (split /:/, $ENV{LD_LIBRARY_PATH}) { $path =~ s{/+$}{}; - if (Cwd::realpath($path) =~ m/^\Q$cwd\E/) { + my $realpath = Cwd::realpath($path); + next unless defined $realpath; + if ($realpath =~ m/^\Q$cwd\E/) { warning(g_('deprecated use of LD_LIBRARY_PATH with private ' . 'library directory which interferes with ' . 'cross-building, please use -l option instead')); -- cgit v1.2.3 From 9429372291069eab0f853f772fc76177413410ef Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 16 Sep 2018 03:31:25 +0200 Subject: Dpkg::Deps::KnownFacts: Satisfy :native with arch:all packages too Architecture:all packages are treated as native ones as part of the current multi-arch design, the only current exception is in build dependencies with the :native arch-qualifier. It looks like this was an oversight when implementing the :native support, as there's been no rationale found for the current behavior. Closes: #854438 Analysis-by: Johannes Schauer --- debian/changelog | 5 +++++ scripts/Dpkg/Deps/KnownFacts.pm | 3 ++- scripts/t/Dpkg_Deps.t | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 6fea9b501..d407098b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -163,6 +163,11 @@ dpkg (1.19.1) UNRELEASED; urgency=medium conversion. - Dpkg::Control::Fields: Do not use & sigil for function calls. - Dpkg::Shlibs: Ignore nonexistent directories present in LD_LIBRARY_PATH. + - Dpkg::Deps::KnownFacts: Satisfy :native with arch:all packages too. + These are treated as native packages everywhere else in the multi-arch + design, this was the only exception, which has become a source of + packaging problems as of late. This was apparently an oversight in + the original implementation. Closes: #854438 * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/scripts/Dpkg/Deps/KnownFacts.pm b/scripts/Dpkg/Deps/KnownFacts.pm index 95770ec00..192f6aa6b 100644 --- a/scripts/Dpkg/Deps/KnownFacts.pm +++ b/scripts/Dpkg/Deps/KnownFacts.pm @@ -167,7 +167,8 @@ sub _find_package { } elsif ($archqual eq 'any') { return $p if $ma eq 'allowed'; } elsif ($archqual eq 'native') { - return $p if $a eq $build_arch and $ma ne 'foreign'; + return if $ma eq 'foreign'; + return $p if $a eq $build_arch or $a eq 'all'; } else { return $p if $a eq $archqual; } diff --git a/scripts/t/Dpkg_Deps.t b/scripts/t/Dpkg_Deps.t index 27fb12a15..14fe4e014 100644 --- a/scripts/t/Dpkg_Deps.t +++ b/scripts/t/Dpkg_Deps.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 78; +use Test::More tests => 82; use Dpkg::Arch qw(get_host_arch); use Dpkg::Version; @@ -160,6 +160,8 @@ $facts->add_installed_package('pkg-ma-foreign2', '1.3.4-1', get_host_arch(), 'fo $facts->add_installed_package('pkg-ma-allowed', '1.3.4-1', 'somearch', 'allowed'); $facts->add_installed_package('pkg-ma-allowed2', '1.3.4-1', 'somearch', 'allowed'); $facts->add_installed_package('pkg-ma-allowed3', '1.3.4-1', get_host_arch(), 'allowed'); +$facts->add_installed_package('pkg-indep-normal', '1.3.4-1', 'all', 'no'); +$facts->add_installed_package('pkg-indep-foreign', '1.3.4-1', 'all', 'foreign'); $facts->add_provided_package('myvirtual', undef, undef, 'mypackage'); $facts->add_provided_package('myvirtual2', REL_EQ, '1.0-1', 'mypackage'); $facts->add_provided_package('myvirtual3', REL_GE, '2.0-1', 'mypackage'); @@ -172,6 +174,23 @@ $dep_dup->simplify_deps($facts, $dep_opposite); is($dep_dup->output(), 'libc6 (>= 2.6-1), mypackage2, pkg-ma-allowed2', 'Simplify deps'); +my $dep_ma_all_normal_implicit_native = deps_parse('pkg-indep-normal', build_dep => 1); +my $dep_ma_all_normal_explicit_native = deps_parse('pkg-indep-normal:native', build_dep => 1); +my $dep_ma_all_foreign_implicit_native = deps_parse('pkg-indep-foreign', build_dep => 1); +my $dep_ma_all_foreign_explicit_native = deps_parse('pkg-indep-foreign:native', build_dep => 1); +$dep_ma_all_normal_implicit_native->simplify_deps($facts); +is($dep_ma_all_normal_implicit_native->output(), '', + 'Simplify arch:all m-a:no w/ implicit :native (satisfied)'); +$dep_ma_all_normal_explicit_native->simplify_deps($facts); +is($dep_ma_all_normal_explicit_native->output(), '', + 'Simplify arch:all m-a:no w/ explicit :native (satisfied)'); +$dep_ma_all_foreign_implicit_native->simplify_deps($facts); +is($dep_ma_all_foreign_implicit_native->output(), '', + 'Simplify arch:all m-a:foreign w/ implicit :native (satisfied)'); +$dep_ma_all_foreign_explicit_native->simplify_deps($facts); +is($dep_ma_all_foreign_explicit_native->output(), 'pkg-indep-foreign:native', + 'Simplify arch:all m-a:foreign w/ explicit :native (unsatisfied)'); + TODO: { local $TODO = 'not yet implemented'; -- cgit v1.2.3 From a034e7d53b0c96c419d71c86921d2a509b0d79bc Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 30 Jul 2018 16:42:21 +0200 Subject: Dpkg::Vendor::Debian: Add fixfilepath support to reproducible feature This is a superset of the fixdebugpath feature supported by gcc-8, but covering in addition mappings for macros such as __FILE__ and similar. --- debian/changelog | 1 + man/dpkg-buildflags.man | 11 +++++++++++ scripts/Dpkg/Vendor/Debian.pm | 21 +++++++++++++++++---- scripts/t/Dpkg_BuildFlags.t | 1 + 4 files changed, 30 insertions(+), 4 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index d407098b0..5f45df110 100644 --- a/debian/changelog +++ b/debian/changelog @@ -168,6 +168,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium design, this was the only exception, which has become a source of packaging problems as of late. This was apparently an oversight in the original implementation. Closes: #854438 + - Dpkg::Vendor::Debian: Add fixfilepath support to reproducible feature. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/man/dpkg-buildflags.man b/man/dpkg-buildflags.man index 7712c5576..ba18dbbb7 100644 --- a/man/dpkg-buildflags.man +++ b/man/dpkg-buildflags.man @@ -476,6 +476,17 @@ This will cause warnings when the \fB__TIME__\fP, \fB__DATE__\fP and \fB__TIMESTAMP__\fP macros are used. . .TP +.B fixfilepath +This setting (disabled by default) adds +.BI \-ffile\-prefix\-map= BUILDPATH =. +to \fBCFLAGS\fP, \fBCXXFLAGS\fP, \fBOBJCFLAGS\fP, \fBOBJCXXFLAGS\fP, +\fBGCJFLAGS\fP, \fBFFLAGS\fP and \fBFCFLAGS\fP where \fBBUILDPATH\fP is +set to the top-level directory of the package being built. +This has the effect of removing the build path from any generated file. + +If both \fBfixdebugpath\fP and \fBfixfilepath\fP are set, this option +takes precedence, because it is a superset of the former. +.TP .B fixdebugpath This setting (enabled by default) adds .BI \-fdebug\-prefix\-map= BUILDPATH =. diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 1e8f24397..4bcf120e0 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -100,6 +100,7 @@ sub _add_build_flags { }, reproducible => { timeless => 1, + fixfilepath => 0, fixdebugpath => 1, }, sanitize => { @@ -205,7 +206,8 @@ sub _add_build_flags { my $build_path; # Mask features that might have an unsafe usage. - if ($use_feature{reproducible}{fixdebugpath}) { + if ($use_feature{reproducible}{fixfilepath} or + $use_feature{reproducible}{fixdebugpath}) { require Cwd; $build_path = $ENV{DEB_BUILD_PATH} || Cwd::cwd(); @@ -214,6 +216,7 @@ sub _add_build_flags { # so that we do not need to worry about escaping the characters # on output. if ($build_path =~ m/[^-+:.0-9a-zA-Z~\/_]/) { + $use_feature{reproducible}{fixfilepath} = 0; $use_feature{reproducible}{fixdebugpath} = 0; } } @@ -223,9 +226,19 @@ sub _add_build_flags { $flags->append('CPPFLAGS', '-Wdate-time'); } - # Avoid storing the build path in the debug symbols. - if ($use_feature{reproducible}{fixdebugpath}) { - my $map = '-fdebug-prefix-map=' . $build_path . '=.'; + # Avoid storing the build path in the binaries. + if ($use_feature{reproducible}{fixfilepath} or + $use_feature{reproducible}{fixdebugpath}) { + my $map; + + # -ffile-prefix-map is a superset of -fdebug-prefix-map, prefer it + # if both are set. + if ($use_feature{reproducible}{fixfilepath}) { + $map = '-ffile-prefix-map=' . $build_path . '=.'; + } else { + $map = '-fdebug-prefix-map=' . $build_path . '=.'; + } + $flags->append('CFLAGS', $map); $flags->append('CXXFLAGS', $map); $flags->append('OBJCFLAGS', $map); diff --git a/scripts/t/Dpkg_BuildFlags.t b/scripts/t/Dpkg_BuildFlags.t index 776fdf1a4..b087e0ab2 100644 --- a/scripts/t/Dpkg_BuildFlags.t +++ b/scripts/t/Dpkg_BuildFlags.t @@ -66,6 +66,7 @@ my %known_features = ( ) ], reproducible => [ qw( fixdebugpath + fixfilepath timeless ) ], sanitize => [ qw( -- cgit v1.2.3 From 37030e02cab5efe710834268f3d4ea426ec4a99a Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 18 Sep 2018 23:34:31 +0200 Subject: Dpkg::Dist::Files: Add support for file attributes This will make it possible to track key/value attributes for each file, so that we can track interesting information and pass it to the various programs parsing the debian/files file. --- debian/changelog | 1 + man/deb-src-files.man | 7 +++++++ scripts/Dpkg/Dist/Files.pm | 17 ++++++++++++++--- scripts/t/Dpkg_Dist_Files.t | 31 ++++++++++++++++++++++--------- scripts/t/Dpkg_Dist_Files/files-byhand | 4 ++-- 5 files changed, 46 insertions(+), 14 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 5f45df110..5b00463da 100644 --- a/debian/changelog +++ b/debian/changelog @@ -169,6 +169,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium packaging problems as of late. This was apparently an oversight in the original implementation. Closes: #854438 - Dpkg::Vendor::Debian: Add fixfilepath support to reproducible feature. + - Dpkg::Dist::Files: Add support for file attributes. * Documentation: - Update gettext minimal version in README. - Add a missing dot on the dpkg-buildflags(1) «lfs» feature paragraph. diff --git a/man/deb-src-files.man b/man/deb-src-files.man index 39269aacd..cc8abda52 100644 --- a/man/deb-src-files.man +++ b/man/deb-src-files.man @@ -33,6 +33,9 @@ The \fIdebian/files\fP file has a simple whitespace-delimited format. .I filename .I section .I priority +[ +.I keyword=value\&...\& +] .in -5 .PP .I filename @@ -43,6 +46,10 @@ and .I priority correspond to the respective control fields available in the .deb. The allowed values are specific to each distribution archive. +.PP +.I keyword=value\&...\& +corresponds to an optional whitespace-delimited list of attributes for this +entry. . .SH NOTES This file is not intended to be modified directly, please use one of diff --git a/scripts/Dpkg/Dist/Files.pm b/scripts/Dpkg/Dist/Files.pm index c2c426bd9..28f9d9a7a 100644 --- a/scripts/Dpkg/Dist/Files.pm +++ b/scripts/Dpkg/Dist/Files.pm @@ -81,12 +81,14 @@ sub parse { my $file; - if (m/^(\S+) (\S+) (\S+)$/) { + if (m/^(\S+) (\S+) (\S+)((?:\s+[0-9a-z-]+=\S+)*)$/) { $file = $self->parse_filename($1); error(g_('badly formed package name in files list file, line %d'), $.) unless defined $file; $file->{section} = $2; $file->{priority} = $3; + my $attrs = $4; + $file->{attrs} = { map { split /=/ } split ' ', $attrs }; } else { error(g_('badly formed line in files list file, line %d'), $.); } @@ -131,12 +133,13 @@ sub get_file { } sub add_file { - my ($self, $filename, $section, $priority) = @_; + my ($self, $filename, $section, $priority, %attrs) = @_; my $file = $self->parse_filename($filename); error(g_('invalid filename %s'), $filename) unless defined $file; $file->{section} = $section; $file->{priority} = $priority; + $file->{attrs} = \%attrs; $self->{files}->{$filename} = $file; @@ -171,7 +174,15 @@ sub output { foreach my $filename (sort keys %{$self->{files}}) { my $file = $self->{files}->{$filename}; - my $entry = "$filename $file->{section} $file->{priority}\n"; + my $entry = "$filename $file->{section} $file->{priority}"; + + if (exists $file->{attrs}) { + foreach my $attr (sort keys %{$file->{attrs}}) { + $entry .= " $attr=$file->{attrs}->{$attr}"; + } + } + + $entry .= "\n"; print { $fh } $entry if defined $fh; $str .= $entry; diff --git a/scripts/t/Dpkg_Dist_Files.t b/scripts/t/Dpkg_Dist_Files.t index 44d42d058..e7d6a5da6 100644 --- a/scripts/t/Dpkg_Dist_Files.t +++ b/scripts/t/Dpkg_Dist_Files.t @@ -29,11 +29,13 @@ my %expected = ( filename => 'pkg-src_4:2.0+1A~rc1-1.dsc', section => 'source', priority => 'extra', + attrs => {}, }, 'pkg-src_4:2.0+1A~rc1-1.tar.xz' => { filename => 'pkg-src_4:2.0+1A~rc1-1.tar.xz', section => 'source', priority => 'extra', + attrs => {}, }, 'pkg-templ_1.2.3_arch.type' => { filename => 'pkg-templ_1.2.3_arch.type', @@ -43,6 +45,7 @@ my %expected = ( arch => 'arch', section => 'section', priority => 'priority', + attrs => {}, }, 'pkg-arch_2.0.0_amd64.deb' => { filename => 'pkg-arch_2.0.0_amd64.deb', @@ -52,6 +55,7 @@ my %expected = ( arch => 'amd64', section => 'admin', priority => 'required', + attrs => {}, }, 'pkg-indep_0.0.1-2_all.deb' => { filename => 'pkg-indep_0.0.1-2_all.deb', @@ -61,26 +65,35 @@ my %expected = ( arch => 'all', section => 'net', priority => 'standard', + attrs => {}, }, 'other_0.txt' => { filename => 'other_0.txt', section => 'text', priority => 'optional', + attrs => { + 'mime-type' => 'text/plain', + }, }, 'BY-HAND-file' => { filename => 'BY-HAND-file', section => 'webdocs', priority => 'optional', + attrs => { + 'by-hand' => 'true' + }, }, 'another:filename' => { filename => 'another:filename', section => 'by-hand', priority => 'extra', + attrs => {}, }, 'added-on-the-fly' => { filename => 'added-on-the-fly', section => 'void', priority => 'wish', + attrs => {}, }, ); @@ -88,8 +101,8 @@ my $dist = Dpkg::Dist::Files->new(); $dist->load("$datadir/files-byhand") or error('cannot parse file'); $expected = <<'FILES'; -BY-HAND-file webdocs optional -other_0.txt text optional +BY-HAND-file webdocs optional by-hand=true +other_0.txt text optional mime-type=text/plain pkg-arch_2.0.0_amd64.deb admin required pkg-indep_0.0.1-2_all.deb net standard pkg-templ_1.2.3_arch.type section priority @@ -110,9 +123,9 @@ foreach my $f ($dist->get_files()) { is($dist->parse_filename('file%invalid'), undef, 'invalid filename'); $expected = <<'FILES'; -BY-HAND-file webdocs optional +BY-HAND-file webdocs optional by-hand=true added-on-the-fly void wish -other_0.txt text optional +other_0.txt text optional mime-type=text/plain pkg-arch_2.0.0_amd64.deb void imperative pkg-templ_1.2.3_arch.type section priority FILES @@ -156,8 +169,8 @@ is_deeply($dist->get_file('another:filename'), is($dist->output, $expected, 'Added source files'); $expected = <<'FILES'; -BY-HAND-file webdocs optional -other_0.txt text optional +BY-HAND-file webdocs optional by-hand=true +other_0.txt text optional mime-type=text/plain pkg-arch_2.0.0_amd64.deb admin required pkg-frag-a_0.0_arch.type section priority pkg-frag-b_0.0_arch.type section priority @@ -181,8 +194,8 @@ $dist->filter(remove => sub { $_[0]->{priority} eq 'optional' }); is($dist->output(), $expected, 'Filter remove priority optional'); $expected = <<'FILES'; -BY-HAND-file webdocs optional -other_0.txt text optional +BY-HAND-file webdocs optional by-hand=true +other_0.txt text optional mime-type=text/plain FILES $dist->reset(); @@ -191,7 +204,7 @@ $dist->filter(keep => sub { $_[0]->{priority} eq 'optional' }); is($dist->output(), $expected, 'Filter keep priority optional'); $expected = <<'FILES'; -BY-HAND-file webdocs optional +BY-HAND-file webdocs optional by-hand=true FILES $dist->reset(); diff --git a/scripts/t/Dpkg_Dist_Files/files-byhand b/scripts/t/Dpkg_Dist_Files/files-byhand index ac45d4610..416b14fb8 100644 --- a/scripts/t/Dpkg_Dist_Files/files-byhand +++ b/scripts/t/Dpkg_Dist_Files/files-byhand @@ -1,5 +1,5 @@ pkg-templ_1.2.3_arch.type section priority pkg-arch_2.0.0_amd64.deb admin required pkg-indep_0.0.1-2_all.deb net standard -other_0.txt text optional -BY-HAND-file webdocs optional +other_0.txt text optional mime-type=text/plain +BY-HAND-file webdocs optional by-hand=true -- cgit v1.2.3 From a7901786002cf4bd9f1dfbf3e4d844fc27478a8b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 18 Sep 2018 23:34:59 +0200 Subject: dpkg-parsechangelog: Add new --reverse option This option will make the output be in reverse order. --- debian/changelog | 2 ++ man/dpkg-parsechangelog.man | 6 +++++- scripts/Dpkg/Changelog.pm | 9 +++++---- scripts/Dpkg/Changelog/Parse.pm | 2 +- scripts/dpkg-parsechangelog.pl | 3 +++ scripts/t/Dpkg_Changelog.t | 6 +++++- 6 files changed, 21 insertions(+), 7 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 6e18c2587..10d681f61 100644 --- a/debian/changelog +++ b/debian/changelog @@ -98,6 +98,8 @@ dpkg (1.19.1) UNRELEASED; urgency=medium * Switch dpkg-gencontrol and dpkg-genchanges to track automatically generated artifacts by using the Auto-Built-Package field from the binary package instead of hardcoding package name patterns (such as «-dbgsym$»). + * Add new --reverse option to dpkg-parsechangelog, to list the changelog + entries in reverse order. * Architecture support: - Add support for riscv64 CPU. Closes: #822914 Thanks to Manuel A. Fernandez Montecelo diff --git a/man/dpkg-parsechangelog.man b/man/dpkg-parsechangelog.man index fd73fc8db..0a46394f8 100644 --- a/man/dpkg-parsechangelog.man +++ b/man/dpkg-parsechangelog.man @@ -74,7 +74,7 @@ Set the output format. Currently supported values are option existed) and the default. It consists of one paragraph in Debian control format (see \fBdeb\-control\fP(5)). If more than one entry is requested, then most fields are taken from the -most recent entry, except otherwise stated: +first entry (usually the most recent entry), except otherwise stated: .RS .TP .BI Source: " pkg-name" @@ -122,6 +122,10 @@ The \fBrfc822\fP format uses the same fields but outputs a separate paragraph for each changelog entry so that all metadata for each entry is preserved. .TP +.B \-\-reverse +Include all changes in reverse order (since dpkg 1.19.1). +Note: for the \fBdpkg\fP format the first entry will be the most ancient entry. +.TP .B \-\-all Include all changes. Note: other options have no effect when this is in use. .TP diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index 35e48ef02..39353fb5c 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -332,11 +332,12 @@ sub get_range { my ($self, $range) = @_; $range //= {}; my $res = $self->_data_range($range); - if (defined $res) { - return @$res if wantarray; - return $res; + return unless defined $res; + if (wantarray) { + return reverse @{$res} if $range->{reverse}; + return @{$res}; } else { - return; + return $res; } } diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm index 28bb6892a..91da43ab2 100644 --- a/scripts/Dpkg/Changelog/Parse.pm +++ b/scripts/Dpkg/Changelog/Parse.pm @@ -152,7 +152,7 @@ sub _changelog_parse { $options{format} //= 'dpkg'; $options{compression} //= $options{file} ne 'debian/changelog'; - my @range_opts = qw(since until from to offset count all); + my @range_opts = qw(since until from to offset count reverse all); $options{all} = 1 if exists $options{all}; if (none { defined $options{$_} } @range_opts) { $options{count} = 1; diff --git a/scripts/dpkg-parsechangelog.pl b/scripts/dpkg-parsechangelog.pl index 86c30b451..3d14c4219 100755 --- a/scripts/dpkg-parsechangelog.pl +++ b/scripts/dpkg-parsechangelog.pl @@ -56,6 +56,7 @@ sub usage { "Parser options: --format set output format (defaults to 'dpkg'). + --reverse include all changes in reverse order. --all include all changes. -s, --since include all changes later than . -v ditto. @@ -88,6 +89,8 @@ while (@ARGV) { $options{changelogformat} =~ m/^([0-9a-z]+)$/; } elsif ($arg eq '--format') { $options{format} = shift; + } elsif ($arg eq '--reverse') { + $options{reverse} = 1; } elsif ($arg eq '-l' or $arg eq '--file') { $options{file} = shift; usageerr(g_('missing changelog filename')) diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t index ed9f8a965..8aa1bfc45 100644 --- a/scripts/t/Dpkg_Changelog.t +++ b/scripts/t/Dpkg_Changelog.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 94; +use Test::More tests => 96; use Test::Dpkg qw(:paths); use File::Basename; @@ -81,6 +81,10 @@ foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields", count => 3, versions => [ '2:2.0-1', '1:2.0~rc2-3', '1:2.0~rc2-2' ], name => 'positive count'); + check_options(%ref, range => { count => 3, reverse => 1 }, + count => 3, + versions => [ '1:2.0~rc2-2', '1:2.0~rc2-3', '2:2.0-1' ], + name => 'positive reverse count'); check_options(%ref, range => { count => -3 }, count => 3, versions => [ -- cgit v1.2.3 From 2848db123e1452d2c71840b7c00ca198c3626d4e Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sat, 15 Sep 2018 16:10:29 -0700 Subject: perl: Replace all calls to Cwd::cwd with Cwd::getcwd The former calls /bin/pwd, while the latter uses the getcwd() syscall directly. Signed-off-by: Guillem Jover --- debian/changelog | 4 ++++ doc/lcov-inject.pl | 2 +- lib/dpkg/t/t-tarextract.t | 2 +- lib/dpkg/t/t-treewalk.t | 2 +- scripts/Dpkg/Vendor/Debian.pm | 2 +- scripts/dpkg-genbuildinfo.pl | 2 +- scripts/dpkg-source.pl | 2 +- scripts/t/Dpkg_Shlibs.t | 2 +- 8 files changed, 11 insertions(+), 7 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 10d681f61..3f8de197d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -296,6 +296,10 @@ dpkg (1.19.1) UNRELEASED; urgency=medium - Delete fixup lines from i18nspector output instead of emptying them. - Add new codespell author test. + [ Josh Triplett ] + * Perl: Replace all calls to Cwd::cwd with Cwd::getcwd; the former calls + /bin/pwd, while the latter uses the getcwd() syscall directly. + [ Updated programs translations ] * Dutch (Frans Spiesschaert). Closes: #881401 * German (Sven Joachim). diff --git a/doc/lcov-inject.pl b/doc/lcov-inject.pl index a74c8010d..12b78bd9a 100755 --- a/doc/lcov-inject.pl +++ b/doc/lcov-inject.pl @@ -25,7 +25,7 @@ use Cwd; use Devel::Cover::DB; my $dir = 'scripts'; -my $cwd = cwd(); +my $cwd = getcwd(); chdir $dir or die "cannot switch to $dir\n"; diff --git a/lib/dpkg/t/t-tarextract.t b/lib/dpkg/t/t-tarextract.t index 25916bb8d..5fb9afa09 100755 --- a/lib/dpkg/t/t-tarextract.t +++ b/lib/dpkg/t/t-tarextract.t @@ -119,7 +119,7 @@ TAR make_path($tmpdir); - my $cwd = cwd(); + my $cwd = getcwd(); # Check generated tarballs. foreach my $type (qw(v7 ustar oldgnu gnu)) { diff --git a/lib/dpkg/t/t-treewalk.t b/lib/dpkg/t/t-treewalk.t index dcde7901e..6f379c81b 100755 --- a/lib/dpkg/t/t-treewalk.t +++ b/lib/dpkg/t/t-treewalk.t @@ -45,7 +45,7 @@ sub make_file { # Populate the tree hierarchy. sub make_tree { my ($dirtree) = @_; - my $cwd = cwd(); + my $cwd = getcwd(); make_path($dirtree); chdir $dirtree; diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 4bcf120e0..7d4b6d802 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -210,7 +210,7 @@ sub _add_build_flags { $use_feature{reproducible}{fixdebugpath}) { require Cwd; - $build_path = $ENV{DEB_BUILD_PATH} || Cwd::cwd(); + $build_path = $ENV{DEB_BUILD_PATH} || Cwd::getcwd(); # If we have any unsafe character in the path, disable the flag, # so that we do not need to worry about escaping the characters diff --git a/scripts/dpkg-genbuildinfo.pl b/scripts/dpkg-genbuildinfo.pl index 96b06093a..fe296506e 100755 --- a/scripts/dpkg-genbuildinfo.pl +++ b/scripts/dpkg-genbuildinfo.pl @@ -423,7 +423,7 @@ if ($use_feature{kernel}) { $fields->{'Build-Kernel-Version'} = "$kern_rel $kern_ver"; } -my $cwd = cwd(); +my $cwd = getcwd(); if ($use_feature{path}) { $fields->{'Build-Path'} = $cwd; } else { diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 107408d79..6a4825d22 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -118,7 +118,7 @@ if (defined($options{opmode}) && } if ($dir eq '.') { # . is never correct, adjust automatically - $dir = basename(cwd()); + $dir = basename(getcwd()); chdir '..' or syserr(g_("unable to chdir to '%s'"), '..'); } # --format options are not allowed, they would take precedence diff --git a/scripts/t/Dpkg_Shlibs.t b/scripts/t/Dpkg_Shlibs.t index 4dc98bb3f..a2b892d74 100644 --- a/scripts/t/Dpkg_Shlibs.t +++ b/scripts/t/Dpkg_Shlibs.t @@ -54,7 +54,7 @@ Dpkg::Shlibs::blank_library_paths(); # We want relative paths inside the ld.so.conf fragments to work, and $srcdir # is usually a relative path, so let's temporarily switch directory. # XXX: An alternative would be to make parse_ldso_conf relative path aware. -my $cwd = cwd(); +my $cwd = getcwd(); test_needs_srcdir_switch(); Dpkg::Shlibs::parse_ldso_conf('t/Dpkg_Shlibs/ld.so.conf'); chdir($cwd); -- cgit v1.2.3 From 2d3a3fd28050ca76be4322e2d44b13627c0c5f72 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 29 Sep 2018 23:32:34 +0200 Subject: Dpkg::OpenPGP: Ignore Version field in enarmored output This will contain different data depending on the program used. We do not really care about that, later versions of GnuPG have stopped emitting it, and it makes the test suite fail when using GnuPG 1.x. Fixes: https://rt.cpan.org/Public/Bug/Display.html?id=127217 --- debian/changelog | 3 +++ scripts/Dpkg/OpenPGP.pm | 1 + 2 files changed, 4 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 7406d5bde..1f33be708 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,9 @@ dpkg (1.19.2) UNRELEASED; urgency=medium [ Guillem Jover ] + * Perl modules: + - Dpkg::OpenPGP: Ignore Version field in enarmored output. + Fixes CPAN#127217. * Documentation: - dpkg-buildpackage(1): Clarify --build=source explanation. - dsc(5): Clarify what “flattened” means in Testsuite-Triggers. diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm index 8d85e845d..210a36f23 100644 --- a/scripts/Dpkg/OpenPGP.pm +++ b/scripts/Dpkg/OpenPGP.pm @@ -61,6 +61,7 @@ sub openpgp_sig_to_asc open my $fh_gpg, '-|', 'gpg', '-o', '-', '--enarmor', $sig or syserr(g_('cannot execute %s program'), 'gpg'); while (my $line = <$fh_gpg>) { + next if $line =~ m/^Version: /; next if $line =~ m/^Comment: /; $line =~ s/ARMORED FILE/SIGNATURE/; -- cgit v1.2.3 From f6c46ce78c7e3f5504ce5d18a16c5482597716e3 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 29 Sep 2018 23:34:32 +0200 Subject: Dpkg::OpenPGP: Do not read the gpg user configuration file --- debian/changelog | 1 + scripts/Dpkg/OpenPGP.pm | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 1f33be708..0ed0de87a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,7 @@ dpkg (1.19.2) UNRELEASED; urgency=medium * Perl modules: - Dpkg::OpenPGP: Ignore Version field in enarmored output. Fixes CPAN#127217. + - Dpkg::OpenPGP: Do not read the gpg user configuration file. * Documentation: - dpkg-buildpackage(1): Clarify --build=source explanation. - dsc(5): Clarify what “flattened” means in Testsuite-Triggers. diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm index 210a36f23..f719e6e4e 100644 --- a/scripts/Dpkg/OpenPGP.pm +++ b/scripts/Dpkg/OpenPGP.pm @@ -56,9 +56,11 @@ sub openpgp_sig_to_asc warning(g_('cannot OpenPGP ASCII armor signature file due to missing gpg')); } + my @gpg_opts = qw(--no-options); + open my $fh_asc, '>', $asc or syserr(g_('cannot create signature file %s'), $asc); - open my $fh_gpg, '-|', 'gpg', '-o', '-', '--enarmor', $sig + open my $fh_gpg, '-|', 'gpg', @gpg_opts, '-o', '-', '--enarmor', $sig or syserr(g_('cannot execute %s program'), 'gpg'); while (my $line = <$fh_gpg>) { next if $line =~ m/^Version: /; -- cgit v1.2.3 From ffe3d7aeed7e7eb9a1c22d45fd0e5c2af2c8bcad Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 16 Sep 2018 23:42:08 +0200 Subject: Dpkg::Source::Functions: Reimplement is_binary() w/o using diff(1) The check is very simple, and can be done w/o requiring calling diff(1) for each input file. This makes the code shorter, more portable, and should be faster in the non-binary cases. --- debian/changelog | 1 + scripts/Dpkg/Source/Functions.pm | 31 ++++++++----------------------- 2 files changed, 9 insertions(+), 23 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 4d7e8f1ab..fd83782c3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ dpkg (1.19.2) UNRELEASED; urgency=medium - Dpkg::OpenPGP: Ignore Version field in enarmored output. Fixes CPAN#127217. - Dpkg::OpenPGP: Do not read the gpg user configuration file. + - Dpkg::Source::Functions: Reimplement is_binary() w/o using diff(1). * Documentation: - dpkg-buildpackage(1): Clarify --build=source explanation. - dsc(5): Clarify what “flattened” means in Testsuite-Triggers. diff --git a/scripts/Dpkg/Source/Functions.pm b/scripts/Dpkg/Source/Functions.pm index 262b80ad1..3435f6c5a 100644 --- a/scripts/Dpkg/Source/Functions.pm +++ b/scripts/Dpkg/Source/Functions.pm @@ -110,30 +110,15 @@ sub fs_time($) { sub is_binary($) { my $file = shift; - # TODO: might want to reimplement what diff does, aka checking if the - # file contains \0 in the first 4Kb of data + # Perform the same check as diff(1), look for a NUL character in the first + # 4 KiB of the file. + open my $fh, '<', $file + or syserr(g_('cannot open file %s for binary detection'), $file); + read $fh, my $buf, 4096, 0; + my $res = index $buf, "\0"; + close $fh; - # Use diff to check if it's a binary file - my $diffgen; - my $diff_pid = spawn( - exec => [ 'diff', '-u', '--', '/dev/null', $file ], - env => { LC_ALL => 'C', LANG => 'C', TZ => 'UTC0' }, - to_pipe => \$diffgen, - ); - my $result = 0; - local $_; - while (<$diffgen>) { - if (m/^(?:binary|[^-+\@ ].*\bdiffer\b)/i) { - $result = 1; - last; - } elsif (m/^[-+\@ ]/) { - $result = 0; - last; - } - } - close($diffgen) or syserr('close on diff pipe'); - wait_child($diff_pid, nocheck => 1, cmdline => "diff -u -- /dev/null $file"); - return $result; + return $res >= 0; } 1; -- cgit v1.2.3 From 837ecfdac680369ce71d96748a8a4762a414f654 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 16 Sep 2018 23:47:10 +0200 Subject: Dpkg::Source::Package::V2: Split BinaryFiles module into its own file --- debian/changelog | 2 + scripts/Dpkg/Source/BinaryFiles.pm | 108 +++++++++++++++++++++++++++++++++++++ scripts/Dpkg/Source/Package/V2.pm | 87 ++---------------------------- scripts/Makefile.am | 1 + scripts/po/POTFILES.in | 1 + 5 files changed, 115 insertions(+), 84 deletions(-) create mode 100644 scripts/Dpkg/Source/BinaryFiles.pm (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index fd83782c3..139a287f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,8 @@ dpkg (1.19.2) UNRELEASED; urgency=medium Fixes CPAN#127217. - Dpkg::OpenPGP: Do not read the gpg user configuration file. - Dpkg::Source::Functions: Reimplement is_binary() w/o using diff(1). + - Dpkg::Source::Package::V2: Split the BinaryFiles module into its own + file, and give it a more generic name (Dpkg::Source::BinaryFiles). * Documentation: - dpkg-buildpackage(1): Clarify --build=source explanation. - dsc(5): Clarify what “flattened” means in Testsuite-Triggers. diff --git a/scripts/Dpkg/Source/BinaryFiles.pm b/scripts/Dpkg/Source/BinaryFiles.pm new file mode 100644 index 000000000..c503e42b6 --- /dev/null +++ b/scripts/Dpkg/Source/BinaryFiles.pm @@ -0,0 +1,108 @@ +# Copyright © 2008-2011 Raphaël Hertzog +# Copyright © 2008-2015 Guillem Jover +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Dpkg::Source::BinaryFiles; + +use strict; +use warnings; + +our $VERSION = '0.01'; + +use File::Path qw(make_path); +use File::Spec; + +use Dpkg::ErrorHandling; +use Dpkg::Gettext; + +sub new { + my ($this, $dir) = @_; + my $class = ref($this) || $this; + + my $self = { + dir => $dir, + allowed_binaries => {}, + seen_binaries => {}, + include_binaries_path => + File::Spec->catfile($dir, 'debian', 'source', 'include-binaries'), + }; + bless $self, $class; + $self->load_allowed_binaries(); + return $self; +} + +sub new_binary_found { + my ($self, $path) = @_; + + $self->{seen_binaries}{$path} = 1; +} + +sub load_allowed_binaries { + my $self = shift; + my $incbin_file = $self->{include_binaries_path}; + + if (-f $incbin_file) { + open my $incbin_fh, '<', $incbin_file + or syserr(g_('cannot read %s'), $incbin_file); + while (<$incbin_fh>) { + chomp; + s/^\s*//; + s/\s*$//; + next if /^#/ or length == 0; + $self->{allowed_binaries}{$_} = 1; + } + close $incbin_fh; + } +} + +sub binary_is_allowed { + my ($self, $path) = @_; + + return 1 if exists $self->{allowed_binaries}{$path}; + return 0; +} + +sub update_debian_source_include_binaries { + my $self = shift; + + my @unknown_binaries = $self->get_unknown_binaries(); + return unless scalar @unknown_binaries; + + my $incbin_file = $self->{include_binaries_path}; + make_path(File::Spec->catdir($self->{dir}, 'debian', 'source')); + open my $incbin_fh, '>>', $incbin_file + or syserr(g_('cannot write %s'), $incbin_file); + foreach my $binary (@unknown_binaries) { + print { $incbin_fh } "$binary\n"; + info(g_('adding %s to %s'), $binary, 'debian/source/include-binaries'); + $self->{allowed_binaries}{$binary} = 1; + } + close $incbin_fh; +} + +sub get_unknown_binaries { + my $self = shift; + + return grep { not $self->binary_is_allowed($_) } $self->get_seen_binaries(); +} + +sub get_seen_binaries { + my $self = shift; + my @seen = sort keys %{$self->{seen_binaries}}; + + return @seen; +} + +1; diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index 2c8529bc1..8be647d7b 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -37,6 +37,7 @@ use Dpkg::Path qw(find_command); use Dpkg::Compression; use Dpkg::Source::Archive; use Dpkg::Source::Patch; +use Dpkg::Source::BinaryFiles; use Dpkg::Exit qw(push_exit_handler pop_exit_handler); use Dpkg::Source::Functions qw(erasedir chmod_if_needed is_binary fs_time); use Dpkg::Vendor qw(run_vendor_hook); @@ -517,7 +518,7 @@ sub do_build { my $basenamerev = $self->get_basename(1); # Check if the debian directory contains unwanted binary files - my $binaryfiles = Dpkg::Source::Package::V2::BinaryFiles->new($dir); + my $binaryfiles = Dpkg::Source::BinaryFiles->new($dir); my $unwanted_binaries = 0; my $check_binary = sub { if (-f and is_binary($_)) { @@ -714,7 +715,7 @@ sub do_commit { error(g_("patch file '%s' doesn't exist"), $tmpdiff) if not -e $tmpdiff; } - my $binaryfiles = Dpkg::Source::Package::V2::BinaryFiles->new($dir); + my $binaryfiles = Dpkg::Source::BinaryFiles->new($dir); my $handle_binary = sub { my ($self, $old, $new, %opts) = @_; my $fn = File::Spec->abs2rel($new, $dir); @@ -757,86 +758,4 @@ sub do_commit { info(g_('local changes have been recorded in a new patch: %s'), $patch); } -package Dpkg::Source::Package::V2::BinaryFiles; - -use Dpkg::ErrorHandling; -use Dpkg::Gettext; - -use File::Path qw(make_path); -use File::Spec; - -sub new { - my ($this, $dir) = @_; - my $class = ref($this) || $this; - - my $self = { - dir => $dir, - allowed_binaries => {}, - seen_binaries => {}, - include_binaries_path => - File::Spec->catfile($dir, 'debian', 'source', 'include-binaries'), - }; - bless $self, $class; - $self->load_allowed_binaries(); - return $self; -} - -sub new_binary_found { - my ($self, $path) = @_; - - $self->{seen_binaries}{$path} = 1; -} - -sub load_allowed_binaries { - my $self = shift; - my $incbin_file = $self->{include_binaries_path}; - if (-f $incbin_file) { - open(my $incbin_fh, '<', $incbin_file) - or syserr(g_('cannot read %s'), $incbin_file); - while (<$incbin_fh>) { - chomp; - s/^\s*//; - s/\s*$//; - next if /^#/ or length == 0; - $self->{allowed_binaries}{$_} = 1; - } - close($incbin_fh); - } -} - -sub binary_is_allowed { - my ($self, $path) = @_; - return 1 if exists $self->{allowed_binaries}{$path}; - return 0; -} - -sub update_debian_source_include_binaries { - my $self = shift; - - my @unknown_binaries = $self->get_unknown_binaries(); - return unless scalar(@unknown_binaries); - - my $incbin_file = $self->{include_binaries_path}; - make_path(File::Spec->catdir($self->{dir}, 'debian', 'source')); - open(my $incbin_fh, '>>', $incbin_file) - or syserr(g_('cannot write %s'), $incbin_file); - foreach my $binary (@unknown_binaries) { - print { $incbin_fh } "$binary\n"; - info(g_('adding %s to %s'), $binary, 'debian/source/include-binaries'); - $self->{allowed_binaries}{$binary} = 1; - } - close($incbin_fh); -} - -sub get_unknown_binaries { - my $self = shift; - return grep { not $self->binary_is_allowed($_) } $self->get_seen_binaries(); -} - -sub get_seen_binaries { - my $self = shift; - my @seen = sort keys %{$self->{seen_binaries}}; - return @seen; -} - 1; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index d8160749b..d7bd8d2f7 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -104,6 +104,7 @@ nobase_dist_perllib_DATA = \ Dpkg/Shlibs/SymbolFile.pm \ Dpkg/Shlibs/Cppfilt.pm \ Dpkg/Source/Archive.pm \ + Dpkg/Source/BinaryFiles.pm \ Dpkg/Source/Functions.pm \ Dpkg/Source/Package.pm \ Dpkg/Source/Package/V1.pm \ diff --git a/scripts/po/POTFILES.in b/scripts/po/POTFILES.in index 638fd8b97..a486b593d 100644 --- a/scripts/po/POTFILES.in +++ b/scripts/po/POTFILES.in @@ -72,6 +72,7 @@ scripts/Dpkg/Shlibs/Symbol.pm scripts/Dpkg/Shlibs/SymbolFile.pm scripts/Dpkg/Source/Archive.pm scripts/Dpkg/Source/Functions.pm +scripts/Dpkg/Source/BinaryFiles.pm scripts/Dpkg/Source/Package.pm scripts/Dpkg/Source/Package/V1.pm scripts/Dpkg/Source/Package/V2.pm -- cgit v1.2.3 From 76b05dce1342834fec1b3d9b6ff3fc33a33c1fb2 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 17 Sep 2018 00:12:56 +0200 Subject: Dpkg::Source::Package::V2: Move binary file detection to BinaryFiles module This makes it possible to reuse the code by other modules. --- debian/changelog | 2 ++ scripts/Dpkg/Source/BinaryFiles.pm | 53 ++++++++++++++++++++++++++++++++++++++ scripts/Dpkg/Source/Package/V2.pm | 50 +++++------------------------------ 3 files changed, 61 insertions(+), 44 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 139a287f6..73d76a09c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,8 @@ dpkg (1.19.2) UNRELEASED; urgency=medium - Dpkg::Source::Functions: Reimplement is_binary() w/o using diff(1). - Dpkg::Source::Package::V2: Split the BinaryFiles module into its own file, and give it a more generic name (Dpkg::Source::BinaryFiles). + - Dpkg::Source::Package::V2: Move binary file detection to BinaryFiles + module. * Documentation: - dpkg-buildpackage(1): Clarify --build=source explanation. - dsc(5): Clarify what “flattened” means in Testsuite-Triggers. diff --git a/scripts/Dpkg/Source/BinaryFiles.pm b/scripts/Dpkg/Source/BinaryFiles.pm index c503e42b6..48c84c8fc 100644 --- a/scripts/Dpkg/Source/BinaryFiles.pm +++ b/scripts/Dpkg/Source/BinaryFiles.pm @@ -21,11 +21,14 @@ use warnings; our $VERSION = '0.01'; +use Cwd; use File::Path qw(make_path); use File::Spec; +use File::Find; use Dpkg::ErrorHandling; use Dpkg::Gettext; +use Dpkg::Source::Functions qw(is_binary); sub new { my ($this, $dir) = @_; @@ -105,4 +108,54 @@ sub get_seen_binaries { return @seen; } +sub detect_binary_files { + my ($self, %opts) = @_; + + my $unwanted_binaries = 0; + my $check_binary = sub { + if (-f and is_binary($_)) { + my $fn = File::Spec->abs2rel($_, $self->{dir}); + $self->new_binary_found($fn); + unless ($opts{include_binaries} or $self->binary_is_allowed($fn)) { + errormsg(g_('unwanted binary file: %s'), $fn); + $unwanted_binaries++; + } + } + }; + my $exclude_glob = '{' . + join(',', map { s/,/\\,/rg } @{$opts{exclude_globs}}) . + '}'; + my $filter_ignore = sub { + # Filter out files that are not going to be included in the debian + # tarball due to ignores. + my %exclude; + my $reldir = File::Spec->abs2rel($File::Find::dir, $self->{dir}); + my $cwd = getcwd(); + # Apply the pattern both from the top dir and from the inspected dir + chdir $self->{dir} + or syserr(g_("unable to chdir to '%s'"), $self->{dir}); + $exclude{$_} = 1 foreach glob $exclude_glob; + chdir $cwd or syserr(g_("unable to chdir to '%s'"), $cwd); + chdir $File::Find::dir + or syserr(g_("unable to chdir to '%s'"), $File::Find::dir); + $exclude{$_} = 1 foreach glob $exclude_glob; + chdir $cwd or syserr(g_("unable to chdir to '%s'"), $cwd); + my @result; + foreach my $fn (@_) { + unless (exists $exclude{$fn} or exists $exclude{"$reldir/$fn"}) { + push @result, $fn; + } + } + return @result; + }; + find({ wanted => $check_binary, preprocess => $filter_ignore, + no_chdir => 1 }, File::Spec->catdir($self->{dir}, 'debian')); + error(P_('detected %d unwanted binary file (add it in ' . + 'debian/source/include-binaries to allow its inclusion).', + 'detected %d unwanted binary files (add them in ' . + 'debian/source/include-binaries to allow their inclusion).', + $unwanted_binaries), $unwanted_binaries) + if $unwanted_binaries; +} + 1; diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index 8be647d7b..fe9a1727d 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -39,7 +39,7 @@ use Dpkg::Source::Archive; use Dpkg::Source::Patch; use Dpkg::Source::BinaryFiles; use Dpkg::Exit qw(push_exit_handler pop_exit_handler); -use Dpkg::Source::Functions qw(erasedir chmod_if_needed is_binary fs_time); +use Dpkg::Source::Functions qw(erasedir chmod_if_needed fs_time); use Dpkg::Vendor qw(run_vendor_hook); use Dpkg::Control; use Dpkg::Changelog::Parse; @@ -519,49 +519,11 @@ sub do_build { # Check if the debian directory contains unwanted binary files my $binaryfiles = Dpkg::Source::BinaryFiles->new($dir); - my $unwanted_binaries = 0; - my $check_binary = sub { - if (-f and is_binary($_)) { - my $fn = File::Spec->abs2rel($_, $dir); - $binaryfiles->new_binary_found($fn); - unless ($include_binaries or $binaryfiles->binary_is_allowed($fn)) { - errormsg(g_('unwanted binary file: %s'), $fn); - $unwanted_binaries++; - } - } - }; - my $tar_ignore_glob = '{' . join(',', - map { s/,/\\,/rg } @{$self->{options}{tar_ignore}}) . '}'; - my $filter_ignore = sub { - # Filter out files that are not going to be included in the debian - # tarball due to ignores. - my %exclude; - my $reldir = File::Spec->abs2rel($File::Find::dir, $dir); - my $cwd = getcwd(); - # Apply the pattern both from the top dir and from the inspected dir - chdir $dir or syserr(g_("unable to chdir to '%s'"), $dir); - $exclude{$_} = 1 foreach glob($tar_ignore_glob); - chdir $cwd or syserr(g_("unable to chdir to '%s'"), $cwd); - chdir($File::Find::dir) - or syserr(g_("unable to chdir to '%s'"), $File::Find::dir); - $exclude{$_} = 1 foreach glob($tar_ignore_glob); - chdir $cwd or syserr(g_("unable to chdir to '%s'"), $cwd); - my @result; - foreach my $fn (@_) { - unless (exists $exclude{$fn} or exists $exclude{"$reldir/$fn"}) { - push @result, $fn; - } - } - return @result; - }; - find({ wanted => $check_binary, preprocess => $filter_ignore, - no_chdir => 1 }, File::Spec->catdir($dir, 'debian')); - error(P_('detected %d unwanted binary file (add it in ' . - 'debian/source/include-binaries to allow its inclusion).', - 'detected %d unwanted binary files (add them in ' . - 'debian/source/include-binaries to allow their inclusion).', - $unwanted_binaries), $unwanted_binaries) - if $unwanted_binaries; + + $binaryfiles->detect_binary_files( + exclude_globs => $self->{options}{tar_ignore}, + include_binaries => $include_binaries, + ); # Handle modified binary files detected by the auto-patch generation my $handle_binary = sub { -- cgit v1.2.3 From 853f59ec0468f72fa29811a8fe48fad91fab6083 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 23 Oct 2018 02:58:56 +0200 Subject: perl: Fix POD for Dpkg::Interface::Storable derived method implementations Document inherited methods. Document the return values. Note which arguments are optional. Reorder methods by their position in the stack. --- debian/changelog | 1 + scripts/Dpkg/Changelog.pm | 18 +++++++----------- scripts/Dpkg/Conf.pm | 10 +++++----- scripts/Dpkg/Control/HashCore.pm | 19 +++++++++---------- scripts/Dpkg/Control/Info.pm | 15 ++++++++------- scripts/Dpkg/Deps/Simple.pm | 38 ++++++++++++++++++++++++-------------- scripts/Dpkg/Index.pm | 25 ++++++++++++------------- scripts/Dpkg/Interface/Storable.pm | 4 ++-- scripts/Dpkg/Substvars.pm | 24 ++++++++++++------------ 9 files changed, 80 insertions(+), 74 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 7e5ea0e24..1178f6240 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - dpkg-query(1): Document the version introducing the -f option. - dpkg-architecture(1): Add reference to the TERMS section in the VARIABLES section. Prompted by Axel Beckert . + - Fix POD for Dpkg::Interface::Storable derived method implementations. * Code internals: - dpkg-maintscript-helper: Use an explicit escape instead of a literal backslash. diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index 39353fb5c..47752b911 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -74,12 +74,6 @@ sub new { return $self; } -=item $c->load($filename) - -Parse $filename as a changelog. - -=cut - =item $c->set_options(%opts) Change the value of some options. "verbose" (defaults to 1) defines @@ -443,11 +437,7 @@ sub abort_early { return; } -=item $c->save($filename) - -Save the changelog in the given file. - -=item $c->output() +=item $str = $c->output() =item "$c" @@ -476,6 +466,12 @@ sub output { return $str; } +=item $c->save($filename) + +Save the changelog in the given file. + +=cut + our ( @URGENCIES, %URGENCIES ); BEGIN { @URGENCIES = qw(low medium high critical emergency); diff --git a/scripts/Dpkg/Conf.pm b/scripts/Dpkg/Conf.pm index ca98cd3a7..5b98bbd8e 100644 --- a/scripts/Dpkg/Conf.pm +++ b/scripts/Dpkg/Conf.pm @@ -221,7 +221,7 @@ sub filter { @{$self->{options}}; } -=item $string = $conf->output($fh) +=item $string = $conf->output([$fh]) Write the options in the given filehandle (if defined) and return a string representation of the content (that would be) written. @@ -230,10 +230,6 @@ representation of the content (that would be) written. Return a string representation of the content. -=item $conf->save($file) - -Save the options in a file. - =cut sub output { @@ -249,6 +245,10 @@ sub output { return $ret; } +=item $conf->save($file) + +Save the options in a file. + =back =head1 CHANGES diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index e83522729..542069332 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -160,11 +160,6 @@ sub get_option { return $$self->{$k}; } -=item $c->load($file) - -Parse the content of $file. Exits in case of errors. Returns true if some -fields have been parsed. - =item $c->parse_error($file, $fmt, ...) Prints an error message and dies on syntax parse errors. @@ -284,6 +279,11 @@ sub parse { return defined($cf); } +=item $c->load($file) + +Parse the content of $file. Exits in case of errors. Returns true if some +fields have been parsed. + =item $c->find_custom_field($name) Scan the fields and look for a user specific field whose name matches the @@ -313,11 +313,6 @@ sub get_custom_field { return; } -=item $c->save($filename) - -Write the string representation of the control information to a -file. - =item $str = $c->output() =item "$c" @@ -386,6 +381,10 @@ sub output { return $str; } +=item $c->save($filename) + +Write the string representation of the control information to a file. + =item $c->set_output_order(@fields) Define the order in which fields will be displayed in the output() method. diff --git a/scripts/Dpkg/Control/Info.pm b/scripts/Dpkg/Control/Info.pm index a5eae8732..9b07eedbe 100644 --- a/scripts/Dpkg/Control/Info.pm +++ b/scripts/Dpkg/Control/Info.pm @@ -90,11 +90,6 @@ sub reset { $self->{packages} = []; } -=item $c->load($file) - -Load the content of $file. Exits in case of errors. If file is "-", it -loads from the standard input. - =item $c->parse($fh, $description) Parse a control file from the given filehandle. Exits in case of errors. @@ -129,6 +124,11 @@ sub parse { } } +=item $c->load($file) + +Load the content of $file. Exits in case of errors. If file is "-", it +loads from the standard input. + =item $c->[0] =item $c->get_source() @@ -182,9 +182,10 @@ sub get_packages { return @{$self->{packages}}; } -=item $c->output($filehandle) +=item $str = $c->output([$fh]) -Dump the content into a filehandle. +Return the content info into a string. If $fh is specified print it into +the filehandle. =cut diff --git a/scripts/Dpkg/Deps/Simple.pm b/scripts/Dpkg/Deps/Simple.pm index 0557c7cfc..4fa1ae8d5 100644 --- a/scripts/Dpkg/Deps/Simple.pm +++ b/scripts/Dpkg/Deps/Simple.pm @@ -149,20 +149,6 @@ sub reset { $self->{restrictions} = undef; } -=item $dep->parse($fh, $desc) - -Parses a line from a filehandle. - -=cut - -sub parse { - my ($self, $fh, $desc) = @_; - - my $line = <$fh>; - chomp $line; - return $self->parse_string($line); -} - =item $dep->parse_string($dep_string) Parses the dependency string and modifies internal properties to match the @@ -224,6 +210,24 @@ sub parse_string { } } +=item $dep->parse($fh, $desc) + +Parse a dependency line from a filehandle. + +=cut + +sub parse { + my ($self, $fh, $desc) = @_; + + my $line = <$fh>; + chomp $line; + return $self->parse_string($line); +} + +=item $dep->load($filename) + +Parse a dependency line from $filename. + =item $dep->output([$fh]) =item "$dep" @@ -257,6 +261,12 @@ sub output { return $res; } +=item $dep->save($filename) + +Save the dependency into the given $filename. + +=cut + # _arch_is_superset(\@p, \@q) # # Returns true if the arch list @p is a superset of arch list @q. diff --git a/scripts/Dpkg/Index.pm b/scripts/Dpkg/Index.pm index bcee6205b..682f16921 100644 --- a/scripts/Dpkg/Index.pm +++ b/scripts/Dpkg/Index.pm @@ -237,11 +237,6 @@ sub add { $self->{items}{$key} = $item; } -=item $index->load($file) - -Reads the file and creates all items parsed. Returns the number of items -parsed. Handles compressed files transparently based on their extensions. - =item $index->parse($fh, $desc) Reads the filehandle and creates all items parsed. When called multiple @@ -263,10 +258,10 @@ sub parse { return $i; } -=item $index->save($file) +=item $index->load($file) -Writes the content of the index in a file. Auto-compresses files -based on their extensions. +Reads the file and creates all items parsed. Returns the number of items +parsed. Handles compressed files transparently based on their extensions. =item $item = $index->new_item() @@ -404,17 +399,16 @@ sub sort { } } -=item $str = $index->output() +=item $str = $index->output([$fh]) =item "$index" -Get a string representation of the index. The Dpkg::Control objects are +Get a string representation of the index. The L objects are output in the order which they have been read or added except if the order have been changed with sort(). -=item $index->output($fh) - -Print the string representation of the index to a filehandle. +Print the string representation of the index to a filehandle if $fh has +been passed. =cut @@ -432,6 +426,11 @@ sub output { return $str; } +=item $index->save($file) + +Writes the content of the index in a file. Auto-compresses files +based on their extensions. + =back =head1 CHANGES diff --git a/scripts/Dpkg/Interface/Storable.pm b/scripts/Dpkg/Interface/Storable.pm index eb6078d3b..5ed308cf2 100644 --- a/scripts/Dpkg/Interface/Storable.pm +++ b/scripts/Dpkg/Interface/Storable.pm @@ -48,13 +48,13 @@ from Dpkg::Interface::Storable so that the methods provided can work. =over 4 -=item $obj->parse($fh, $desc) +=item $obj->parse($fh[, $desc]) This methods initialize the object with the data stored in the filehandle. $desc is optional and is a textual description of the filehandle used in error messages. -=item $string = $obj->output($fh) +=item $string = $obj->output([$fh]) This method returns a string representation of the object in $string and it writes the same string to $fh (if it's defined). diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index 650eae7fa..d2060efc5 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -183,10 +183,6 @@ sub no_warn { $self->mark_as_used($key); } -=item $s->load($file) - -Add new substitutions read from $file. - =item $s->parse($fh, $desc) Add new substitutions read from the filehandle. $desc is used to identify @@ -216,6 +212,10 @@ sub parse { return $count } +=item $s->load($file) + +Add new substitutions read from $file. + =item $s->set_version_substvars($sourceversion, $binaryversion) Defines ${binary:Version}, ${source:Version} and @@ -404,20 +404,15 @@ sub filter { } } -=item $s->save($file) - -Store all substitutions variables except the automatic ones in the -indicated file. - =item "$s" Return a string representation of all substitutions variables except the automatic ones. -=item $str = $s->output($fh) +=item $str = $s->output([$fh]) -Print all substitutions variables except the automatic ones in the -filehandle and return the content written. +Return all substitutions variables except the automatic ones. If $fh +is passed print them into the filehandle. =cut @@ -434,6 +429,11 @@ sub output { return $str; } +=item $s->save($file) + +Store all substitutions variables except the automatic ones in the +indicated file. + =back =head1 CHANGES -- cgit v1.2.3 From 1fa3e4360b4ebadef4f0f486fb4a029e6bbdc705 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 13 Oct 2018 10:00:39 +0200 Subject: Dpkg::Deps::Simple: Fix POD signature for new constructor --- debian/changelog | 1 + scripts/Dpkg/Deps/Simple.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 1178f6240..14970a692 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,6 +17,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - dpkg-architecture(1): Add reference to the TERMS section in the VARIABLES section. Prompted by Axel Beckert . - Fix POD for Dpkg::Interface::Storable derived method implementations. + - Dpkg::Deps::Simple(3): Fix POD signature for new constructor. * Code internals: - dpkg-maintscript-helper: Use an explicit escape instead of a literal backslash. diff --git a/scripts/Dpkg/Deps/Simple.pm b/scripts/Dpkg/Deps/Simple.pm index 4fa1ae8d5..efe635cec 100644 --- a/scripts/Dpkg/Deps/Simple.pm +++ b/scripts/Dpkg/Deps/Simple.pm @@ -88,7 +88,7 @@ use Dpkg::Gettext; use parent qw(Dpkg::Interface::Storable); -=item $dep = Dpkg::Deps::Simple->new(%opts); +=item $dep = Dpkg::Deps::Simple->new([$dep[, %opts]]); Creates a new object. Some options can be set through %opts: -- cgit v1.2.3 From e326eda15c84d0456aa2e1c22c996e89ef6c40f2 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 9 Dec 2018 23:06:29 +0100 Subject: Dpkg::Changelog::Debian: Preserve modelines at EOF We should keep these and consider them as pseudo-EOF markers, and stop processing once seen. [lamby@debian.org: - Initial test cases for dpkg-mergechangelogs functional tests. ] Closes: #916056 --- debian/changelog | 3 +++ man/deb-changelog.man | 10 +++++----- man/dpkg-mergechangelogs.man | 4 ++-- scripts/Dpkg/Changelog/Debian.pm | 8 ++++++-- scripts/Makefile.am | 1 + scripts/t/Dpkg_Changelog.t | 8 ++++++-- scripts/t/Dpkg_Changelog/stop-modeline | 13 +++++++++++++ scripts/t/merge_changelogs/ch-a | 2 ++ scripts/t/merge_changelogs/ch-b | 2 ++ scripts/t/merge_changelogs/ch-merged | 2 ++ scripts/t/merge_changelogs/ch-merged-basic | 2 ++ scripts/t/merge_changelogs/ch-merged-pr | 2 ++ scripts/t/merge_changelogs/ch-merged-pr-basic | 2 ++ scripts/t/merge_changelogs/ch-old | 2 ++ 14 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 scripts/t/Dpkg_Changelog/stop-modeline (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 14970a692..9a6e7a47d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,9 @@ dpkg (1.19.3) UNRELEASED; urgency=medium [ Guillem Jover ] + * Perl modules: + - Dpkg::Changelog::Debian: Preserve modelines at EOF. Closes: #916056 + Thanks to Chris Lamb for initial test cases. * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/man/deb-changelog.man b/man/deb-changelog.man index 6aaa5d2cf..c4485e045 100644 --- a/man/deb-changelog.man +++ b/man/deb-changelog.man @@ -142,12 +142,12 @@ The maintainer details and the date must be separated by exactly two spaces. .PP Any line that consists entirely (i.e., no leading whitespace) of \fB#\fP -or \fB/* */\fP style comments, RCS keywords, Vim modelines or Emacs local -variables should be ignored. +or \fB/* */\fP style comments or RCS keywords. .PP -Ancient changelog entries with other formats at the end of the file should -be accepted and preserved on output, but their contents might be otherwise -ignored and parsing stopped at that point. +Vim modelines or Emacs local variables, and ancient changelog entries with +other formats at the end of the file should be accepted and preserved on +output, but their contents might be otherwise ignored and parsing stopped +at that point. .PP The entire changelog must be encoded in UTF-8. .SH FILES diff --git a/man/dpkg-mergechangelogs.man b/man/dpkg-mergechangelogs.man index 9cda23ef0..4d6159c02 100644 --- a/man/dpkg-mergechangelogs.man +++ b/man/dpkg-mergechangelogs.man @@ -75,8 +75,8 @@ The accepted values are: \fB0\fP and \fB1\fP (default). .SH LIMITATIONS .P Anything that is not parsed by Dpkg::Changelog is lost during the merge. -This might include stuff like Vim modelines, Emacs variables, comments -which were not supposed to be there, etc. +This might include stuff like comments which were not supposed to be +there, etc. . .SH INTEGRATION WITH GIT .P diff --git a/scripts/Dpkg/Changelog/Debian.pm b/scripts/Dpkg/Changelog/Debian.pm index a44ac666c..937acb5e0 100644 --- a/scripts/Dpkg/Changelog/Debian.pm +++ b/scripts/Dpkg/Changelog/Debian.pm @@ -162,9 +162,13 @@ sub parse { $expect= START_CHANGES; @blanklines = (); } elsif (m/^(?:;;\s*)?Local variables:/io) { - last; # skip Emacs variables at end of file + # Save any trailing Emacs variables at end of file. + $self->set_unparsed_tail("$_\n" . (file_slurp($fh) // '')); + last; } elsif (m/^vim:/io) { - last; # skip Vim modelines at end of file + # Save any trailing Vim modelines at end of file. + $self->set_unparsed_tail("$_\n" . (file_slurp($fh) // '')); + last; } elsif (m/^\$\w+:.*\$/o) { next; # skip stuff that look like a RCS keyword } elsif (m/^\# /o) { diff --git a/scripts/Makefile.am b/scripts/Makefile.am index d7bd8d2f7..d68560173 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -311,6 +311,7 @@ test_data = \ t/Dpkg_Changelog/misplaced-tz \ t/Dpkg_Changelog/regressions \ t/Dpkg_Changelog/shadow \ + t/Dpkg_Changelog/stop-modeline \ t/Dpkg_Changelog/unreleased \ t/Dpkg_Checksums/empty \ t/Dpkg_Checksums/data-1 \ diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t index 8aa1bfc45..f487ff560 100644 --- a/scripts/t/Dpkg_Changelog.t +++ b/scripts/t/Dpkg_Changelog.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 96; +use Test::More tests => 102; use Test::Dpkg qw(:paths); use File::Basename; @@ -36,7 +36,7 @@ my $vendor = get_current_vendor(); ######################### foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields", - "$datadir/regressions", "$datadir/date-format") { + "$datadir/regressions", "$datadir/date-format", "$datadir/stop-modeline") { my $changes = Dpkg::Changelog::Debian->new(verbose => 0); $changes->load($file); @@ -346,6 +346,10 @@ Xb-Userfield2: foobar is($data[2]->get_timestamp(), 'Mon, 01 Jan 2000 00:00:00 +0000', 'get date w/ DoW, and zero timezone offset'); } + if ($file eq "$datadir/stop-modeline") { + is($changes->get_unparsed_tail(), "vim: et\n", + 'get unparsed modeline at EOF'); + } if ($file eq "$datadir/regressions") { my $f = ($changes->format_range('dpkg'))[0]; is("$f->{Version}", '0', 'version 0 correctly parsed'); diff --git a/scripts/t/Dpkg_Changelog/stop-modeline b/scripts/t/Dpkg_Changelog/stop-modeline new file mode 100644 index 000000000..5b8a7b438 --- /dev/null +++ b/scripts/t/Dpkg_Changelog/stop-modeline @@ -0,0 +1,13 @@ +modeline (2.0-1) unstable; urgency=low + + * Upload. + + -- Dpkg Developers Tue, 4 Oct 2005 01:49:05 +0200 + +modeline (1.0-1) unstable; urgency=low + + * Upload. + + -- Dpkg Developers Tue, 4 Oct 2005 01:48:05 +0200 + +vim: et diff --git a/scripts/t/merge_changelogs/ch-a b/scripts/t/merge_changelogs/ch-a index 02dad9397..ff5419d8d 100644 --- a/scripts/t/merge_changelogs/ch-a +++ b/scripts/t/merge_changelogs/ch-a @@ -90,3 +90,5 @@ test (1.0-1) unstable; urgency=low * Initial release. (Closes: #XXXXXX) -- Raphaël Hertzog Sun, 18 Apr 2010 17:37:46 +0200 + +vim: et diff --git a/scripts/t/merge_changelogs/ch-b b/scripts/t/merge_changelogs/ch-b index 9eb78699b..a74145f82 100644 --- a/scripts/t/merge_changelogs/ch-b +++ b/scripts/t/merge_changelogs/ch-b @@ -85,3 +85,5 @@ test (1.0-1) unstable; urgency=low * Initial release. (Closes: #XXXXXX) -- Raphaël Hertzog Sun, 18 Apr 2010 17:37:46 +0200 + +vim: et diff --git a/scripts/t/merge_changelogs/ch-merged b/scripts/t/merge_changelogs/ch-merged index c995f1cf9..29a985d16 100644 --- a/scripts/t/merge_changelogs/ch-merged +++ b/scripts/t/merge_changelogs/ch-merged @@ -111,3 +111,5 @@ test (1.0-1) unstable; urgency=low * Initial release. (Closes: #XXXXXX) -- Raphaël Hertzog Sun, 18 Apr 2010 17:37:46 +0200 + +vim: et diff --git a/scripts/t/merge_changelogs/ch-merged-basic b/scripts/t/merge_changelogs/ch-merged-basic index 6b054c353..f89fe1123 100644 --- a/scripts/t/merge_changelogs/ch-merged-basic +++ b/scripts/t/merge_changelogs/ch-merged-basic @@ -134,3 +134,5 @@ test (1.0-1) unstable; urgency=low * Initial release. (Closes: #XXXXXX) -- Raphaël Hertzog Sun, 18 Apr 2010 17:37:46 +0200 + +vim: et diff --git a/scripts/t/merge_changelogs/ch-merged-pr b/scripts/t/merge_changelogs/ch-merged-pr index 467211c80..a58f09779 100644 --- a/scripts/t/merge_changelogs/ch-merged-pr +++ b/scripts/t/merge_changelogs/ch-merged-pr @@ -104,3 +104,5 @@ test (1.0-1) unstable; urgency=low * Initial release. (Closes: #XXXXXX) -- Raphaël Hertzog Sun, 18 Apr 2010 17:37:46 +0200 + +vim: et diff --git a/scripts/t/merge_changelogs/ch-merged-pr-basic b/scripts/t/merge_changelogs/ch-merged-pr-basic index 61f46cd69..773361253 100644 --- a/scripts/t/merge_changelogs/ch-merged-pr-basic +++ b/scripts/t/merge_changelogs/ch-merged-pr-basic @@ -136,3 +136,5 @@ test (1.0-1) unstable; urgency=low * Initial release. (Closes: #XXXXXX) -- Raphaël Hertzog Sun, 18 Apr 2010 17:37:46 +0200 + +vim: et diff --git a/scripts/t/merge_changelogs/ch-old b/scripts/t/merge_changelogs/ch-old index 12ee224c1..5ff7dd366 100644 --- a/scripts/t/merge_changelogs/ch-old +++ b/scripts/t/merge_changelogs/ch-old @@ -83,3 +83,5 @@ test (1.0-1) unstable; urgency=low * Initial release. (Closes: #XXXXXX) -- Raphaël Hertzog Sun, 18 Apr 2010 17:37:46 +0200 + +vim: et -- cgit v1.2.3 From 39eb793a685273f520b25179bf118f8845ece0f6 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 24 Dec 2018 03:05:05 +0100 Subject: Dpkg::File: Make file_slurp() also accept pathnames in addition to filehandles This makes several call sites more clear, as we move the logic inside the function. --- debian/changelog | 2 ++ scripts/Dpkg/File.pm | 16 +++++++++++++++- scripts/Dpkg/Source/Package/V2.pm | 7 ++----- scripts/dpkg-genchanges.pl | 5 +---- scripts/t/Dpkg_Changelog.t | 4 +--- utils/t/update_alternatives.t | 7 ++----- 6 files changed, 23 insertions(+), 18 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 9a6e7a47d..64380eb07 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ dpkg (1.19.3) UNRELEASED; urgency=medium * Perl modules: - Dpkg::Changelog::Debian: Preserve modelines at EOF. Closes: #916056 Thanks to Chris Lamb for initial test cases. + - Dpkg::File: Make file_slurp() also accept pathnames in addition to + filehandles. * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/File.pm b/scripts/Dpkg/File.pm index 884923852..6ba49a6e6 100644 --- a/scripts/Dpkg/File.pm +++ b/scripts/Dpkg/File.pm @@ -25,12 +25,26 @@ our @EXPORT = qw( ); use Exporter qw(import); +use Scalar::Util qw(openhandle); + +use Dpkg::ErrorHandling; +use Dpkg::Gettext; sub file_slurp { - my $fh = shift; + my $file = shift; + my $fh; + my $doclose = 0; + if (openhandle($file)) { + $fh = $file; + } else { + open $fh, '<', $file or syserr(g_('cannot read %s'), $fh); + $doclose = 1; + } local $/; my $data = <$fh>; + close $fh if $doclose; + return $data; } diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index fe9a1727d..e2c1b49fb 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -591,12 +591,8 @@ sub _get_patch_header { unless (-f $ph) { $ph = File::Spec->catfile($dir, 'debian', 'source', 'patch-header'); } - my $text; if (-f $ph) { - open(my $ph_fh, '<', $ph) or syserr(g_('cannot read %s'), $ph); - $text = file_slurp($ph_fh); - close($ph_fh); - return $text; + return file_slurp($ph); } my $ch_info = changelog_parse(offset => 0, count => 1, file => File::Spec->catfile($dir, 'debian', 'changelog')); @@ -613,6 +609,7 @@ it.\n"; $header->{'Author'} = $ch_info->{'Maintainer'}; my $yyyy_mm_dd = POSIX::strftime('%Y-%m-%d', gmtime); + my $text; $text = "$header"; run_vendor_hook('extend-patch-header', \$text, $ch_info); $text .= "\n--- diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 13ab8a453..690a4e59d 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -415,10 +415,7 @@ foreach (keys %{$changelog}) { } if ($changesdescription) { - open(my $changes_fh, '<', $changesdescription) - or syserr(g_('cannot read %s'), $changesdescription); - $fields->{'Changes'} = "\n" . file_slurp($changes_fh); - close($changes_fh); + $fields->{'Changes'} = "\n" . file_slurp($changesdescription); } for my $p (keys %p2f) { diff --git a/scripts/t/Dpkg_Changelog.t b/scripts/t/Dpkg_Changelog.t index f487ff560..4d046fec1 100644 --- a/scripts/t/Dpkg_Changelog.t +++ b/scripts/t/Dpkg_Changelog.t @@ -41,9 +41,7 @@ foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields", my $changes = Dpkg::Changelog::Debian->new(verbose => 0); $changes->load($file); - open(my $clog_fh, '<', "$file") or die "can't open $file\n"; - my $content = file_slurp($clog_fh); - close($clog_fh); + my $content = file_slurp($file); cmp_ok($content, 'eq', "$changes", "string output of Dpkg::Changelog on $file"); my $errors = $changes->get_parse_errors(); diff --git a/utils/t/update_alternatives.t b/utils/t/update_alternatives.t index 491fee07d..84e2080da 100644 --- a/utils/t/update_alternatives.t +++ b/utils/t/update_alternatives.t @@ -21,6 +21,7 @@ use Test::More; use File::Spec; use Dpkg::IPC; +use Dpkg::File qw(file_slurp); use Dpkg::Path qw(find_command); my $srcdir = $ENV{srcdir} || '.'; @@ -260,11 +261,7 @@ check_choice(0, 'auto', 'initial install 3'); # verify that the administrative file is sorted properly { - local $/ = undef; - open(my $db_fh, '<', "$admindir/generic-test") or die $!; - my $content = <$db_fh>; - close($db_fh); - + my $content = file_slurp("$admindir/generic-test"); my $expected = "auto $bindir/generic-test -- cgit v1.2.3 From 75afd33e320ebb31f0e974b227d714b049a67808 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 8 Dec 2018 00:28:57 +0100 Subject: Dpkg::Vendor::Ubuntu: Fix buildflags override after default setting move The default buildflags got moved from the Dpkg::BuildFlags module to the Dpkg::Vendor::Debian, but this module was not adapted to match. Instead of running the Debian hooks after the Ubuntu buildflags are set up, run them first, and then modify/prepend the bits we need to change. This fixes compiler optimization on ppc64el, and makes setting it more future proof. Fixes: commit d5374bc618310917557daa9c9ac2f4930515a0b2 Closes: #915881 Co-Author: Iain Lane Co-Author: Adam Conrad --- debian/changelog | 3 ++ scripts/Dpkg/Vendor/Ubuntu.pm | 12 ++++---- scripts/Makefile.am | 1 + scripts/t/Dpkg_BuildFlags_Ubuntu.t | 57 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 scripts/t/Dpkg_BuildFlags_Ubuntu.t (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 64380eb07..f5face124 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,9 @@ dpkg (1.19.3) UNRELEASED; urgency=medium Thanks to Chris Lamb for initial test cases. - Dpkg::File: Make file_slurp() also accept pathnames in addition to filehandles. + - Dpkg::Vendor::Ubuntu: Fix buildflags override after default setting move. + Based on a patch by Iain Lane and + Adam Conrad . Closes: #915881 * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm index eb2dffefe..e6335c204 100644 --- a/scripts/Dpkg/Vendor/Ubuntu.pm +++ b/scripts/Dpkg/Vendor/Ubuntu.pm @@ -98,6 +98,9 @@ sub run_hook { } elsif ($hook eq 'update-buildflags') { my $flags = shift @params; + # Run the Debian hook to add hardening flags + $self->SUPER::run_hook($hook, $flags); + require Dpkg::BuildOptions; my $build_opts = Dpkg::BuildOptions->new(); @@ -109,15 +112,14 @@ sub run_hook { if (Dpkg::Arch::debarch_eq($arch, 'ppc64el')) { for my $flag (qw(CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS GCJFLAGS FFLAGS FCFLAGS)) { - $flags->set($flag, '-g -O3', 'vendor'); + my $value = $flags->get($flag); + $value =~ s/-O[0-9]/-O3/; + $flags->set($flag, $value); } } } # Per https://wiki.ubuntu.com/DistCompilerFlags - $flags->set('LDFLAGS', '-Wl,-Bsymbolic-functions', 'vendor'); - - # Run the Debian hook to add hardening flags - $self->SUPER::run_hook($hook, $flags); + $flags->prepend('LDFLAGS', '-Wl,-Bsymbolic-functions'); } else { return $self->SUPER::run_hook($hook, @params); } diff --git a/scripts/Makefile.am b/scripts/Makefile.am index d68560173..65867b6b2 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -219,6 +219,7 @@ test_scripts = \ t/Dpkg_Shlibs_Cppfilt.t \ t/Dpkg_Shlibs.t \ t/Dpkg_BuildFlags.t \ + t/Dpkg_BuildFlags_Ubuntu.t \ t/Dpkg_BuildOptions.t \ t/Dpkg_BuildProfiles.t \ t/Dpkg_Build_Env.t \ diff --git a/scripts/t/Dpkg_BuildFlags_Ubuntu.t b/scripts/t/Dpkg_BuildFlags_Ubuntu.t new file mode 100644 index 000000000..3cfdb268f --- /dev/null +++ b/scripts/t/Dpkg_BuildFlags_Ubuntu.t @@ -0,0 +1,57 @@ +#!/usr/bin/perl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use warnings; + +use Test::More tests => 16; + +BEGIN { + use_ok('Dpkg::BuildFlags'); +} + +sub test_optflag +{ + my ($bf, $optflag) = @_; + + foreach my $flag (qw(CFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS GCJFLAGS + FFLAGS FCFLAGS)) { + my $value = $bf->get($flag); + ok($value =~ m/$optflag/, "$flag contains $optflag: $value"); + } +} + +my $bf; + +# Force loading the Dpkg::Vendor::Ubuntu module. +$ENV{DEB_VENDOR} = 'Ubuntu'; + +# Test the optimization flag inherited from the Dpkg::Vendor::Debian module. +$ENV{DEB_HOST_ARCH} = 'amd64'; +$bf = Dpkg::BuildFlags->new(); + +test_optflag($bf, '-O2'); + +# Test the overlaid Ubuntu-specific linker flag. +ok($bf->get('LDFLAGS') =~ m/-Wl,-Bsymbolic-functions/, + 'LDFLAGS contains -Bsymbolic-functions'); + +# Test the optimization flag override only for ppc64el. +$ENV{DEB_HOST_ARCH} = 'ppc64el'; +$bf = Dpkg::BuildFlags->new(); + +test_optflag($bf, '-O3'); + +1; -- cgit v1.2.3 From 6b8897bad85394b2737e609419ad3ebd7ee5b008 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 10 Oct 2018 09:40:00 +0200 Subject: Dpkg::Shlibs::Objdump: Remove unused Dpkg::IPC import The spawn() call was removed but not the matching import. Fixes: commit 8ae966ae7d3635b8359829085db4262923ceae96 --- debian/changelog | 1 + scripts/Dpkg/Shlibs/Objdump.pm | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index f5face124..5ef764d80 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - Dpkg::Vendor::Ubuntu: Fix buildflags override after default setting move. Based on a patch by Iain Lane and Adam Conrad . Closes: #915881 + - Dpkg::Shlibs::Objdump: Remove unused Dpkg::IPC import. * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index d0a7b56cb..d3a94113e 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -25,7 +25,6 @@ use Dpkg::Gettext; use Dpkg::ErrorHandling; use Dpkg::Path qw(find_command); use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch); -use Dpkg::IPC; # Decide which objdump to call our $OBJDUMP = 'objdump'; -- cgit v1.2.3 From 50b7e8cc41eb94a184087cc93cab86e401643c90 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 10 Oct 2018 09:41:11 +0200 Subject: Dpkg::Shlibs::Objdump: Only select objdump program when going to use it Running code in the module scope means that anything importing the module will execute that code, which is undesirable. Move the initialization into a _select_objdump() sub, which gets assigned into a state variable on demand. --- debian/changelog | 1 + scripts/Dpkg/Shlibs/Objdump.pm | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 5ef764d80..e4d49221e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium Based on a patch by Iain Lane and Adam Conrad . Closes: #915881 - Dpkg::Shlibs::Objdump: Remove unused Dpkg::IPC import. + - Dpkg::Shlibs::Objdump: Only select objdump program when going to use it. * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index d3a94113e..4cee866e7 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -1,4 +1,5 @@ # Copyright © 2007-2010 Raphaël Hertzog +# Copyright © 2007-2009,2012-2015,2017-2018 Guillem Jover # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -23,16 +24,6 @@ our $VERSION = '0.01'; use Dpkg::Gettext; use Dpkg::ErrorHandling; -use Dpkg::Path qw(find_command); -use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch); - -# Decide which objdump to call -our $OBJDUMP = 'objdump'; -if (get_build_arch() ne get_host_arch()) { - my $od = debarch_to_gnutriplet(get_host_arch()) . '-objdump'; - $OBJDUMP = $od if find_command($od); -} - sub new { my $this = shift; @@ -243,9 +234,12 @@ package Dpkg::Shlibs::Objdump::Object; use strict; use warnings; +use feature qw(state); use Dpkg::Gettext; use Dpkg::ErrorHandling; +use Dpkg::Path qw(find_command); +use Dpkg::Arch qw(debarch_to_gnutriplet get_build_arch get_host_arch); sub new { my $this = shift; @@ -280,6 +274,14 @@ sub reset { return $self; } +sub _select_objdump { + # Decide which objdump to call + if (get_build_arch() ne get_host_arch()) { + my $od = debarch_to_gnutriplet(get_host_arch()) . '-objdump'; + return $od if find_command($od); + } + return 'objdump'; +} sub analyze { my ($self, $file) = @_; @@ -297,6 +299,7 @@ sub analyze { return; } + state $OBJDUMP = _select_objdump(); local $ENV{LC_ALL} = 'C'; open(my $objdump, '-|', $OBJDUMP, '-w', '-f', '-p', '-T', '-R', $file) or syserr(g_('cannot fork for %s'), $OBJDUMP); -- cgit v1.2.3 From a7fb57546f0a7e88a1acd7bdf1c081b43972b01d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 25 Nov 2018 22:59:03 +0100 Subject: Dpkg::Source::Package: Do not reinitialize fields member in constructor We initialized it already in the new constructor, no point in doing the same twice. --- debian/changelog | 1 + scripts/Dpkg/Source/Package.pm | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index e4d49221e..d43a06258 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium Adam Conrad . Closes: #915881 - Dpkg::Shlibs::Objdump: Remove unused Dpkg::IPC import. - Dpkg::Shlibs::Objdump: Only select objdump program when going to use it. + - Dpkg::Source::Package: Do not reinitialize fields member in constructor. * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index f7851d203..c9f8d5e14 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -262,9 +262,8 @@ sub initialize { $self->{filename} = $fn; # Read the fields - my $fields = Dpkg::Control->new(type => CTRL_PKG_SRC); + my $fields = $self->{fields}; $fields->load($filename); - $self->{fields} = $fields; $self->{is_signed} = $fields->get_option('is_pgp_signed'); foreach my $f (qw(Source Version Files)) { -- cgit v1.2.3 From a71649166e7dabbce315c8e49501ba68676831ef Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 5 Nov 2018 23:57:52 +0100 Subject: Dpkg::Source::Patch: Do not recommend --include-removal when not supported If the option has not been set, then the source format does not support it and we should thus not recommend the --include-removal option in the warning. Closes: #913012 --- debian/changelog | 2 ++ scripts/Dpkg/Source/Patch.pm | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index d43a06258..88e6f9b48 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,8 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - Dpkg::Shlibs::Objdump: Remove unused Dpkg::IPC import. - Dpkg::Shlibs::Objdump: Only select objdump program when going to use it. - Dpkg::Source::Package: Do not reinitialize fields member in constructor. + - Dpkg::Source::Patch: Do not recommend --include-removal when not + supported. Closes: #913012 * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/Source/Patch.pm b/scripts/Dpkg/Source/Patch.pm index e5ad5424b..25d56335d 100644 --- a/scripts/Dpkg/Source/Patch.pm +++ b/scripts/Dpkg/Source/Patch.pm @@ -148,7 +148,6 @@ sub add_diff_directory { # TODO: make this function more configurable # - offer to disable some checks my $basedir = $opts{basedirname} || basename($new); - my $inc_removal = $opts{include_removal} // 0; my $diff_ignore; if ($opts{diff_ignore_func}) { $diff_ignore = $opts{diff_ignore_func}; @@ -226,11 +225,13 @@ sub add_diff_directory { return if $files_in_new{$fn}; lstat("$old/$fn") or syserr(g_('cannot stat file %s'), "$old/$fn"); if (-f _) { - if ($inc_removal) { + if (not defined $opts{include_removal}) { + warning(g_('ignoring deletion of file %s'), $fn); + } elsif (not $opts{include_removal}) { + warning(g_('ignoring deletion of file %s, use --include-removal to override'), $fn); + } else { push @diff_files, [$fn, 0, 0, "$old/$fn", '/dev/null', "$basedir.orig/$fn", '/dev/null']; - } else { - warning(g_('ignoring deletion of file %s, use --include-removal to override'), $fn); } } elsif (-d _) { warning(g_('ignoring deletion of directory %s'), $fn); -- cgit v1.2.3 From 05f666b8e944e7e7cf06966e192f759fa83b4d02 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 12 Oct 2018 20:46:10 +0200 Subject: Dpkg::Source::Package::V3::Bzr: Fix format name in output message --- debian/changelog | 1 + scripts/Dpkg/Source/Package/V3/Bzr.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 88e6f9b48..5d9a187de 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - Dpkg::Source::Package: Do not reinitialize fields member in constructor. - Dpkg::Source::Patch: Do not recommend --include-removal when not supported. Closes: #913012 + - Dpkg::Source::Package::V3::Bzr: Fix format name in output message. * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/Source/Package/V3/Bzr.pm b/scripts/Dpkg/Source/Package/V3/Bzr.pm index f0752c0b1..13d49c742 100644 --- a/scripts/Dpkg/Source/Package/V3/Bzr.pm +++ b/scripts/Dpkg/Source/Package/V3/Bzr.pm @@ -176,7 +176,7 @@ sub do_extract { my @files = $self->get_files(); if (@files > 1) { - error(g_('format v3.0 uses only one source file')); + error(g_('format v3.0 (bzr) uses only one source file')); } my $tarfile = $files[0]; my $comp_ext_regex = compression_get_file_extension_regex(); -- cgit v1.2.3 From e0b3b307decf60b2a4e39c511ad970d4a1abd2b6 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 13 Oct 2018 10:02:03 +0200 Subject: Dpkg::Source::Package: Add a new format option to the new constructor This makes it easier to construct a source package object with the desired object, and initialize it as required. Prompted-by: James McCoy Ref: https://salsa.debian.org/debian/devscripts/merge_requests/61 --- debian/changelog | 2 ++ scripts/Dpkg/Source/Package.pm | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 5d9a187de..63c983e4b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - Dpkg::Source::Patch: Do not recommend --include-removal when not supported. Closes: #913012 - Dpkg::Source::Package::V3::Bzr: Fix format name in output message. + - Dpkg::Source::Package: Add a new format option to the new constructor. + Prompted by James McCoy . * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index c9f8d5e14..b3a80ba1d 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -34,7 +34,7 @@ is the one that supports the extraction of the source package. use strict; use warnings; -our $VERSION = '1.02'; +our $VERSION = '1.03'; our @EXPORT_OK = qw( get_default_diff_ignore_regex set_default_diff_ignore_regex @@ -166,12 +166,15 @@ sub get_default_tar_ignore_pattern { =over 4 -=item $p = Dpkg::Source::Package->new(filename => $dscfile, options => {}) +=item $p = Dpkg::Source::Package->new(%opts, options => {}) -Creates a new object corresponding to the source package described -by the file $dscfile. +Creates a new object corresponding to a source package. When the key +B is set to a F<.dsc> file, it will be used to initialize the +source package with its description. Otherwise if the B key is +set to a valid value, the object will be initialized for that format +(since dpkg 1.19.3). -The options hash supports the following options: +The B key is a hash ref which supports the following options: =over 8 @@ -220,6 +223,10 @@ sub new { if (exists $args{filename}) { $self->initialize($args{filename}); $self->init_options(); + } elsif ($args{format}) { + $self->{fields}{Format} = $args{format}; + $self->upgrade_object_type(0); + $self->init_options(); } return $self; } @@ -670,6 +677,10 @@ sub write_dsc { =head1 CHANGES +=head2 Version 1.03 (dpkg 1.19.3) + +New option: format in new(). + =head2 Version 1.02 (dpkg 1.18.7) New option: require_strong_checksums in check_checksums(). -- cgit v1.2.3 From 23802ae9be9760a4135b8ca2911c86045fe47fc2 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 21 Oct 2018 22:55:29 +0200 Subject: Dpkg::Source::Package: Improve debian/source/format parsing and validation Make the regex more strict and decompose it right away instead of doing a second pass over it. Only initialize minor when we need to update the format. And fix the error for an invalid format to stop referencing the Format field, which might not be involved during the parsing. --- debian/changelog | 2 ++ scripts/Dpkg/Source/Package.pm | 25 +++++++++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 63c983e4b..6065bc48d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,6 +17,8 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - Dpkg::Source::Package::V3::Bzr: Fix format name in output message. - Dpkg::Source::Package: Add a new format option to the new constructor. Prompted by James McCoy . + - Dpkg::Source::Package: Improve debian/source/format parsing and + validation. * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index b3a80ba1d..29e61170e 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -290,16 +290,8 @@ sub upgrade_object_type { $self->{fields}{'Format'} //= '1.0'; my $format = $self->{fields}{'Format'}; - if ($format =~ /^([\d\.]+)(?:\s+\((.*)\))?$/) { - my ($version, $variant) = ($1, $2); - - if (defined $variant and $variant ne lc $variant) { - error(g_("source package format '%s' is not supported: %s"), - $format, g_('format variant must be in lowercase')); - } - - my $major = $version =~ s/\.[\d\.]+$//r; - my $minor; + if ($format =~ /^(\d+)(?:\.(\d+))?(?:\s+\(([a-z0-9]+)\))?$/) { + my ($major, $minor, $variant) = ($1, $2, $3); my $module = "Dpkg::Source::Package::V$major"; $module .= '::' . ucfirst $variant if defined $variant; @@ -308,19 +300,20 @@ sub upgrade_object_type { require $module; \$minor = \$${module}::CURRENT_MINOR_VERSION; }; - $minor //= 0; - if ($update_format) { - $self->{fields}{'Format'} = "$major.$minor"; - $self->{fields}{'Format'} .= " ($variant)" if defined $variant; - } if ($@) { error(g_("source package format '%s' is not supported: %s"), $format, $@); } + + if ($update_format) { + $minor //= 0; + $self->{fields}{'Format'} = "$major.$minor"; + $self->{fields}{'Format'} .= " ($variant)" if defined $variant; + } $module->prerequisites() if $module->can('prerequisites'); bless $self, $module; } else { - error(g_("invalid Format field '%s'"), $format); + error(g_("source package format '%s' is invalid"), $format); } } -- cgit v1.2.3 From c8dcfa3f2c42f51cebf2673312a52e7b71bb00ec Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 23 Oct 2018 02:18:04 +0200 Subject: Dpkg::Source::Format: New module This new public module centralizes the handling of debian/source/format so that other projects can reuse it instead of having to reimplement it. Prompted-by: Mattia Rizzolo Ref: https://salsa.debian.org/debian/devscripts/merge_requests/63 --- debian/changelog | 2 + debian/control | 1 + scripts/Dpkg.pm | 4 + scripts/Dpkg/Source/Format.pm | 191 +++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.am | 2 + scripts/t/Dpkg_Source_Format.t | 65 ++++++++++++++ 6 files changed, 265 insertions(+) create mode 100644 scripts/Dpkg/Source/Format.pm create mode 100644 scripts/t/Dpkg_Source_Format.t (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 6065bc48d..456c1ec43 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,8 @@ dpkg (1.19.3) UNRELEASED; urgency=medium Prompted by James McCoy . - Dpkg::Source::Package: Improve debian/source/format parsing and validation. + - Dpkg::Source::Format: New public module. + Prompted by Mattia Rizzolo . * Documentation: - dpkg(1): Clarify --remove action. Closes: #914478 - dpkg-query(1): Clarify --list option behavior when no arguments are diff --git a/debian/control b/debian/control index 1d7e33a2e..f78162c41 100644 --- a/debian/control +++ b/debian/control @@ -197,6 +197,7 @@ Description: Dpkg perl modules example) - Dpkg::Interface::Storable: base object serializer - Dpkg::Path: common path handling functions + - Dpkg::Source::Format: manipulate debian/source/format files - Dpkg::Source::Package: extract Debian source packages - Dpkg::Substvars: substitute variables in strings - Dpkg::Vendor: identify current distribution vendor diff --git a/scripts/Dpkg.pm b/scripts/Dpkg.pm index fd9259ecb..c2768a3dd 100644 --- a/scripts/Dpkg.pm +++ b/scripts/Dpkg.pm @@ -266,6 +266,10 @@ Base object serializer. Common path handling functions. +=item L + +Parse and manipulate debian/source/format files. + =item L Extract Debian source packages. diff --git a/scripts/Dpkg/Source/Format.pm b/scripts/Dpkg/Source/Format.pm new file mode 100644 index 000000000..55172a2ef --- /dev/null +++ b/scripts/Dpkg/Source/Format.pm @@ -0,0 +1,191 @@ +# Copyright © 2008-2011 Raphaël Hertzog +# Copyright © 2008-2018 Guillem Jover +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +package Dpkg::Source::Format; + +=encoding utf8 + +=head1 NAME + +Dpkg::Source::Format - manipulate debian/source/format files + +=head1 DESCRIPTION + +This module provides an object that can manipulate Debian source +package F files. + +=cut + +use strict; +use warnings; + +our $VERSION = '1.00'; + +use Dpkg::Gettext; +use Dpkg::ErrorHandling; + +use parent qw(Dpkg::Interface::Storable); + +=head1 METHODS + +=over 4 + +=item $f = Dpkg::Source::Format->new(%opts) + +Creates a new object corresponding to a source package's +F file. When the key B is set, it will +be used to parse and set the format. Otherwise if the B key is +set it will be validated and used to set the format. + +=cut + +sub new { + my ($this, %opts) = @_; + my $class = ref($this) || $this; + my $self = { + filename => undef, + major => undef, + minor => undef, + variant => undef, + }; + bless $self, $class; + + if (exists $opts{filename}) { + $self->load($opts{filename}, compression => 0); + } elsif ($opts{format}) { + $self->set($opts{format}); + } + return $self; +} + +=item $f->set_from_parts($major[, $minor[, $variant]]) + +Sets the source format from its parts. The $major part is mandatory. +The $minor and $variant parts are optional. + +B: This function performs no validation. + +=cut + +sub set_from_parts { + my ($self, $major, $minor, $variant) = @_; + + $self->{major} = $major; + $self->{minor} = $minor // 0; + $self->{variant} = $variant; +} + +=item ($major, $minor, $variant) = $f->set($format) + +Sets (and validates) the source $format specified. Will return the parsed +format parts as a list, the optional $minor and $variant parts might be +undef. + +=cut + +sub set { + my ($self, $format) = @_; + + if ($format =~ /^(\d+)(?:\.(\d+))?(?:\s+\(([a-z0-9]+)\))?$/) { + my ($major, $minor, $variant) = ($1, $2, $3); + + $self->set_from_parts($major, $minor, $variant); + + return ($major, $minor, $variant); + } else { + error(g_("source package format '%s' is invalid"), $format); + } +} + +=item ($major, $minor, $variant) = $f->get() + +=item $format = $f->get() + +Gets the source format, either as properly formatted scalar, or as a list +of its parts, where the optional $minor and $variant parts might be undef. + +=cut + +sub get { + my $self = shift; + + if (wantarray) { + return ($self->{major}, $self->{minor}, $self->{variant}); + } else { + my $format = "$self->{major}.$self->{minor}"; + $format .= " ($self->{variant})" if defined $self->{variant}; + + return $format; + } +} + +=item $count = $f->parse($fh, $desc) + +Parse the source format string from $fh, with filehandle description $desc. + +=cut + +sub parse { + my ($self, $fh, $desc) = @_; + + my $format = <$fh>; + chomp $format if defined $format; + error(g_('%s is empty'), $desc) + unless defined $format and length $format; + + $self->set($format); + + return 1; +} + +=item $count = $f->load($filename) + +Parse $filename contents for a source package format string. + +=item $str = $f->output([$fh]) + +=item "$f" + +Returns a string representing the source package format version. +If $fh is set, it prints the string to the filehandle. + +=cut + +sub output { + my ($self, $fh) = @_; + + my $str = $self->get(); + + print { $fh } "$str\n" if defined $fh; + + return $str; +} + +=item $f->save($filename) + +Save the source package format into the given $filename. + +=back + +=head1 CHANGES + +=head2 Version 1.00 (dpkg 1.19.3) + +Mark the module as public. + +=cut + +1; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 65867b6b2..aacd630fc 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -105,6 +105,7 @@ nobase_dist_perllib_DATA = \ Dpkg/Shlibs/Cppfilt.pm \ Dpkg/Source/Archive.pm \ Dpkg/Source/BinaryFiles.pm \ + Dpkg/Source/Format.pm \ Dpkg/Source/Functions.pm \ Dpkg/Source/Package.pm \ Dpkg/Source/Package/V1.pm \ @@ -251,6 +252,7 @@ test_scripts = \ t/Dpkg_Source_Functions.t \ t/Dpkg_Source_Patch.t \ t/Dpkg_Source_Quilt.t \ + t/Dpkg_Source_Format.t \ t/Dpkg_Source_Archive.t \ t/Dpkg_Source_Package.t \ t/Dpkg_Dist_Files.t \ diff --git a/scripts/t/Dpkg_Source_Format.t b/scripts/t/Dpkg_Source_Format.t new file mode 100644 index 000000000..5a2785ea5 --- /dev/null +++ b/scripts/t/Dpkg_Source_Format.t @@ -0,0 +1,65 @@ +#!/usr/bin/perl +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +use strict; +use warnings; + +use Test::More tests => 14; + +BEGIN { + use_ok('Dpkg::Source::Format'); +} + +my $format = Dpkg::Source::Format->new(); +my @format_parts; +my $format_string; + +$format->set('4.3 (variant)'); +@format_parts = $format->get(); +is_deeply(\@format_parts, [ qw(4 3 variant) ], 'decomposition of format'); +$format_string = $format->get(); +ok($format_string eq '4.3 (variant)', 'function stringification of format'); +$format_string = "$format"; +ok($format_string eq '4.3 (variant)', 'operator stringification of format'); + +$format->set('5.5'); +$format_string = $format->get(); +ok($format_string eq '5.5', 'missing variant'); + +$format->set('6'); +$format_string = $format->get(); +ok($format_string eq '6.0', 'implied minor'); + +my %format_bogus = ( + 'a' => 'require numerical major', + '7.a'=> 'require numerical minor', + '.5' => 'require non-empty major', + '7.' => 'require non-empty minor', + '7.0 ()' => 'require non-empty variant', + '7.0 ( )' => 'require non-space variant', + '7.0 (VARIANT)' => 'require lower-case variant', + '7.6.5' => 'excess version part', +); + +foreach my $format_bogus (sort keys %format_bogus) { + eval { + $format->set($format_bogus); + }; + ok($@, $format_bogus{$format_bogus}); +}; + +# TODO: Add actual test cases. + +1; -- cgit v1.2.3 From d1d35a56e401181b6d15baf474a7db21d3372a65 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 20 Oct 2018 15:04:16 +0200 Subject: Dpkg::Source::Package, dpkg-source: Switch to new Dpkg::Source::Format module This move all ad-hoc code to use the new Dpkg::Source::Format module. --- debian/changelog | 1 + scripts/Dpkg/Source/Package.pm | 52 ++++++++++++++++++------------------------ scripts/dpkg-source.pl | 12 ++++------ 3 files changed, 27 insertions(+), 38 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 456c1ec43..55d28b816 100644 --- a/debian/changelog +++ b/debian/changelog @@ -42,6 +42,7 @@ dpkg (1.19.3) UNRELEASED; urgency=medium - dpkg-maintscript-helper: Use an explicit escape instead of a literal backslash. - Quote shell variables. Reported by Johannes Schauer . + - Switch perl code to use the new Dpkg::Source::Format module. * Build system: - get-version: Use a format string with printf. - run-script: Use $() instead of deprecated ``. diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 29e61170e..74daa712b 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -213,6 +213,7 @@ sub new { my $class = ref($this) || $this; my $self = { fields => Dpkg::Control->new(type => CTRL_PKG_SRC), + format => Dpkg::Source::Format->new(), options => {}, checksums => Dpkg::Checksums->new(), }; @@ -287,34 +288,28 @@ sub initialize { sub upgrade_object_type { my ($self, $update_format) = @_; $update_format //= 1; - $self->{fields}{'Format'} //= '1.0'; - my $format = $self->{fields}{'Format'}; - - if ($format =~ /^(\d+)(?:\.(\d+))?(?:\s+\(([a-z0-9]+)\))?$/) { - my ($major, $minor, $variant) = ($1, $2, $3); - - my $module = "Dpkg::Source::Package::V$major"; - $module .= '::' . ucfirst $variant if defined $variant; - eval qq{ - pop \@INC if \$INC[-1] eq '.'; - require $module; - \$minor = \$${module}::CURRENT_MINOR_VERSION; - }; - if ($@) { - error(g_("source package format '%s' is not supported: %s"), - $format, $@); - } - if ($update_format) { - $minor //= 0; - $self->{fields}{'Format'} = "$major.$minor"; - $self->{fields}{'Format'} .= " ($variant)" if defined $variant; - } - $module->prerequisites() if $module->can('prerequisites'); - bless $self, $module; - } else { - error(g_("source package format '%s' is invalid"), $format); + my $format = $self->{fields}{'Format'} // '1.0'; + my ($major, $minor, $variant) = $self->{format}->set($format); + + my $module = "Dpkg::Source::Package::V$major"; + $module .= '::' . ucfirst $variant if defined $variant; + eval qq{ + pop \@INC if \$INC[-1] eq '.'; + require $module; + \$minor = \$${module}::CURRENT_MINOR_VERSION; + }; + if ($@) { + error(g_("source package format '%s' is not supported: %s"), + $format, $@); } + if ($update_format) { + $self->{format}->set_from_parts($major, $minor, $variant); + $self->{fields}{'Format'} = $self->{format}->get(); + } + + $module->prerequisites() if $module->can('prerequisites'); + bless $self, $module; } =item $p->get_filename() @@ -548,10 +543,7 @@ sub extract { my $format_file = File::Spec->catfile($srcdir, 'format'); unless (-e $format_file) { mkdir($srcdir) unless -e $srcdir; - open(my $format_fh, '>', $format_file) - or syserr(g_('cannot write %s'), $format_file); - print { $format_fh } $self->{fields}{'Format'} . "\n"; - close($format_fh); + $self->{format}->save($format_file); } } diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 6a4825d22..2e5f41d31 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -396,14 +396,10 @@ if ($options{opmode} =~ /^(build|print-format|(before|after)-build|commit)$/) { # Select the format to use if (not defined $build_format) { - if (-e "$dir/debian/source/format") { - open(my $format_fh, '<', "$dir/debian/source/format") - or syserr(g_('cannot read %s'), "$dir/debian/source/format"); - $build_format = <$format_fh>; - chomp($build_format) if defined $build_format; - error(g_('%s is empty'), "$dir/debian/source/format") - unless defined $build_format and length $build_format; - close($format_fh); + my $format_file = "$dir/debian/source/format"; + if (-e $format_file) { + my $format = Dpkg::Source::Format->new(filename => $format_file); + $build_format = $format->get(); } else { warning(g_('no source format specified in %s, ' . 'see dpkg-source(1)'), 'debian/source/format') -- cgit v1.2.3 From 13cad525ffbcbfba47863ea41024415ac25f7974 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 2 Dec 2018 03:35:49 +0100 Subject: dpkg-genbuildinfo: Add support for a new Build-Tainted-By field This field will contain a list of tainting reason tags, which can denote that the current build has potentially been broken. Suggested-by: Alexander E. Patrakov --- debian/changelog | 2 ++ man/deb-buildinfo.man | 11 +++++++++++ scripts/Dpkg/Control/FieldsCore.pm | 7 ++++++- scripts/Dpkg/Vendor/Debian.pm | 10 ++++++++++ scripts/Dpkg/Vendor/Default.pm | 10 ++++++++++ scripts/dpkg-genbuildinfo.pl | 2 ++ scripts/t/Dpkg_Control_Fields.t | 5 +++-- 7 files changed, 44 insertions(+), 3 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 7006c9093..58a306652 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,6 +23,8 @@ dpkg (1.19.5) UNRELEASED; urgency=medium Closes: #922039 * dpkg-maintscript-helper: Restrict find for dir-to-symlink move to -maxdepth 1. Thanks to Ralf Treinen . Closes: #922799 + * dpkg-genbuildinfo: Add support for a new Build-Tainted-By field in + .buildinfo files. Suggested by Alexander E. Patrakov . * Documentation: - start-stop-daemon(1): Document behavior of --pidfile security checks. Closes: #921557 diff --git a/man/deb-buildinfo.man b/man/deb-buildinfo.man index 5013aa047..1a1ddc7d1 100644 --- a/man/deb-buildinfo.man +++ b/man/deb-buildinfo.man @@ -149,6 +149,17 @@ via some pattern match to avoid leaking possibly sensitive information. On Debian and derivatives only build paths starting with \fI/build/\fP will emit this field. .TP +.B Build\-Tainted\-By: +.TQ +.I " taint-reason-list" +This folded field contains a space-separated list of non-exhausitve reason +tags (formed by alphanumeric and dash characters) which identify why the +current build has been tainted (since dpkg 1.19.5). +.IP +On Debian and derivatives the following reason tags can be emitted: +.RS +.RE +.TP .BR Installed\-Build\-Depends: " (required)" .TQ .I " package-list" diff --git a/scripts/Dpkg/Control/FieldsCore.pm b/scripts/Dpkg/Control/FieldsCore.pm index b100366e1..f460433fc 100644 --- a/scripts/Dpkg/Control/FieldsCore.pm +++ b/scripts/Dpkg/Control/FieldsCore.pm @@ -176,6 +176,11 @@ our %FIELDS = ( allowed => CTRL_INFO_PKG, separator => FIELD_SEP_SPACE, }, + 'build-tainted-by' => { + name => 'Build-Tainted-By', + allowed => CTRL_FILE_BUILDINFO, + separator => FIELD_SEP_SPACE, + }, 'built-for-profiles' => { name => 'Built-For-Profiles', allowed => ALL_PKG | CTRL_FILE_CHANGES, @@ -634,7 +639,7 @@ our %FIELD_ORDER = ( qw(format source binary architecture version binary-only-changes), @src_checksums_fields, qw(build-origin build-architecture build-kernel-version build-date - build-path installed-build-depends environment), + build-path build-tainted-by installed-build-depends environment), ], CTRL_FILE_CHANGES() => [ qw(format date source binary binary-only built-for-profiles architecture diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 7d4b6d802..7b5244042 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -81,6 +81,8 @@ sub run_hook { $self->_add_build_flags(@params); } elsif ($hook eq 'builtin-system-build-paths') { return qw(/build/); + } elsif ($hook eq 'build-tainted-by') { + return $self->_build_tainted_by(); } else { return $self->SUPER::run_hook($hook, @params); } @@ -439,6 +441,14 @@ sub _add_build_flags { } } +sub _build_tainted_by { + my $self = shift; + my %tainted; + + my @tainted = sort keys %tainted; + return @tainted; +} + =head1 CHANGES =head2 Version 0.xx diff --git a/scripts/Dpkg/Vendor/Default.pm b/scripts/Dpkg/Vendor/Default.pm index 40815efde..ed05c3009 100644 --- a/scripts/Dpkg/Vendor/Default.pm +++ b/scripts/Dpkg/Vendor/Default.pm @@ -140,6 +140,14 @@ field will be created if the current directory is "/build/dpkg-1.18.0". If the list contains "/", the path will always be recorded. If the list is empty, the current path will never be recorded. +=item build-tainted-by () + +The hook is called by dpkg-genbuildinfo to determine if the current system +has been tainted in some way that could affect the resulting build, which +will be recorded in the B field (since dpkg 1.19.5). It +takes no parameters, but returns a (possibly empty) list of tainted reason +tags (formed by alphanumeric and dash characters). + =back =cut @@ -172,6 +180,8 @@ sub run_hook { my $flags = shift @params; } elsif ($hook eq 'builtin-system-build-paths') { return (); + } elsif ($hook eq 'build-tainted-by') { + return (); } # Default return value for unknown/unimplemented hooks diff --git a/scripts/dpkg-genbuildinfo.pl b/scripts/dpkg-genbuildinfo.pl index fe296506e..827b6679f 100755 --- a/scripts/dpkg-genbuildinfo.pl +++ b/scripts/dpkg-genbuildinfo.pl @@ -437,6 +437,8 @@ if ($use_feature{path}) { } } +$fields->{'Build-Tainted-By'} = "\n" . join "\n", run_vendor_hook('build-tainted-by'); + $checksums->export_to_control($fields); $fields->{'Installed-Build-Depends'} = collect_installed_builddeps($control); diff --git a/scripts/t/Dpkg_Control_Fields.t b/scripts/t/Dpkg_Control_Fields.t index 00f951052..8e0bd721b 100644 --- a/scripts/t/Dpkg_Control_Fields.t +++ b/scripts/t/Dpkg_Control_Fields.t @@ -20,7 +20,7 @@ use Test::More; use Test::Dpkg qw(:paths); BEGIN { - plan tests => 2416; + plan tests => 2438; use_ok('Dpkg::Control::Types'); use_ok('Dpkg::Control::FieldsCore'); @@ -167,7 +167,8 @@ my %fields = ( qw(Format Source Binary Architecture Version Binary-Only-Changes), @src_checksums, qw(Build-Origin Build-Architecture Build-Kernel-Version - Build-Date Build-Path Installed-Build-Depends Environment) + Build-Date Build-Path Build-Tainted-By + Installed-Build-Depends Environment) ], }, CTRL_FILE_CHANGES() => { -- cgit v1.2.3 From dd406dc36649bacf646c51735214b9b21a82b5ae Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 2 Dec 2018 03:35:49 +0100 Subject: Dpkg::Vendor::Debian: Add support for merged-usr-via-symlinks tainted tag This will detect whether the system we are building on contains the problematic /usr merged via symlinks deployment method. Suggested-by: Alexander E. Patrakov --- debian/changelog | 3 +++ man/deb-buildinfo.man | 11 +++++++++++ scripts/Dpkg/Vendor/Debian.pm | 10 ++++++++++ 3 files changed, 24 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 58a306652..a57bd3438 100644 --- a/debian/changelog +++ b/debian/changelog @@ -25,6 +25,9 @@ dpkg (1.19.5) UNRELEASED; urgency=medium -maxdepth 1. Thanks to Ralf Treinen . Closes: #922799 * dpkg-genbuildinfo: Add support for a new Build-Tainted-By field in .buildinfo files. Suggested by Alexander E. Patrakov . + * Perl modules: + - Dpkg::Vendor::Debian: Add support for merged-usr-via-symlinks tainted + tag. Suggested by Alexander E. Patrakov . * Documentation: - start-stop-daemon(1): Document behavior of --pidfile security checks. Closes: #921557 diff --git a/man/deb-buildinfo.man b/man/deb-buildinfo.man index 1a1ddc7d1..fe276bef2 100644 --- a/man/deb-buildinfo.man +++ b/man/deb-buildinfo.man @@ -158,6 +158,17 @@ current build has been tainted (since dpkg 1.19.5). .IP On Debian and derivatives the following reason tags can be emitted: .RS +.TP +.B merged\-usr\-via\-symlinks +The system has a merged \fI/usr\fP via symlinks. +This will confuse \fBdpkg\-query\fP, \fBdpkg\-statoverride\fP, +\fBdpkg\-trigger\fP, \fBupdate\-alternatives\fP and any other tool using +pathnames as keys into their databases, as it creates filesystem aliasing +problems, and messes with the understanding of the filesystem that +\fBdpkg\fP has recorded in its database. +For build systems that hardcode pathnames to specific binaries or libraries +on the resulting artifacts, it can also produce packages that will be +incompatible with non-/usr-merged filesystems. .RE .TP .BR Installed\-Build\-Depends: " (required)" diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 7b5244042..6948bdc16 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -445,6 +445,16 @@ sub _build_tainted_by { my $self = shift; my %tainted; + foreach my $pathname (qw(/bin /sbin /lib /lib32 /libo32 /libx32 /lib64)) { + next unless -l $pathname; + + my $linkname = readlink $pathname; + if ($linkname eq "usr$pathname") { + $tainted{'merged-usr-via-symlinks'} = 1; + last; + } + } + my @tainted = sort keys %tainted; return @tainted; } -- cgit v1.2.3 From 769e87e0b9943bae4c62f1a5c85581be653d74b8 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 3 Dec 2018 08:57:14 +0100 Subject: Dpkg::Vendor::Debian: Add support for usr-local-has-* tainted tags These will detect problematic files under /usr/local which can taint the current build. --- debian/changelog | 1 + man/deb-buildinfo.man | 12 ++++++++++++ scripts/Dpkg/Vendor/Debian.pm | 14 ++++++++++++++ 3 files changed, 27 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index a57bd3438..16ea0cf74 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,7 @@ dpkg (1.19.5) UNRELEASED; urgency=medium * Perl modules: - Dpkg::Vendor::Debian: Add support for merged-usr-via-symlinks tainted tag. Suggested by Alexander E. Patrakov . + - Dpkg::Vendor::Debian: Add support for usr-local-has-* tainted tags. * Documentation: - start-stop-daemon(1): Document behavior of --pidfile security checks. Closes: #921557 diff --git a/man/deb-buildinfo.man b/man/deb-buildinfo.man index fe276bef2..691acb255 100644 --- a/man/deb-buildinfo.man +++ b/man/deb-buildinfo.man @@ -169,6 +169,18 @@ problems, and messes with the understanding of the filesystem that For build systems that hardcode pathnames to specific binaries or libraries on the resulting artifacts, it can also produce packages that will be incompatible with non-/usr-merged filesystems. +.TP +.B usr\-local\-has\-configs +The system has configuration files under \fI/usr/local/etc\fP. +.TP +.B usr\-local\-has\-includes +The system has header files under \fI/usr/local/include\fP. +.TP +.B usr\-local\-has\-programs +The system has programs under \fI/usr/local/bin\fP or \fI/usr/local/sbin\fP. +.TP +.B usr\-local\-has\-libraries +The system has libraries, either static or shared under \fI/usr/local/lib\fP. .RE .TP .BR Installed\-Build\-Depends: " (required)" diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 6948bdc16..a352bbdde 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -455,6 +455,20 @@ sub _build_tainted_by { } } + require File::Find; + my %usr_local_types = ( + configs => [ qw(etc) ], + includes => [ qw(include) ], + programs => [ qw(bin sbin) ], + libraries => [ qw(lib) ], + ); + foreach my $type (keys %usr_local_types) { + File::Find::find({ + wanted => sub { $tainted{"usr-local-has-$type"} = 1 if -f }, + no_chdir => 1, + }, map { "/usr/local/$_" } @{$usr_local_types{$type}}); + } + my @tainted = sort keys %tainted; return @tainted; } -- cgit v1.2.3 From 41628ced3ebbdb2ed2219b5320b6301aee7d65be Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 1 Feb 2019 03:41:25 +0100 Subject: Dpkg::Source::Package: Add a missing use Dpkg::Source::Format Closes: #921031 Fixes: commit d1d35a56e401181b6d15baf474a7db21d3372a65 Diagnosed-by: Ian Jackson --- debian/changelog | 3 +++ scripts/Dpkg/Source/Package.pm | 1 + 2 files changed, 4 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 16ea0cf74..90edb01b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -29,6 +29,9 @@ dpkg (1.19.5) UNRELEASED; urgency=medium - Dpkg::Vendor::Debian: Add support for merged-usr-via-symlinks tainted tag. Suggested by Alexander E. Patrakov . - Dpkg::Vendor::Debian: Add support for usr-local-has-* tainted tags. + - Dpkg::Source::Package: Add a missing use Dpkg::Source::Format. + Diagnosed by Ian Jackson . + Closes: #921031 * Documentation: - start-stop-daemon(1): Document behavior of --pidfile security checks. Closes: #921557 diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 74daa712b..69c2a2976 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -56,6 +56,7 @@ use Dpkg::Exit qw(run_exit_handlers); use Dpkg::Path qw(check_files_are_the_same find_command); use Dpkg::IPC; use Dpkg::Vendor qw(run_vendor_hook); +use Dpkg::Source::Format; my $diff_ignore_default_regex = ' # Ignore general backup files -- cgit v1.2.3 From 7605ee419fa482baeb8db5ff42e3163df6ac51bd Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 22 Feb 2019 01:42:13 +0100 Subject: Dpkg::BuildOptions: Fix typo in POD --- scripts/Dpkg/BuildOptions.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/scripts/Dpkg/BuildOptions.pm b/scripts/Dpkg/BuildOptions.pm index 057dfc1e3..263381b49 100644 --- a/scripts/Dpkg/BuildOptions.pm +++ b/scripts/Dpkg/BuildOptions.pm @@ -164,7 +164,7 @@ Each feature is prefixed with a ‘B<+>’ or a ‘B<->’ character as a marker to enable or disable it. The special feature “B” can be used to act on all known features. -Unknown of malformed features will emit warnings. +Unknown or malformed features will emit warnings. =cut -- cgit v1.2.3 From 740c330ad0deb5d4894ad43619fc80cfa0cf8313 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 2 Mar 2019 02:41:40 +0100 Subject: Dpkg::Source::Package::V1: Change default build option style to -sa Using -sA by default means the user might lose data on overwrite if there is already a directory with the same name laying around. Closes: #910737 --- debian/changelog | 5 +++++ man/dpkg-source.man | 2 +- scripts/Dpkg/Source/Package/V1.pm | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 3346afa9e..dc7a3e4d6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -6,6 +6,11 @@ dpkg (1.19.6) UNRELEASED; urgency=medium free()s and the subsequent crashes. * libdpkg: Handle non end-of-tape errors from tar_header_decode(). * libdpkg: Use ERANGE instead of EINVAL for tar_atol8() out-of-range error. + * Perl modules: + - Dpkg::Source::Package::V1: Change default build option style to -sa. + Using -sA by default means the user might lose data on overwrite if + there is already a directory with the same name laying around. + Closes: #910737 * Packaging: - Update usertags. - Install a lintian profile for dpkg based on the debian profile, so that diff --git a/man/dpkg-source.man b/man/dpkg-source.man index 502c67311..09a2ec7bd 100644 --- a/man/dpkg-source.man +++ b/man/dpkg-source.man @@ -400,7 +400,7 @@ was specified (this is equivalent to or raise an error if .B \-sa was specified. -.B \-sA +.B \-sa is the default. .TP .B \-\-abort\-on\-upstream\-changes diff --git a/scripts/Dpkg/Source/Package/V1.pm b/scripts/Dpkg/Source/Package/V1.pm index 38c2498f4..be13750a4 100644 --- a/scripts/Dpkg/Source/Package/V1.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -267,7 +267,7 @@ sub do_build { 'argument (with v1.0 source package)')); } - $sourcestyle =~ y/X/A/; + $sourcestyle =~ y/X/a/; unless ($sourcestyle =~ m/[akpursnAKPUR]/) { usageerr(g_('source handling style -s%s not allowed with -b'), $sourcestyle); -- cgit v1.2.3 From ae3b466f03f30a71b31403dd1696ccda65e7177b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Mon, 11 Mar 2019 22:39:38 +0100 Subject: Dpkg::Source::Package: Handle Format field being undefined On source format 1.0, the default is for the debian/source/format file not being present, which means we'll start with an empty Format field name. Fixes: commit d1d35a56e401181b6d15baf474a7db21d3372a65 --- debian/changelog | 4 ++++ scripts/Dpkg/Source/Package.pm | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index dc7a3e4d6..ea6a844d9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,10 @@ dpkg (1.19.6) UNRELEASED; urgency=medium Using -sA by default means the user might lose data on overwrite if there is already a directory with the same name laying around. Closes: #910737 + - Dpkg::Source::Package: Handle Format field being undefined. On source + format 1.0, the default is for the debian/source/format file not being + present, which means we'll start with an empty Format field name. + Regression introduced in dpkg 1.19.3. * Packaging: - Update usertags. - Install a lintian profile for dpkg based on the debian profile, so that diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 69c2a2976..9cc5d178f 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -537,7 +537,8 @@ sub extract { } # Store format if non-standard so that next build keeps the same format - if ($self->{fields}{'Format'} ne '1.0' and + if ($self->{fields}{'Format'} and + $self->{fields}{'Format'} ne '1.0' and not $self->{options}{skip_debianization}) { my $srcdir = File::Spec->catdir($newdirectory, 'debian', 'source'); -- cgit v1.2.3 From 63b674de77ede42f1e9547ad760f3c83fd051a4e Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 23 May 2019 22:04:56 +0200 Subject: doc: Fix typos Warned-by: codespell --- ChangeLog.old | 2 +- debian/changelog | 3 ++- dselect/pkglist.h | 2 +- man/deb-buildinfo.man | 2 +- man/deb-src-rules.man | 2 +- man/dpkg-buildflags.man | 4 ++-- man/dpkg-query.man | 2 +- man/start-stop-daemon.man | 2 +- scripts/Dpkg/Changelog/Entry/Debian.pm | 2 +- t/codespell/stopwords | 13 +++++++++++++ 10 files changed, 24 insertions(+), 10 deletions(-) (limited to 'scripts/Dpkg') diff --git a/ChangeLog.old b/ChangeLog.old index 8cd7ba729..1889f112f 100644 --- a/ChangeLog.old +++ b/ChangeLog.old @@ -8312,7 +8312,7 @@ packages, sort that (rather than the complete list) and use that when calling list1package. This means we only expand to the longest field in the result, not the database. Hopefully the - speed gain of only sorting a filtered list outweighs the slighty + speed gain of only sorting a filtered list outweighs the slightly extra computation time. 2005-03-18 Scott James Remnant diff --git a/debian/changelog b/debian/changelog index 29cec6642..b30d204f3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ dpkg (1.19.7) UNRELEASED; urgency=medium the prototyping section to be less confusing with what is currently implemented. Closes: #929019 - README: Clarify when autopoint is needed. Closes: #929601 + - Fix typos in docs and output strings. Warned by codespell. [ Updated programs translations ] * Catalan (Guillem Jover). @@ -327,7 +328,7 @@ dpkg (1.19.3) unstable; urgency=medium * Test suite: - Add new shellcheck author test. - Add descriptions for the shellcheck exclude codes. - - Update cppcheck supressions. + - Update cppcheck suppressions. [ Updated programs translations ] * Dutch (Frans Spiesschaert). Closes: #912023 diff --git a/dselect/pkglist.h b/dselect/pkglist.h index f60a93169..3d46dcfd8 100644 --- a/dselect/pkglist.h +++ b/dselect/pkglist.h @@ -212,7 +212,7 @@ protected: explicit packagelist(keybindings *kb); // nonrecursive packagelist(keybindings *kb, pkginfo **pkgltab); // recursive - void add(pkginfo **arry) { while (*arry) add(*arry++); } + void add(pkginfo **array) { while (*array) add(*array++); } void add(pkginfo*); void add(pkginfo *, pkgwant); void add(pkginfo*, const char *extrainfo, showpriority displayimportance); diff --git a/man/deb-buildinfo.man b/man/deb-buildinfo.man index 691acb255..6a9d00b40 100644 --- a/man/deb-buildinfo.man +++ b/man/deb-buildinfo.man @@ -152,7 +152,7 @@ will emit this field. .B Build\-Tainted\-By: .TQ .I " taint-reason-list" -This folded field contains a space-separated list of non-exhausitve reason +This folded field contains a space-separated list of non-exhaustive reason tags (formed by alphanumeric and dash characters) which identify why the current build has been tainted (since dpkg 1.19.5). .IP diff --git a/man/deb-src-rules.man b/man/deb-src-rules.man index 19a8f7207..9fd8b30ba 100644 --- a/man/deb-src-rules.man +++ b/man/deb-src-rules.man @@ -40,7 +40,7 @@ This target will be called with root privileges. .B build\-indep Build architecture independent files required to build any architecture independent binary package. -If there are no architecture indepdenent binary packages to generate, +If there are no architecture independent binary packages to generate, the target must still exist but do nothing. This target must not require root privileges. .TP diff --git a/man/dpkg-buildflags.man b/man/dpkg-buildflags.man index ba18dbbb7..f352c18ee 100644 --- a/man/dpkg-buildflags.man +++ b/man/dpkg-buildflags.man @@ -107,7 +107,7 @@ This is a legacy alias for \fBcmdline\fP. .TP .B make Make directives to set and export all the compilation flags in the -environment. Output can be written to a makefile fragment and +environment. Output can be written to a Makefile fragment and evaluated using an \fBinclude\fP directive. .RE .TP @@ -575,7 +575,7 @@ Makefile snippet that will load (and optionally export) all flags supported by \fBdpkg-buildflags\fP into variables (since dpkg 1.16.1). . .SH EXAMPLES -To pass build flags to a build command in a makefile: +To pass build flags to a build command in a Makefile: .PP .RS 4 .nf diff --git a/man/dpkg-query.man b/man/dpkg-query.man index de14b9afe..1358d0c0b 100644 --- a/man/dpkg-query.man +++ b/man/dpkg-query.man @@ -140,7 +140,7 @@ for that, this command will not get removed. Search for packages that own files corresponding to the given pattern. Standard shell wildcard characters can be used in the pattern, where asterisk (\fB*\fP) and question mark (\fB?\fP) will match a slash, -and blackslash (\fB\\\fP) will be used as an escape character. +and backslash (\fB\\\fP) will be used as an escape character. If the first character in the \fIfilename-search-pattern\fP is none of ‘\fB*[?/\fP’ then it will be considered a substring match and will be diff --git a/man/start-stop-daemon.man b/man/start-stop-daemon.man index 2a083f34c..d5a53ccff 100644 --- a/man/start-stop-daemon.man +++ b/man/start-stop-daemon.man @@ -272,7 +272,7 @@ code for them to do this themselves. .BR \-\-notify\-await Wait for the background process to send a readiness notification before considering the service started (since version 1.19.3). -This implements parts of the systemd readiness procotol, as specified +This implements parts of the systemd readiness protocol, as specified in the \fBsd_notify\fP(3) man page. The following variables are supported: .RS diff --git a/scripts/Dpkg/Changelog/Entry/Debian.pm b/scripts/Dpkg/Changelog/Entry/Debian.pm index 3d1888638..5f4c9e569 100644 --- a/scripts/Dpkg/Changelog/Entry/Debian.pm +++ b/scripts/Dpkg/Changelog/Entry/Debian.pm @@ -236,7 +236,7 @@ sub parse_trailer { push @errors, sprintf(g_('invalid abbreviated month name \'%s\''), $8); } } - push @errors, sprintf(g_("cannot parse non-comformant date '%s'"), $7); + push @errors, sprintf(g_("cannot parse non-conformant date '%s'"), $7); }; $self->{trailer_timestamp_date} = $4; } else { diff --git a/t/codespell/stopwords b/t/codespell/stopwords index 1909fdd40..75dcb1767 100644 --- a/t/codespell/stopwords +++ b/t/codespell/stopwords @@ -1,12 +1,25 @@ +accreting +ba cas chage +chang +claus cmo creat +files' +finitel +fo iff isnt +ist +ists lowercased mitre +msdos objext +od +packages' +process' readded rela te -- cgit v1.2.3 From 9229100918a1741ceb4b0f60636869cfc9432731 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Thu, 2 May 2019 02:58:32 +0200 Subject: scripts: Remove support for versioned GnuPG 2 program and packages The current default in Debian and anywhere else is to use unversioned GnuPG 2.x binaries, so there's no need anymore to try these first or at all. --- debian/changelog | 1 + debian/control | 8 ++++---- man/dpkg-buildpackage.man | 7 +++---- scripts/Dpkg/Source/Package.pm | 6 +----- scripts/dpkg-buildpackage.pl | 6 ++---- 5 files changed, 11 insertions(+), 17 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 3581597c1..bb386ab0b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium * dpkg-shlibdeps: Add support for new Build-Depends-Packages, to be able to specify multiple packages. Closes: #926669 Based on a patch by Frank Schaefer . + * perl: Remove support for versioned GnuPG 2 program and packages. * Documentation: - man: Fix uncommon wording constructs. * Build system: diff --git a/debian/control b/debian/control index 63b5c7f26..bd1a3619f 100644 --- a/debian/control +++ b/debian/control @@ -101,8 +101,8 @@ Recommends: build-essential, gcc | c-compiler, fakeroot, - gnupg | gnupg2, - gpgv | gpgv2, + gnupg, + gpgv, # Used by dpkg-mergechangelogs. libalgorithm-merge-perl, Suggests: @@ -136,8 +136,8 @@ Recommends: xz-utils, Suggests: debian-keyring, - gnupg | gnupg2, - gpgv | gpgv2, + gnupg, + gpgv, gcc | c-compiler, binutils, patch, diff --git a/man/dpkg-buildpackage.man b/man/dpkg-buildpackage.man index d60b09f54..6a6965f2f 100644 --- a/man/dpkg-buildpackage.man +++ b/man/dpkg-buildpackage.man @@ -90,7 +90,7 @@ It runs the \fBcheck\fP hook and calls a package checker for the \fB.changes\fP file (if a command is specified in \fBDEB_CHECK_COMMAND\fP or with \fB\-\-check\-command\fP). .IP \fB11.\fP 3 -It runs the \fBsign\fP hook and calls \fBgpg2\fP or \fBgpg\fP (as long as it +It runs the \fBsign\fP hook and calls \fBgpg\fP (as long as it is not an UNRELEASED build, or \fB\-\-no\-sign\fP is specified) to sign the \fB.dsc\fP file (if any, unless \fB\-us\fP or \fB\-\-unsigned\-source\fP is specified), the \fB.buildinfo\fP @@ -399,9 +399,9 @@ Can be used multiple times. When \fBdpkg\-buildpackage\fP needs to execute GPG to sign a source control (\fB.dsc\fP) file or a \fB.changes\fP file it will run \fIsign-command\fP (searching the \fBPATH\fP if necessary) instead of -\fBgpg2\fP or \fBgpg\fP (long option since dpkg 1.18.8). +\fBgpg\fP (long option since dpkg 1.18.8). \fIsign-command\fP will get all the arguments -that \fBgpg2\fP or \fBgpg\fP would have gotten. \fIsign-command\fP +that \fBgpg\fP would have gotten. \fIsign-command\fP should not contain spaces or any other shell metacharacters. .TP .BR \-k ", " \-\-sign\-key= \fIkey-id\fP @@ -584,5 +584,4 @@ and initial arguments for .BR dpkg\-genchanges (1), .BR fakeroot (1), .BR lintian (1), -.BR gpg2 (1), .BR gpg (1). diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 9cc5d178f..df3ac8737 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -428,12 +428,8 @@ sub check_signature { my $dsc = $self->get_filename(); my @exec; - if (find_command('gpgv2')) { - push @exec, 'gpgv2'; - } elsif (find_command('gpgv')) { + if (find_command('gpgv')) { push @exec, 'gpgv'; - } elsif (find_command('gpg2')) { - push @exec, 'gpg2', '--no-default-keyring', '-q', '--verify'; } elsif (find_command('gpg')) { push @exec, 'gpg', '--no-default-keyring', '-q', '--verify'; } diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl index 81c6f57c7..e48f972a9 100755 --- a/scripts/dpkg-buildpackage.pl +++ b/scripts/dpkg-buildpackage.pl @@ -101,7 +101,7 @@ sub usage { pass option to dpkg-genbuildinfo. -p, --sign-command= command to sign .dsc and/or .changes files - (default is gpg2 or gpg). + (default is gpg). -k, --sign-key= the key to use for signing. -ap, --sign-pause add pause before starting signature process. -us, --unsigned-source unsigned source package. @@ -394,9 +394,7 @@ if ($signcommand) { } } elsif (($ENV{GNUPGHOME} && -e $ENV{GNUPGHOME}) || ($ENV{HOME} && -e "$ENV{HOME}/.gnupg")) { - if (find_command('gpg2')) { - $signcommand = 'gpg2'; - } elsif (find_command('gpg')) { + if (find_command('gpg')) { $signcommand = 'gpg'; } } -- cgit v1.2.3 From 522e3b46ee9861f6e1b87124066d716a5b6a6c0c Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 1 May 2019 23:18:34 +0200 Subject: Dpkg::Source::Package: Refactor original tarball handling --- debian/changelog | 2 ++ scripts/Dpkg/Source/Package/V1.pm | 8 +++++--- scripts/Dpkg/Source/Package/V2.pm | 32 ++++++++++++++------------------ 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index bb386ab0b..bcec8748f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium * perl: Remove support for versioned GnuPG 2 program and packages. * Documentation: - man: Fix uncommon wording constructs. + * Code internals: + - Dpkg::Source::Package: Refactor original tarball handling. * Build system: - Bump minimal Perl version to 5.24.1. diff --git a/scripts/Dpkg/Source/Package/V1.pm b/scripts/Dpkg/Source/Package/V1.pm index be13750a4..ff683af21 100644 --- a/scripts/Dpkg/Source/Package/V1.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -409,9 +409,11 @@ sub do_build { $sourcepackage, $tarname); } - $self->add_file($tarname) if $tarname; - if ($tarname and -e "$tarname.sig" and not -e "$tarname.asc") { - openpgp_sig_to_asc("$tarname.sig", "$tarname.asc"); + if ($tarname) { + $self->add_file($tarname); + if (-e "$tarname.sig" and not -e "$tarname.asc") { + openpgp_sig_to_asc("$tarname.sig", "$tarname.asc"); + } } if ($tarsign and -e $tarsign) { info(g_('building %s using existing %s'), $sourcepackage, $tarsign); diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index e2c1b49fb..db9bd3e71 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -408,26 +408,22 @@ sub _generate_patch { 'one is allowed'), $tarfile, $file); } $tarfile = $file; - push @origtarfiles, $file; - $self->add_file($file); - if (-e "$file.sig" and not -e "$file.asc") { - openpgp_sig_to_asc("$file.sig", "$file.asc"); - } - if (-e "$file.asc") { - push @origtarfiles, "$file.asc"; - $self->add_file("$file.asc") - } } elsif ($file =~ /\.orig-([[:alnum:]-]+)\.tar\.$comp_ext_regex$/) { $addonfile{$1} = $file; - push @origtarfiles, $file; - $self->add_file($file); - if (-e "$file.sig" and not -e "$file.asc") { - openpgp_sig_to_asc("$file.sig", "$file.asc"); - } - if (-e "$file.asc") { - push @origtarfiles, "$file.asc"; - $self->add_file("$file.asc"); - } + } else { + next; + } + + push @origtarfiles, $file; + $self->add_file($file); + + # Check for an upstream signature. + if (-e "$file.sig" and not -e "$file.asc") { + openpgp_sig_to_asc("$file.sig", "$file.asc"); + } + if (-e "$file.asc") { + push @origtarfiles, "$file.asc"; + $self->add_file("$file.asc") } } -- cgit v1.2.3 From 1973a0789cea5ac0e7da10a81cc5cca8384200df Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 1 May 2019 23:19:17 +0200 Subject: perl: Use File::Copy instead of spawning mv/cp commands We use cp() in Dpkg::Source::Package to preserve the file attributes, but just move() in dpkg-buildpackage where it does not matter. --- debian/changelog | 1 + scripts/Dpkg/Source/Package.pm | 5 +++-- scripts/dpkg-buildpackage.pl | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index bcec8748f..0418c6fe6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - man: Fix uncommon wording constructs. * Code internals: - Dpkg::Source::Package: Refactor original tarball handling. + - perl: Use File::Copy instead of spawning mv/cp commands. * Build system: - Bump minimal Perl version to 5.24.1. diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index df3ac8737..e800a6392 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -44,6 +44,7 @@ our @EXPORT_OK = qw( use Exporter qw(import); use POSIX qw(:errno_h :sys_wait_h); use Carp; +use File::Copy qw(cp); use File::Basename; use Dpkg::Gettext; @@ -519,8 +520,8 @@ sub extract { my $src = File::Spec->catfile($self->{basedir}, $orig); my $dst = File::Spec->catfile($destdir, $orig); if (not check_files_are_the_same($src, $dst, 1)) { - system('cp', '--', $src, $dst); - subprocerr("cp $src to $dst") if $?; + cp($src, $dst) + or syserror(g_('cannot copy %s to %s'), $src, $dst); } } } diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl index e48f972a9..2c49738b5 100755 --- a/scripts/dpkg-buildpackage.pl +++ b/scripts/dpkg-buildpackage.pl @@ -851,8 +851,8 @@ sub signfile { '--output', "$signfile.asc", $signfile); my $status = $?; if ($status == 0) { - system('mv', '--', "$signfile.asc", "../$file") - and subprocerr('mv'); + move("$signfile.asc", "../$file") + or syserror(g_('cannot move %s to %s'), "$signfile.asc", "../$file"); } print "\n"; -- cgit v1.2.3 From 139dfc4c78593d995610c0aa180300a9a7dd94ac Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 1 May 2019 23:20:38 +0200 Subject: Dpkg::OpenPGP: Refactor signature verification into a new function --- debian/changelog | 1 + scripts/Dpkg/OpenPGP.pm | 40 +++++++++++++++++++++++++++++++++++ scripts/Dpkg/Source/Package.pm | 47 ++++++++---------------------------------- 3 files changed, 50 insertions(+), 38 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 0418c6fe6..42e536756 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium * Code internals: - Dpkg::Source::Package: Refactor original tarball handling. - perl: Use File::Copy instead of spawning mv/cp commands. + - Dpkg::OpenPGP: Refactor signature verification into a new function. * Build system: - Bump minimal Perl version to 5.24.1. diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm index f719e6e4e..234c90a4d 100644 --- a/scripts/Dpkg/OpenPGP.pm +++ b/scripts/Dpkg/OpenPGP.pm @@ -18,6 +18,7 @@ package Dpkg::OpenPGP; use strict; use warnings; +use POSIX qw(:sys_wait_h); use Exporter qw(import); use File::Copy; @@ -80,4 +81,43 @@ sub openpgp_sig_to_asc return; } +sub verify_signature { + my ($sig, %opts) = @_; + + $opts{require_valid_signature} //= 1; + + my @exec; + if (find_command('gpgv')) { + push @exec, 'gpgv'; + } elsif (find_command('gpg')) { + push @exec, 'gpg', '--no-default-keyring', '-q', '--verify'; + } elsif ($opts{require_valid_signature}) { + error(g_('cannot verify signature on %s since GnuPG is not installed'), + $sig); + } else { + warning(g_('cannot verify signature on %s since GnuPG is not installed'), + $sig); + return; + } + foreach my $keyring (@{$opts{keyrings}}) { + push @exec, '--keyring', $keyring; + } + push @exec, $sig; + + my ($stdout, $stderr); + spawn(exec => \@exec, wait_child => 1, nocheck => 1, timeout => 10, + to_string => \$stdout, error_to_string => \$stderr); + if (WIFEXITED($?)) { + my $status = WEXITSTATUS($?); + print { *STDERR } "$stdout$stderr" if $status; + if ($status == 1 or ($status && $opts{require_valid_signature})) { + error(g_('failed to verify signature on %s'), $sig); + } elsif ($status) { + warning(g_('failed to verify signature on %s'), $sig); + } + } else { + subprocerr("@exec"); + } +} + 1; diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index e800a6392..e7c4fb22d 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -58,6 +58,7 @@ use Dpkg::Path qw(check_files_are_the_same find_command); use Dpkg::IPC; use Dpkg::Vendor qw(run_vendor_hook); use Dpkg::Source::Format; +use Dpkg::OpenPGP; my $diff_ignore_default_regex = ' # Ignore general backup files @@ -427,48 +428,18 @@ then any problem will result in a fatal error. sub check_signature { my $self = shift; my $dsc = $self->get_filename(); - my @exec; + my @keyrings; - if (find_command('gpgv')) { - push @exec, 'gpgv'; - } elsif (find_command('gpg')) { - push @exec, 'gpg', '--no-default-keyring', '-q', '--verify'; + if (length $ENV{HOME} and -r "$ENV{HOME}/.gnupg/trustedkeys.gpg") { + push @keyrings, "$ENV{HOME}/.gnupg/trustedkeys.gpg"; } - if (scalar(@exec)) { - if (length $ENV{HOME} and -r "$ENV{HOME}/.gnupg/trustedkeys.gpg") { - push @exec, '--keyring', "$ENV{HOME}/.gnupg/trustedkeys.gpg"; - } - foreach my $vendor_keyring (run_vendor_hook('package-keyrings')) { - if (-r $vendor_keyring) { - push @exec, '--keyring', $vendor_keyring; - } - } - push @exec, $dsc; - - my ($stdout, $stderr); - spawn(exec => \@exec, wait_child => 1, nocheck => 1, - to_string => \$stdout, error_to_string => \$stderr, - timeout => 10); - if (WIFEXITED($?)) { - my $gpg_status = WEXITSTATUS($?); - print { *STDERR } "$stdout$stderr" if $gpg_status; - if ($gpg_status == 1 or ($gpg_status && - $self->{options}{require_valid_signature})) - { - error(g_('failed to verify signature on %s'), $dsc); - } elsif ($gpg_status) { - warning(g_('failed to verify signature on %s'), $dsc); - } - } else { - subprocerr("@exec"); - } - } else { - if ($self->{options}{require_valid_signature}) { - error(g_('cannot verify signature on %s since GnuPG is not installed'), $dsc); - } else { - warning(g_('cannot verify signature on %s since GnuPG is not installed'), $dsc); + foreach my $vendor_keyring (run_vendor_hook('package-keyrings')) { + if (-r $vendor_keyring) { + push @keyrings, $vendor_keyring; } } + + Dpkg::OpenPGP::verify_signature($dsc, keyrings => \@keyrings); } sub describe_cmdline_options { -- cgit v1.2.3 From e4f9fc7a5040f0eeef330e82bdeda6483bbd8a50 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 31 Aug 2019 03:55:10 +0200 Subject: Dpkg::OpenPGP: Make it possible to verify detached signatures This is required to be able to verify original upstream tarball signatures, as they are expected to be ASCII armored detached signatures for the upstream tarballs. --- debian/changelog | 1 + scripts/Dpkg/OpenPGP.pm | 1 + 2 files changed, 2 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 42e536756..876e3460b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Source::Package: Refactor original tarball handling. - perl: Use File::Copy instead of spawning mv/cp commands. - Dpkg::OpenPGP: Refactor signature verification into a new function. + - Dpkg::OpenPGP: Make it possible to verify detached signatures. * Build system: - Bump minimal Perl version to 5.24.1. diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm index 234c90a4d..f207af228 100644 --- a/scripts/Dpkg/OpenPGP.pm +++ b/scripts/Dpkg/OpenPGP.pm @@ -103,6 +103,7 @@ sub verify_signature { push @exec, '--keyring', $keyring; } push @exec, $sig; + push @exec, $opts{datafile} if exists $opts{datafile}; my ($stdout, $stderr); spawn(exec => \@exec, wait_child => 1, nocheck => 1, timeout => 10, -- cgit v1.2.3 From 2f238b0e7286d401acd1325e30c86363a1e380db Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 1 May 2019 23:23:03 +0200 Subject: Dpkg::OpenPGP: Add support for importing an OpenPGP key into a keyring This is needed, for example, to verify original tarball signatures. --- debian/changelog | 1 + scripts/Dpkg/OpenPGP.pm | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 876e3460b..168e2d281 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,6 +23,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - perl: Use File::Copy instead of spawning mv/cp commands. - Dpkg::OpenPGP: Refactor signature verification into a new function. - Dpkg::OpenPGP: Make it possible to verify detached signatures. + - Dpkg::OpenPGP: Add support for importing an OpenPGP key into a keyring. * Build system: - Bump minimal Perl version to 5.24.1. diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm index f207af228..f08bd3b12 100644 --- a/scripts/Dpkg/OpenPGP.pm +++ b/scripts/Dpkg/OpenPGP.pm @@ -81,6 +81,42 @@ sub openpgp_sig_to_asc return; } +sub import_key { + my ($asc, %opts) = @_; + + $opts{require_valid_signature} //= 1; + + my @exec; + if (find_command('gpg')) { + push @exec, 'gpg'; + } elsif ($opts{require_valid_signature}) { + error(g_('cannot import key in %s since GnuPG is not installed'), + $asc); + } else { + warning(g_('cannot import key in %s since GnuPG is not installed'), + $asc); + return; + } + push @exec, '--no-options', '--no-default-keyring', '-q', '--import'; + push @exec, '--keyring', $opts{keyring}; + push @exec, $asc; + + my ($stdout, $stderr); + spawn(exec => \@exec, wait_child => 1, nocheck => 1, timeout => 10, + to_string => \$stdout, error_to_string => \$stderr); + if (WIFEXITED($?)) { + my $status = WEXITSTATUS($?); + print { *STDERR } "$stdout$stderr" if $status; + if ($status == 1 or ($status && $opts{require_valid_signature})) { + error(g_('failed to import key in %s'), $asc); + } elsif ($status) { + warning(g_('failed to import key in %s'), $asc); + } + } else { + subprocerr("@exec"); + } +} + sub verify_signature { my ($sig, %opts) = @_; -- cgit v1.2.3 From 3821f024d92aabf24a333025c1c1956d8a45e718 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 1 May 2019 23:23:03 +0200 Subject: Dpkg::Source::Package: Verify original tarball signatures at build time When we are building the source package, while detecting whether there is any original upstream tarball signature to be included in the .dsc, it's the best time to verify them, so that when the .dsc gets eventually signed there's a certification path for the maintainer that they are including what they expected to be there. --- debian/changelog | 2 ++ scripts/Dpkg/Source/Package.pm | 36 ++++++++++++++++++++++++++++++++++-- scripts/Dpkg/Source/Package/V1.pm | 2 ++ scripts/Dpkg/Source/Package/V2.pm | 4 ++++ 4 files changed, 42 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 168e2d281..16428b983 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,6 +16,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium to specify multiple packages. Closes: #926669 Based on a patch by Frank Schaefer . * perl: Remove support for versioned GnuPG 2 program and packages. + * Perl modules: + - Dpkg::Source::Package: Verify original tarball signatures at build time. * Documentation: - man: Fix uncommon wording constructs. * Code internals: diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index e7c4fb22d..35bdbafa1 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -1,5 +1,5 @@ # Copyright © 2008-2011 Raphaël Hertzog -# Copyright © 2008-2015 Guillem Jover +# Copyright © 2008-2019 Guillem Jover # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,7 +34,7 @@ is the one that supports the extraction of the source package. use strict; use warnings; -our $VERSION = '1.03'; +our $VERSION = '1.04'; our @EXPORT_OK = qw( get_default_diff_ignore_regex set_default_diff_ignore_regex @@ -44,6 +44,7 @@ our @EXPORT_OK = qw( use Exporter qw(import); use POSIX qw(:errno_h :sys_wait_h); use Carp; +use File::Temp; use File::Copy qw(cp); use File::Basename; @@ -403,6 +404,33 @@ sub find_original_tarballs { return @tar; } +=item $p->check_original_tarball_signature($dir, @asc) + +Verify the original upstream tarball signatures @asc using the upstream +public keys. It requires the origin upstream tarballs, their signatures +and the upstream signing key, as found in an unpacked source tree $dir. +If any inconsistency is discovered, it immediately errors out. + +=cut + +sub check_original_tarball_signature { + my ($self, $dir, @asc) = @_; + + my $upstream_key = "$dir/debian/upstream/signing-key.asc"; + if (not -e $upstream_key) { + warning(g_('upstream tarball signatures but no upstream signing key')); + return; + } + + my $keyring = File::Temp->new(UNLINK => 1, SUFFIX => '.gpg'); + Dpkg::OpenPGP::import_key($upstream_key, keyring => $keyring); + foreach my $asc (@asc) { + Dpkg::OpenPGP::verify_signature($asc, + datafile => $asc =~ s/\.asc$//r, + keyrings => [ $keyring ]); + } +} + =item $bool = $p->is_signed() Returns 1 if the DSC files contains an embedded OpenPGP signature. @@ -632,6 +660,10 @@ sub write_dsc { =head1 CHANGES +=head2 Version 1.04 (dpkg 1.20.0) + +New method: check_original_tarball_signature(). + =head2 Version 1.03 (dpkg 1.19.3) New option: format in new(). diff --git a/scripts/Dpkg/Source/Package/V1.pm b/scripts/Dpkg/Source/Package/V1.pm index ff683af21..d91cea03b 100644 --- a/scripts/Dpkg/Source/Package/V1.pm +++ b/scripts/Dpkg/Source/Package/V1.pm @@ -418,6 +418,8 @@ sub do_build { if ($tarsign and -e $tarsign) { info(g_('building %s using existing %s'), $sourcepackage, $tarsign); $self->add_file($tarsign); + + $self->check_original_tarball_signature($tarsign); } if ($sourcestyle =~ m/[kpKP]/) { diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index db9bd3e71..3da317550 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -401,6 +401,7 @@ sub _generate_patch { my ($tarfile, %addonfile); my $comp_ext_regex = compression_get_file_extension_regex(); my @origtarfiles; + my @origtarsigns; foreach my $file (sort $self->find_original_tarballs()) { if ($file =~ /\.orig\.tar\.$comp_ext_regex$/) { if (defined($tarfile)) { @@ -423,6 +424,7 @@ sub _generate_patch { } if (-e "$file.asc") { push @origtarfiles, "$file.asc"; + push @origtarsigns, "$file.asc"; $self->add_file("$file.asc") } } @@ -435,6 +437,8 @@ sub _generate_patch { info(g_('building %s using existing %s'), $self->{fields}{'Source'}, $origtarfile); } + + $self->check_original_tarball_signature(@origtarsigns); } # Unpack a second copy for comparison -- cgit v1.2.3 From 0e1709f6f4002a87bff1b0caa495ded77dd38d1f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 30 Jul 2019 04:45:36 +0200 Subject: Dpkg::BuildFlags: Remove unused hash keys --- debian/changelog | 1 + scripts/Dpkg/BuildFlags.pm | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 36ae294bd..ada26a5a2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -33,6 +33,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::OpenPGP: Refactor signature verification into a new function. - Dpkg::OpenPGP: Make it possible to verify detached signatures. - Dpkg::OpenPGP: Add support for importing an OpenPGP key into a keyring. + - Dpkg::BuildFlags: Remove unused hash keys. * Build system: - Bump minimal Perl version to 5.24.1. - Add a serial versioning to the m4 files. diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm index a8fd4584a..906527b23 100644 --- a/scripts/Dpkg/BuildFlags.pm +++ b/scripts/Dpkg/BuildFlags.pm @@ -68,8 +68,6 @@ Reset the flags stored to the default set provided by the vendor. sub load_vendor_defaults { my $self = shift; - $self->{options} = {}; - $self->{source} = {}; $self->{features} = {}; $self->{flags} = { CPPFLAGS => '', -- cgit v1.2.3 From 36925e06749e495a475f6c42543b226d3f7ae27b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 30 Jul 2019 04:45:57 +0200 Subject: Dpkg::BuildFlags: Add new unset() method This makes it possible to unset variables, so that they do not get output by the various tools. Requested-by: Daniel Schepler --- debian/changelog | 2 ++ scripts/Dpkg/BuildFlags.pm | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index ada26a5a2..a18c3b892 100644 --- a/debian/changelog +++ b/debian/changelog @@ -21,6 +21,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium never the correct solution. * Perl modules: - Dpkg::Source::Package: Verify original tarball signatures at build time. + - Dpkg::BuildFlags: Add new unset() method. + Requested by Daniel Schepler . * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm index 906527b23..edf16e4f3 100644 --- a/scripts/Dpkg/BuildFlags.pm +++ b/scripts/Dpkg/BuildFlags.pm @@ -18,7 +18,7 @@ package Dpkg::BuildFlags; use strict; use warnings; -our $VERSION = '1.03'; +our $VERSION = '1.04'; use Dpkg (); use Dpkg::Gettext; @@ -212,6 +212,20 @@ sub load_config { $self->load_maintainer_config(); } +=item $bf->unset($flag) + +Unset the build flag $flag, so that it will not be known anymore. + +=cut + +sub unset { + my ($self, $flag) = @_; + + delete $self->{flags}->{$flag}; + delete $self->{origin}->{$flag}; + delete $self->{maintainer}->{$flag}; +} + =item $bf->set($flag, $value, $source, $maint) Update the build flag $flag with value $value and record its origin as @@ -440,6 +454,10 @@ sub list { =head1 CHANGES +=head2 Version 1.04 (dpkg 1.20.0) + +New method: $bf->unset(). + =head2 Version 1.03 (dpkg 1.16.5) New method: $bf->get_feature_areas() to list possible values for -- cgit v1.2.3 From ae231c65b162df729a6492105a0ce64945e293c2 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 30 Jul 2019 04:57:47 +0200 Subject: Dpkg::Source::Package::V2: Emit a special patch header on single-debian-patch The previous default patch header does not make sense for a conglomerate patch. Instead provide a more suitable default, that can always be overridden with either the local-patch-header or patch-header files. Closes: #933152 --- debian/changelog | 2 ++ scripts/Dpkg/Source/Package/V2.pm | 12 ++++++++++++ 2 files changed, 14 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index a18c3b892..e559872dd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,6 +23,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Source::Package: Verify original tarball signatures at build time. - Dpkg::BuildFlags: Add new unset() method. Requested by Daniel Schepler . + - Dpkg::Source::Package::V2: Emit a special patch header on + single-debian-patch. Closes: #933152 * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Source/Package/V2.pm b/scripts/Dpkg/Source/Package/V2.pm index 3da317550..d84fce2dd 100644 --- a/scripts/Dpkg/Source/Package/V2.pm +++ b/scripts/Dpkg/Source/Package/V2.pm @@ -587,6 +587,7 @@ sub do_build { sub _get_patch_header { my ($self, $dir) = @_; + my $ph = File::Spec->catfile($dir, 'debian', 'source', 'local-patch-header'); unless (-f $ph) { $ph = File::Spec->catfile($dir, 'debian', 'source', 'patch-header'); @@ -594,6 +595,17 @@ sub _get_patch_header { if (-f $ph) { return file_slurp($ph); } + + if ($self->{options}->{single_debian_patch}) { + return <<'AUTOGEN_HEADER'; +This is an autogenerated patch header for a single-debian-patch file. The +delta against upstream is either kept as a single patch, or maintained +in some VCS, and exported as a single patch instead of more manageable +atomic patches. + +AUTOGEN_HEADER + } + my $ch_info = changelog_parse(offset => 0, count => 1, file => File::Spec->catfile($dir, 'debian', 'changelog')); return '' if not defined $ch_info; -- cgit v1.2.3 From 63e9d12972c866ed02aca040501de1d9b922e880 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 9 Aug 2019 04:30:42 +0200 Subject: Dpkg::Changelog: Document methods provided by subclasses Reported-by: Felix Lechner --- debian/changelog | 2 ++ scripts/Dpkg/Changelog.pm | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index e559872dd..d1fbe287a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,6 +31,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - man: Clarify that the pager is called via «$SHELL -c». - dpkg-shlibdeps: Document split_soname() function. Prompted by Christopher Crim . + - Dpkg::Changelog: Document methods provided by subclasses. + Reported by Felix Lechner . * Code internals: - Dpkg::Source::Package: Refactor original tarball handling. - perl: Use File::Copy instead of spawning mv/cp commands. diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index 47752b911..060081079 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -90,6 +90,22 @@ sub set_options { $self->{$_} = $opts{$_} foreach keys %opts; } +=item $count = $c->parse($fh, $description) + +Read the filehandle and parse a changelog in it. The data in the object is +reset before parsing new data. + +Returns the number of changelog entries that have been parsed with success. + +This method needs to be implemented by one of the specialized changelog +format subclasses. + +=item $count = $c->load($filename) + +Parse $filename contents for a changelog. + +Returns the number of changelog entries that have been parsed with success. + =item $c->reset_parse_errors() Can be used to delete all information about errors occurred during -- cgit v1.2.3 From 79d01b9283bb8c5c9867a9601a4b3011f207684f Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 3 Nov 2019 01:34:29 +0100 Subject: Dpkg::Vendor::Debian: Only scan /usr/local/ directories that exist Closes: #932967 --- debian/changelog | 2 ++ scripts/Dpkg/Vendor/Debian.pm | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index f6f70357e..f9698ef17 100644 --- a/debian/changelog +++ b/debian/changelog @@ -40,6 +40,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium Requested by Daniel Schepler . - Dpkg::Source::Package::V2: Emit a special patch header on single-debian-patch. Closes: #933152 + - Dpkg::Vendor::Debian: Only scan /usr/local/ directories that exist. + Closes: #932967 * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index a352bbdde..65c7f2bad 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -466,7 +466,7 @@ sub _build_tainted_by { File::Find::find({ wanted => sub { $tainted{"usr-local-has-$type"} = 1 if -f }, no_chdir => 1, - }, map { "/usr/local/$_" } @{$usr_local_types{$type}}); + }, grep { -d } map { "/usr/local/$_" } @{$usr_local_types{$type}}); } my @tainted = sort keys %tainted; -- cgit v1.2.3 From 35430c52c8b8b311985535b46bd7ba592bb5d805 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 3 Nov 2019 16:29:05 +0100 Subject: Dpkg::Vendor::Debian: Do not set -Werror=implicit-function-declaration for C++ Closes: #939969 --- debian/changelog | 2 ++ scripts/Dpkg/Vendor/Debian.pm | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index f9698ef17..abd1c27f1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -42,6 +42,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium single-debian-patch. Closes: #933152 - Dpkg::Vendor::Debian: Only scan /usr/local/ directories that exist. Closes: #932967 + - Dpkg::Vendor::Debian: Do not set -Werror=implicit-function-declaration + for C++. Closes: #939969 * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 65c7f2bad..71aa59038 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -185,8 +185,21 @@ sub _add_build_flags { # Warnings that detect actual bugs. if ($use_feature{qa}{bug}) { - foreach my $warnflag (qw(array-bounds clobbered volatile-register-var - implicit-function-declaration)) { + # C flags + my @cflags = qw( + implicit-function-declaration + ); + foreach my $warnflag (@cflags) { + $flags->append('CFLAGS', "-Werror=$warnflag"); + } + + # C/C++ flags + my @cfamilyflags = qw( + array-bounds + clobbered + volatile-register-var + ); + foreach my $warnflag (@cfamilyflags) { $flags->append('CFLAGS', "-Werror=$warnflag"); $flags->append('CXXFLAGS', "-Werror=$warnflag"); } -- cgit v1.2.3 From b958054076c236d470f46f35b94ee16a032ed368 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sun, 3 Nov 2019 17:36:02 +0100 Subject: Dpkg::Deps: Check for valid virtual package version relations Do not allow non-equal version relations in virtual provides. Closes: #930317 --- debian/changelog | 2 ++ scripts/Dpkg/Deps.pm | 19 ++++++++++++++++++- scripts/dpkg-checkbuilddeps.pl | 2 +- scripts/dpkg-gencontrol.pl | 2 +- 4 files changed, 22 insertions(+), 3 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index abd1c27f1..8b5317f07 100644 --- a/debian/changelog +++ b/debian/changelog @@ -44,6 +44,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium Closes: #932967 - Dpkg::Vendor::Debian: Do not set -Werror=implicit-function-declaration for C++. Closes: #939969 + - Dpkg::Deps: Check for valid virtual package version relations. Do not + allow non-equal version relations in virtual provides. Closes: #930317 * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index f3a19e78e..ec02fd8c8 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -46,7 +46,7 @@ All the deps_* functions are exported by default. use strict; use warnings; -our $VERSION = '1.06'; +our $VERSION = '1.07'; our @EXPORT = qw( deps_concat deps_parse @@ -235,6 +235,12 @@ them if set. If set to 1, returns a Dpkg::Deps::Union instead of a Dpkg::Deps::AND. Use this when parsing non-dependency fields like Conflicts. +=item virtual (defaults to 0) + +If set to 1, allow only virtual package version relations, that is none, +or “=”. +This should be set whenever working with Provides fields. + =item build_dep (defaults to 0) If set to 1, allow build-dep only arch qualifiers, that is “:native”. @@ -265,6 +271,7 @@ sub deps_parse { $options{reduce_profiles} //= 0; $options{reduce_restrictions} //= 0; $options{union} //= 0; + $options{virtual} //= 0; $options{build_dep} //= 0; $options{tests_dep} //= 0; @@ -301,6 +308,12 @@ sub deps_parse { warning(g_("can't parse dependency %s"), $dep_or); return; } + if ($options{virtual} && defined $dep_simple->{relation} && + $dep_simple->{relation} ne '=') { + warning(g_('virtual dependency contains invalid relation: %s'), + $dep_simple->output); + return; + } $dep_simple->{arches} = undef if not $options{use_arch}; if ($options{reduce_arch}) { $dep_simple->reduce_arch($options{host_arch}); @@ -437,6 +450,10 @@ provide. =head1 CHANGES +=head2 Version 1.07 (dpkg 1.20.0) + +New option: Add virtual option to Dpkg::Deps::deps_parse(). + =head2 Version 1.06 (dpkg 1.18.7; module version bumped on dpkg 1.18.24) New option: Add tests_dep option to Dpkg::Deps::deps_parse(). diff --git a/scripts/dpkg-checkbuilddeps.pl b/scripts/dpkg-checkbuilddeps.pl index 0621f5f8d..d249ced45 100755 --- a/scripts/dpkg-checkbuilddeps.pl +++ b/scripts/dpkg-checkbuilddeps.pl @@ -165,7 +165,7 @@ sub parse_status { $facts->add_installed_package($package, $version, $arch, $multiarch); if (/^Provides: (.*)$/m) { - my $provides = deps_parse($1, reduce_arch => 1, union => 1); + my $provides = deps_parse($1, reduce_arch => 1, virtual => 1, union => 1); next if not defined $provides; foreach (grep { $_->isa('Dpkg::Deps::Simple') } $provides->get_deps()) diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index a5dda70d0..04a5c68b9 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -257,7 +257,7 @@ $facts->add_installed_package($fields->{'Package'}, $fields->{'Version'}, $fields->{'Architecture'}, $fields->{'Multi-Arch'}); if (exists $pkg->{'Provides'}) { my $provides = deps_parse($substvars->substvars($pkg->{'Provides'}, no_warn => 1), - reduce_restrictions => 1, union => 1); + reduce_restrictions => 1, virtual => 1, union => 1); if (defined $provides) { foreach my $subdep ($provides->get_deps()) { if ($subdep->isa('Dpkg::Deps::Simple')) { -- cgit v1.2.3 From 895a2e525adfd90a57e1e4dfbcc18bb0c1ca64b4 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 10 Aug 2019 02:51:10 +0200 Subject: Dpkg::Changelog: Remove obsolete methods dpkg() and rfc822() Bump module version to 2.00. --- debian/changelog | 1 + scripts/Dpkg/Changelog.pm | 36 +++++------------------------------- 2 files changed, 6 insertions(+), 31 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index d2a040681..5c37bcb23 100644 --- a/debian/changelog +++ b/debian/changelog @@ -48,6 +48,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium allow non-equal version relations in virtual provides. Closes: #930317 - Dpkg: Remove internal lowercase variables $version, $progname, $admindir, $dpkglibdir and $pkgdatadir. + - Dpkg::Changelog: Remove obsolete methods dpkg() and rfc822(). * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index 060081079..1485ae583 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -34,7 +34,7 @@ package Dpkg::Changelog; use strict; use warnings; -our $VERSION = '1.01'; +our $VERSION = '2.00'; use Carp; @@ -670,36 +670,6 @@ sub format_range { } } -=item $control = $c->dpkg($range) - -This is a deprecated alias for $c->format_range('dpkg', $range). - -=cut - -sub dpkg { - my ($self, $range) = @_; - - warnings::warnif('deprecated', - 'deprecated method, please use format_range("dpkg", $range) instead'); - - return $self->format_range('dpkg', $range); -} - -=item @controls = $c->rfc822($range) - -This is a deprecated alias for Cformat_range('rfc822', $range)>. - -=cut - -sub rfc822 { - my ($self, $range) = @_; - - warnings::warnif('deprecated', - 'deprecated method, please use format_range("rfc822", $range) instead'); - - return scalar $self->format_range('rfc822', $range); -} - =back =head1 RANGE SELECTION @@ -779,6 +749,10 @@ with only one of the options specified. =head1 CHANGES +=head2 Version 2.00 (dpkg 1.20.0) + +Remove methods: $c->dpkg(), $c->rfc822(). + =head2 Version 1.01 (dpkg 1.18.8) New method: $c->format_range(). -- cgit v1.2.3 From 9b0dc0a1a879d35443781058415550059db1589c Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 10 Aug 2019 02:51:10 +0200 Subject: Dpkg::Changelog::Entry::Debian: Remove obsolete methods and hide variables Remove obsolete methods check_header() and check_trailer(). Hide internal lowercase variables $regex_header and $regex_trailer. Bump module version to 2.00. --- debian/changelog | 2 ++ scripts/Dpkg/Changelog/Entry/Debian.pm | 49 +++++++--------------------------- 2 files changed, 11 insertions(+), 40 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 5c37bcb23..fdb702b5b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -49,6 +49,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg: Remove internal lowercase variables $version, $progname, $admindir, $dpkglibdir and $pkgdatadir. - Dpkg::Changelog: Remove obsolete methods dpkg() and rfc822(). + - Dpkg::Changelog::Entry::Debian: Remove obsolete methods check_header() + and check_trailer(). Hide variables $regex_header and $regex_trailer. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Changelog/Entry/Debian.pm b/scripts/Dpkg/Changelog/Entry/Debian.pm index 5f4c9e569..2d1c4e6a1 100644 --- a/scripts/Dpkg/Changelog/Entry/Debian.pm +++ b/scripts/Dpkg/Changelog/Entry/Debian.pm @@ -19,10 +19,8 @@ package Dpkg::Changelog::Entry::Debian; use strict; use warnings; -our $VERSION = '1.03'; +our $VERSION = '2.00'; our @EXPORT_OK = qw( - $regex_header - $regex_trailer match_header match_trailer find_closes @@ -55,12 +53,9 @@ implementation are described below. my $name_chars = qr/[-+0-9a-z.]/i; -# XXX: Backwards compatibility, stop exporting on VERSION 2.00. -## no critic (Variables::ProhibitPackageVars) - # The matched content is the source package name ($1), the version ($2), # the target distributions ($3) and the options on the rest of the line ($4). -our $regex_header = qr{ +my $regex_header = qr{ ^ (\w$name_chars*) # Package name \ \(([^\(\) \t]+)\) # Package version @@ -73,7 +68,7 @@ our $regex_header = qr{ # The matched content is the maintainer name ($1), its email ($2), # some blanks ($3) and the timestamp ($4), which is decomposed into # day of week ($6), date-time ($7) and this into month name ($8). -our $regex_trailer = qr< +my $regex_trailer = qr< ^ \ \-\- # Trailer marker \ (.*) # Maintainer name @@ -100,8 +95,6 @@ my %month_name = map { $_ => } qw( August September October November December ); -## use critic - =head1 METHODS =over 4 @@ -245,36 +238,6 @@ sub parse_trailer { return @errors; } -=item $entry->check_header() - -Obsolete method. Use parse_header() instead. - -=cut - -sub check_header { - my $self = shift; - - warnings::warnif('deprecated', - 'obsolete check_header(), use parse_header() instead'); - - return $self->parse_header(); -} - -=item $entry->check_trailer() - -Obsolete method. Use parse_trailer() instead. - -=cut - -sub check_trailer { - my $self = shift; - - warnings::warnif('deprecated', - 'obsolete check_trailer(), use parse_trailer() instead'); - - return $self->parse_header(); -} - =item $entry->normalize() Normalize the content. Strip whitespaces at end of lines, use a single @@ -465,6 +428,12 @@ sub find_closes { =head1 CHANGES +=head2 Version 2.00 (dpkg 1.20.0) + +Remove methods: $entry->check_header(), $entry->check_trailer(). + +Hide variables: $regex_header, $regex_trailer. + =head2 Version 1.03 (dpkg 1.18.8) New methods: $entry->get_timepiece(). -- cgit v1.2.3 From e4fed400378c4ade6b7ceb3aeb03c4252c11c12e Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:25:33 +0100 Subject: Dpkg::Changelog::Parse: Remove $ sigil from option names in POD These are not actual variables, but option passed in a hash, so using the $ sigil here is very confusing. --- debian/changelog | 1 + scripts/Dpkg/Changelog/Parse.pm | 2 +- t/pod-spell.t | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index fdb702b5b..cfae6636c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -63,6 +63,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - man: Split dselect(1) --color from --colour option items. - man: Describe the SONAME formats supported in deb-shlibs(5). - man: Move template symbol documentation into new deb-src-symbols(5). + - Dpkg::Changelog::Parse: Remove $ sigil from option names in POD. * Code internals: - Dpkg::Source::Package: Refactor original tarball handling. - perl: Use File::Copy instead of spawning mv/cp commands. diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm index 91da43ab2..8bf099b00 100644 --- a/scripts/Dpkg/Changelog/Parse.pm +++ b/scripts/Dpkg/Changelog/Parse.pm @@ -217,7 +217,7 @@ New option: 'compression' in changelog_parse(). Deprecated functions: changelog_parse_debian(), changelog_parse_plugin(). -Obsolete options: $forceplugin, $libdir. +Obsolete options: forceplugin, libdir. =head2 Version 1.01 (dpkg 1.18.2) diff --git a/t/pod-spell.t b/t/pod-spell.t index 111d592ca..87b669d7e 100644 --- a/t/pod-spell.t +++ b/t/pod-spell.t @@ -72,12 +72,14 @@ dup'ed env envvar fieldnames +forceplugin ge getters gettext hurd keyrings le +libdir lzma modelines multiarch -- cgit v1.2.3 From 7656016155c2dc408c4659d050a6e4bedb741069 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 10 Aug 2019 02:51:10 +0200 Subject: Dpkg::Changelog::Parse: Remove warnings for obsolete options and functions Remove warnings for obsolete options forceplugin and libdir. Remove obsolete functions changelog_parse_debian() and changelog_parse_plugin(). Bump module version to 2.00. --- debian/changelog | 3 +++ scripts/Dpkg/Changelog/Parse.pm | 60 +++++------------------------------------ 2 files changed, 10 insertions(+), 53 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index cfae6636c..69d274984 100644 --- a/debian/changelog +++ b/debian/changelog @@ -51,6 +51,9 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Changelog: Remove obsolete methods dpkg() and rfc822(). - Dpkg::Changelog::Entry::Debian: Remove obsolete methods check_header() and check_trailer(). Hide variables $regex_header and $regex_trailer. + - Dpkg::Changelog::Parse: Remove warnings of obsolete options forceplugin + and libdir. Remove obsolete functions changelog_parse_debian() and + changelog_parse_plugin(). * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Changelog/Parse.pm b/scripts/Dpkg/Changelog/Parse.pm index 8bf099b00..8140e25a6 100644 --- a/scripts/Dpkg/Changelog/Parse.pm +++ b/scripts/Dpkg/Changelog/Parse.pm @@ -33,10 +33,8 @@ package Dpkg::Changelog::Parse; use strict; use warnings; -our $VERSION = '1.03'; +our $VERSION = '2.00'; our @EXPORT = qw( - changelog_parse_debian - changelog_parse_plugin changelog_parse ); @@ -75,40 +73,6 @@ sub _changelog_detect_format { =over 4 -=item $fields = changelog_parse_debian(%opt) - -This function is deprecated, use changelog_parse() instead, with the changelog -format set to "debian". - -=cut - -sub changelog_parse_debian { - my (%options) = @_; - - warnings::warnif('deprecated', - 'deprecated function changelog_parse_debian, use changelog_parse instead'); - - # Force the plugin to be debian. - $options{changelogformat} = 'debian'; - - return _changelog_parse(%options); -} - -=item $fields = changelog_parse_plugin(%opt) - -This function is deprecated, use changelog_parse() instead. - -=cut - -sub changelog_parse_plugin { - my (%options) = @_; - - warnings::warnif('deprecated', - 'deprecated function changelog_parse_plugin, use changelog_parse instead'); - - return _changelog_parse(%options); -} - =item $fields = changelog_parse(%opt) This function will parse a changelog. In list context, it returns as many @@ -137,15 +101,9 @@ All the other keys in %opt are forwarded to the parser module constructor. =cut -sub _changelog_parse { +sub changelog_parse { my (%options) = @_; - # Setup and sanity checks. - if (exists $options{libdir}) { - warnings::warnif('deprecated', - 'obsolete libdir option, changelog parsers are now perl modules'); - } - $options{file} //= 'debian/changelog'; $options{label} //= $options{file}; $options{changelogformat} //= _changelog_detect_format($options{file}); @@ -195,19 +153,15 @@ sub _changelog_parse { } } -sub changelog_parse { - my (%options) = @_; +=back - if (exists $options{forceplugin}) { - warnings::warnif('deprecated', 'obsolete forceplugin option'); - } +=head1 CHANGES - return _changelog_parse(%options); -} +=head2 Version 2.00 (dpkg 1.20.0) -=back +Remove functions: changelog_parse_debian(), changelog_parse_plugin(). -=head1 CHANGES +Remove warnings: For options 'forceplugin', 'libdir'. =head2 Version 1.03 (dpkg 1.19.0) -- cgit v1.2.3 From ab8176cb9a92a39d062da002cf9192bdc6e5f3d1 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:29:13 +0100 Subject: Dpkg::Compression: Hide internal lowercase variables Bump module version to 2.00. --- debian/changelog | 3 +++ scripts/Dpkg/Compression.pm | 17 +++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 69d274984..28373d1c6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -54,6 +54,9 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Changelog::Parse: Remove warnings of obsolete options forceplugin and libdir. Remove obsolete functions changelog_parse_debian() and changelog_parse_plugin(). + - Dpkg::Compression: Hide internal lowercase variables + $default_compression, $default_compression_level and + $compression_re_file_ext. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Compression.pm b/scripts/Dpkg/Compression.pm index 3dbc4adf0..5bbe7f427 100644 --- a/scripts/Dpkg/Compression.pm +++ b/scripts/Dpkg/Compression.pm @@ -19,9 +19,8 @@ package Dpkg::Compression; use strict; use warnings; -our $VERSION = '1.02'; +our $VERSION = '2.00'; our @EXPORT = qw( - $compression_re_file_ext compression_is_supported compression_get_list compression_get_property @@ -98,14 +97,11 @@ if ($Config{cf_by} eq 'Debian Project') { push @{$COMP->{gzip}->{comp_prog}}, '--rsyncable'; } -# XXX: Backwards compatibility, stop exporting on VERSION 2.00. -## no critic (Variables::ProhibitPackageVars) -our $default_compression = 'xz'; -our $default_compression_level = undef; +my $default_compression = 'xz'; +my $default_compression_level = undef; my $regex = join '|', map { $_->{file_ext} } values %$COMP; -our $compression_re_file_ext = qr/(?:$regex)/; -## use critic +my $compression_re_file_ext = qr/(?:$regex)/; =head1 FUNCTIONS @@ -250,6 +246,11 @@ sub compression_is_valid_level { =head1 CHANGES +=head2 Version 2.00 (dpkg 1.20.0) + +Hide variables: $default_compression, $default_compression_level +and $compression_re_file_ext. + =head2 Version 1.02 (dpkg 1.17.2) New function: compression_get_file_extension_regex() -- cgit v1.2.3 From 7a68fdc76ea3a009ace005aa7972bb337995b127 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:30:04 +0100 Subject: Dpkg::Deps::KnownFacts: Remove obsolete check_package() method Bump module version to 2.00. --- debian/changelog | 1 + scripts/Dpkg/Deps/KnownFacts.pm | 37 +++++-------------------------------- 2 files changed, 6 insertions(+), 32 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 28373d1c6..bef7ecc95 100644 --- a/debian/changelog +++ b/debian/changelog @@ -57,6 +57,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Compression: Hide internal lowercase variables $default_compression, $default_compression_level and $compression_re_file_ext. + - Dpkg::Deps::KnownFacts: Remove obsolete check_package() method. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Deps/KnownFacts.pm b/scripts/Dpkg/Deps/KnownFacts.pm index 192f6aa6b..a414eb49b 100644 --- a/scripts/Dpkg/Deps/KnownFacts.pm +++ b/scripts/Dpkg/Deps/KnownFacts.pm @@ -37,7 +37,7 @@ packages provided (by the set of installed packages). use strict; use warnings; -our $VERSION = '1.01'; +our $VERSION = '2.00'; use Dpkg::Version; @@ -109,37 +109,6 @@ sub add_provided_package { push @{$self->{virtualpkg}{$pkg}}, $v; } -=item ($check, $param) = $facts->check_package($package) - -$check is one when the package is found. For a real package, $param -contains the version. For a virtual package, $param contains an array -reference containing the list of packages that provide it (each package is -listed as [ $provider, $relation, $version ]). - -This function is obsolete and should not be used. Dpkg::Deps::KnownFacts -is only meant to be filled with data and then passed to Dpkg::Deps -methods where appropriate, but it should not be directly queried. - -=cut - -sub check_package { - my ($self, $pkg) = @_; - - warnings::warnif('deprecated', 'obsolete function, pass ' . - 'Dpkg::Deps::KnownFacts to Dpkg::Deps methods instead'); - - if (exists $self->{pkg}{$pkg}) { - return (1, $self->{pkg}{$pkg}[0]{version}); - } - if (exists $self->{virtualpkg}{$pkg}) { - my $arrayref = [ map { [ - $_->{provider}, $_->{relation}, $_->{version} - ] } @{$self->{virtualpkg}{$pkg}} ]; - return (1, $arrayref); - } - return (0, undef); -} - ## ## The functions below are private to Dpkg::Deps::KnownFacts. ## @@ -228,6 +197,10 @@ sub evaluate_simple_dep { =head1 CHANGES +=head2 Version 2.00 (dpkg 1.20.0) + +Remove method: $facts->check_package(). + =head2 Version 1.01 (dpkg 1.16.1) New option: Dpkg::Deps::KnownFacts->add_installed_package() now accepts 2 -- cgit v1.2.3 From 2adeecad3d72ccfb46ed39278c6b1831d8dbad64 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:30:40 +0100 Subject: Dpkg::Exit: Hide internal lowercase @handlers variable Bump module version to 2.00. --- debian/changelog | 1 + scripts/Dpkg/Exit.pm | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index bef7ecc95..60865b3b8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -58,6 +58,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium $default_compression, $default_compression_level and $compression_re_file_ext. - Dpkg::Deps::KnownFacts: Remove obsolete check_package() method. + - Dpkg::Exit: Hide internal lowercase @handlers variable. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Exit.pm b/scripts/Dpkg/Exit.pm index 5e513b496..fb51a3abf 100644 --- a/scripts/Dpkg/Exit.pm +++ b/scripts/Dpkg/Exit.pm @@ -19,7 +19,7 @@ package Dpkg::Exit; use strict; use warnings; -our $VERSION = '1.01'; +our $VERSION = '2.00'; our @EXPORT_OK = qw( push_exit_handler pop_exit_handler @@ -28,10 +28,7 @@ our @EXPORT_OK = qw( use Exporter qw(import); -# XXX: Backwards compatibility, stop exporting on VERSION 2.00. -## no critic (Variables::ProhibitPackageVars) -our @handlers = (); -## use critic +my @handlers = (); =encoding utf8 @@ -91,6 +88,10 @@ $SIG{QUIT} = \&_exit_handler; =head1 CHANGES +=head2 Version 2.00 (dpkg 1.20.0) + +Hide variable: @handlers. + =head2 Version 1.01 (dpkg 1.17.2) New functions: push_exit_handler(), pop_exit_handler(), run_exit_handlers() -- cgit v1.2.3 From 27228611177b0cde44325df2ac8c32ae6bc6d2eb Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:31:07 +0100 Subject: Dpkg::Gettext: Remove obsolete _g() function Bump module version to 2.00. --- debian/changelog | 1 + scripts/Dpkg/Gettext.pm | 16 ++++------------ 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 60865b3b8..64b463182 100644 --- a/debian/changelog +++ b/debian/changelog @@ -59,6 +59,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium $compression_re_file_ext. - Dpkg::Deps::KnownFacts: Remove obsolete check_package() method. - Dpkg::Exit: Hide internal lowercase @handlers variable. + - Dpkg::Gettext: Remove obsolete _g() function. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Gettext.pm b/scripts/Dpkg/Gettext.pm index 03b723c9d..e61cdd1a0 100644 --- a/scripts/Dpkg/Gettext.pm +++ b/scripts/Dpkg/Gettext.pm @@ -30,14 +30,13 @@ use strict; use warnings; use feature qw(state); -our $VERSION = '1.03'; +our $VERSION = '2.00'; our @EXPORT = qw( textdomain ngettext g_ P_ N_ - _g ); use Exporter qw(import); @@ -189,18 +188,11 @@ sub N_ return $msgid; } -# XXX: Backwards compatibility, to be removed on VERSION 2.00. -sub _g ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines) -{ - my $msgid = shift; - - warnings::warnif('deprecated', - 'obsolete _g() function, please use g_() instead'); +=head1 CHANGES - return g_($msgid); -} +=head2 Version 2.00 (dpkg 1.20.0) -=head1 CHANGES +Remove function: _g(). =head2 Version 1.03 (dpkg 1.19.0) -- cgit v1.2.3 From 605d9f8a8a59c8413a9ba0ab260b6f10a7ac1c70 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:32:09 +0100 Subject: Dpkg::Source::Package: Remove and hide internal lowercase variables Bump module version to 2.00. --- debian/changelog | 3 +++ scripts/Dpkg/Source/Package.pm | 16 +++++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 64b463182..8841b1cb2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -60,6 +60,9 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Deps::KnownFacts: Remove obsolete check_package() method. - Dpkg::Exit: Hide internal lowercase @handlers variable. - Dpkg::Gettext: Remove obsolete _g() function. + - Dpkg::Source::Package: Hide internal lowercase variable + @tar_ignore_default_pattern. Remove iternal lowercase variable alias + $diff_ignore_default_regexp. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index 35bdbafa1..d973c5643 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -34,7 +34,7 @@ is the one that supports the extraction of the source package. use strict; use warnings; -our $VERSION = '1.04'; +our $VERSION = '2.00'; our @EXPORT_OK = qw( get_default_diff_ignore_regex set_default_diff_ignore_regex @@ -81,14 +81,8 @@ my $diff_ignore_default_regex = ' $diff_ignore_default_regex =~ s/^#.*$//mg; $diff_ignore_default_regex =~ s/\n//sg; -# Public variables -# XXX: Backwards compatibility, stop exporting on VERSION 2.00. -## no critic (Variables::ProhibitPackageVars) -our $diff_ignore_default_regexp; -*diff_ignore_default_regexp = \$diff_ignore_default_regex; - no warnings 'qw'; ## no critic (TestingAndDebugging::ProhibitNoWarnings) -our @tar_ignore_default_pattern = qw( +my @tar_ignore_default_pattern = qw( *.a *.la *.o @@ -660,10 +654,14 @@ sub write_dsc { =head1 CHANGES -=head2 Version 1.04 (dpkg 1.20.0) +=head2 Version 2.00 (dpkg 1.20.0) New method: check_original_tarball_signature(). +Remove variable: $diff_ignore_default_regexp. + +Hide variable: @tar_ignore_default_pattern. + =head2 Version 1.03 (dpkg 1.19.3) New option: format in new(). -- cgit v1.2.3 From e9fa0cd0bce704657bad9d26810f6fa57f78caf2 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:32:44 +0100 Subject: Dpkg::Substvars: Remove obsolete no_warn() method Bump module version to 2.00. --- debian/changelog | 1 + scripts/Dpkg/Substvars.pm | 21 +++++---------------- 2 files changed, 6 insertions(+), 16 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 8841b1cb2..0cf8c186d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -63,6 +63,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Source::Package: Hide internal lowercase variable @tar_ignore_default_pattern. Remove iternal lowercase variable alias $diff_ignore_default_regexp. + - Dpkg::Substvars: Remove obsolete no_warn() method. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index d2060efc5..49ebd902b 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -19,7 +19,7 @@ package Dpkg::Substvars; use strict; use warnings; -our $VERSION = '1.06'; +our $VERSION = '2.00'; use Dpkg (); use Dpkg::Arch qw(get_host_arch); @@ -168,21 +168,6 @@ sub mark_as_used { $self->{attr}{$key} |= SUBSTVAR_ATTR_USED; } -=item $s->no_warn($key) - -Obsolete function, use mark_as_used() instead. - -=cut - -sub no_warn { - my ($self, $key) = @_; - - warnings::warnif('deprecated', - 'obsolete no_warn() function, use mark_as_used() instead'); - - $self->mark_as_used($key); -} - =item $s->parse($fh, $desc) Add new substitutions read from the filehandle. $desc is used to identify @@ -438,6 +423,10 @@ indicated file. =head1 CHANGES +=head2 Version 2.00 (dpkg 1.20.0) + +Remove method: $s->no_warn(). + =head2 Version 1.06 (dpkg 1.19.0) New method: $s->set_desc_substvars(). -- cgit v1.2.3 From 2c08a8a2a2503398c7d17b4ecb7f364ea4eb3aed Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:33:52 +0100 Subject: Dpkg::Index: Change default value for unique_tuple_key to 1 Bump module version to 2.00. --- debian/changelog | 1 + scripts/Dpkg/Index.pm | 35 +++++++++++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 0cf8c186d..93c9c2f08 100644 --- a/debian/changelog +++ b/debian/changelog @@ -64,6 +64,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium @tar_ignore_default_pattern. Remove iternal lowercase variable alias $diff_ignore_default_regexp. - Dpkg::Substvars: Remove obsolete no_warn() method. + - Dpkg::Index: Change default value for unique_tuple_key to 1. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Index.pm b/scripts/Dpkg/Index.pm index 682f16921..7859bf669 100644 --- a/scripts/Dpkg/Index.pm +++ b/scripts/Dpkg/Index.pm @@ -19,7 +19,7 @@ package Dpkg::Index; use strict; use warnings; -our $VERSION = '1.01'; +our $VERSION = '2.00'; use Dpkg::Gettext; use Dpkg::ErrorHandling; @@ -58,7 +58,7 @@ sub new { my $self = { items => {}, order => [], - unique_tuple_key => 0, + unique_tuple_key => 1, get_key_func => sub { return $_[0]->{Package} }, type => CTRL_UNKNOWN, }; @@ -77,8 +77,7 @@ The "type" option is checked first to define default values for other options. Here are the relevant options: "get_key_func" is a function returning a key for the item passed in parameters, "unique_tuple_key" is a boolean requesting whether the default key should be the unique tuple -(default to false for backwards compatibility, but it will change to true -in dpkg 1.20.x). The index can only contain one item with a given key. +(default to true). The index can only contain one item with a given key. The "get_key_func" function used depends on the type: =over @@ -89,9 +88,9 @@ for CTRL_INFO_SRC, it is the Source field; =item * -for CTRL_INDEX_SRC and CTRL_PKG_SRC it is the Package field by default, -or the Package and Version fields (concatenated with "_") when -"unique_tuple_key" is true; +for CTRL_INDEX_SRC and CTRL_PKG_SRC it is the Package and Version fields +(concatenated with "_") when "unique_tuple_key" is true (the default), or +otherwise the Package field; =item * @@ -99,9 +98,9 @@ for CTRL_INFO_PKG it is simply the Package field; =item * -for CTRL_INDEX_PKG and CTRL_PKG_DEB it is the Package field by default, -or the Package, Version and Architecture fields (concatenated with "_") -when "unique_tuple_key" is true; +for CTRL_INDEX_PKG and CTRL_PKG_DEB it is the Package, Version and +Architecture fields (concatenated with "_") when "unique_tuple_key" is +true (the default) or otherwise the Package field; =item * @@ -165,14 +164,10 @@ sub set_options { $self->{get_key_func} = sub { return $_[0]->{Package} . '_' . $_[0]->{Version}; }; - } elsif (not defined $opts{get_key_func}) { + } else { $self->{get_key_func} = sub { return $_[0]->{Package}; }; - warnings::warnif('deprecated', - 'the default get_key_func for this control type will ' . - 'change semantics in dpkg 1.20.x , please set ' . - 'unique_tuple_key or get_key_func explicitly'); } } elsif ($t == CTRL_INDEX_PKG or $t == CTRL_PKG_DEB) { if ($opts{unique_tuple_key} // $self->{unique_tuple_key}) { @@ -180,14 +175,10 @@ sub set_options { return $_[0]->{Package} . '_' . $_[0]->{Version} . '_' . $_[0]->{Architecture}; }; - } elsif (not defined $opts{get_key_func}) { + } else { $self->{get_key_func} = sub { return $_[0]->{Package}; }; - warnings::warnif('deprecated', - 'the default get_key_func for this control type will ' . - 'change semantics in dpkg 1.20.x , please set ' . - 'unique_tuple_key or get_key_func explicitly'); } } elsif ($t == CTRL_FILE_CHANGES) { $self->{get_key_func} = sub { @@ -435,6 +426,10 @@ based on their extensions. =head1 CHANGES +=head2 Version 2.00 (dpkg 1.20.0) + +Change behavior: The "unique_tuple_key" option now defaults to true. + =head2 Version 1.01 (dpkg 1.19.0) New option: Add new "unique_tuple_key" option to $index->set_options() to set -- cgit v1.2.3 From 69b98260c76342a72f3c819961a33b9a14e899ab Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:37:17 +0100 Subject: Dpkg::Version: Remove deprecation warning from semantic change in bool overload --- debian/changelog | 2 ++ scripts/Dpkg/Version.pm | 13 ++++++------- scripts/t/Dpkg_Version.t | 6 ------ 3 files changed, 8 insertions(+), 13 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 93c9c2f08..a87e747ca 100644 --- a/debian/changelog +++ b/debian/changelog @@ -65,6 +65,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium $diff_ignore_default_regexp. - Dpkg::Substvars: Remove obsolete no_warn() method. - Dpkg::Index: Change default value for unique_tuple_key to 1. + - Dpkg::Version: Remove deprecation warning from semantic change in + bool overload. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm index 2900e5790..51d46c543 100644 --- a/scripts/Dpkg/Version.pm +++ b/scripts/Dpkg/Version.pm @@ -22,7 +22,7 @@ use strict; use warnings; use warnings::register qw(semantic_change::overload::bool); -our $VERSION = '1.02'; +our $VERSION = '1.03'; our @EXPORT = qw( version_compare version_compare_relation @@ -56,12 +56,7 @@ use overload '<=>' => \&_comparison, 'cmp' => \&_comparison, '""' => sub { return $_[0]->as_string(); }, - 'bool' => sub { - warnings::warnif('Dpkg::Version::semantic_change::overload::bool', - 'Dpkg::Version bool overload behavior has changed ' . - 'back to be an is_valid() alias'); - return $_[0]->is_valid(); - }, + 'bool' => sub { return $_[0]->is_valid(); }, 'fallback' => 1; =encoding utf8 @@ -473,6 +468,10 @@ sub version_check($) { =head1 CHANGES +=head2 Version 1.03 (dpkg 1.20.0) + +Remove deprecation warning from semantic change in 1.02. + =head2 Version 1.02 (dpkg 1.19.1) Semantic change: bool evaluation semantics restored to their original behavior. diff --git a/scripts/t/Dpkg_Version.t b/scripts/t/Dpkg_Version.t index 34ab1772f..69f0fecf0 100644 --- a/scripts/t/Dpkg_Version.t +++ b/scripts/t/Dpkg_Version.t @@ -85,12 +85,6 @@ my $truth = { }, }; -# XXX: Some of the tests check the bool overload, which currently emits -# the semantic_change warning. Disable it until we stop emitting the -# warning in dpkg 1.20.x. -## no critic (TestingAndDebugging::ProhibitNoWarnings) -no warnings(qw(Dpkg::Version::semantic_change::overload::bool)); - # Handling of empty/invalid versions my $empty = Dpkg::Version->new(''); ok($empty eq '', "Dpkg::Version->new('') eq ''"); -- cgit v1.2.3 From 83b1500011a0656263afbdeffffca182758ef061 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:38:37 +0100 Subject: Dpkg::Checksums: Remove obsolete 'program' property warning --- debian/changelog | 1 + scripts/Dpkg/Checksums.pm | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index a87e747ca..7a9dd2981 100644 --- a/debian/changelog +++ b/debian/changelog @@ -67,6 +67,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Index: Change default value for unique_tuple_key to 1. - Dpkg::Version: Remove deprecation warning from semantic change in bool overload. + - Dpkg::Checksums: Remove obsolete 'program' property warning. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Checksums.pm b/scripts/Dpkg/Checksums.pm index 1237e8b89..9b7316b07 100644 --- a/scripts/Dpkg/Checksums.pm +++ b/scripts/Dpkg/Checksums.pm @@ -20,7 +20,7 @@ package Dpkg::Checksums; use strict; use warnings; -our $VERSION = '1.03'; +our $VERSION = '1.04'; our @EXPORT = qw( checksums_is_supported checksums_get_list @@ -106,10 +106,6 @@ whether the checksum algorithm is considered cryptographically strong. sub checksums_get_property($$) { my ($alg, $property) = @_; - if ($property eq 'program') { - warnings::warnif('deprecated', 'obsolete checksums program property'); - } - return unless checksums_is_supported($alg); return $CHECKSUMS->{lc($alg)}{$property}; } @@ -400,6 +396,10 @@ sub export_to_control { =head1 CHANGES +=head2 Version 1.04 (dpkg 1.20.0) + +Remove warning: For obsolete property 'program'. + =head2 Version 1.03 (dpkg 1.18.5) New property: Add new 'strong' property. -- cgit v1.2.3 From a376ff0b20918ec4c66a6905529065d992095c35 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:40:03 +0100 Subject: Dpkg::Conf: Remove obsolete methods and obsolete croak for method option We do not bump the module version to 2.00, as these functions and option have croak'ed almost since their introduction. --- debian/changelog | 1 + scripts/Dpkg/Conf.pm | 26 +++++++------------------- 2 files changed, 8 insertions(+), 19 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 7a9dd2981..d481e4b1d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -68,6 +68,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Version: Remove deprecation warning from semantic change in bool overload. - Dpkg::Checksums: Remove obsolete 'program' property warning. + - Dpkg::Conf: Remove obsolete methods and obsolete croak for method option. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Conf.pm b/scripts/Dpkg/Conf.pm index 5b98bbd8e..028a2939f 100644 --- a/scripts/Dpkg/Conf.pm +++ b/scripts/Dpkg/Conf.pm @@ -18,7 +18,7 @@ package Dpkg::Conf; use strict; use warnings; -our $VERSION = '1.03'; +our $VERSION = '1.04'; use Carp; @@ -85,22 +85,6 @@ sub get_options { return @{$self->{options}}; } -=item get() - -=item set() - -Obsolete functions, use get_options() instead. They will croak. - -=cut - -sub get { - croak 'obsolete function, use get_options instead'; -} - -sub set { - croak 'obsolete function, use get_options instead'; -} - =item $conf->load($file) Read options from a file. Return the number of options parsed. @@ -215,8 +199,6 @@ sub filter { my $remove = $opts{remove} // sub { 0 }; my $keep = $opts{keep} // sub { 1 }; - croak 'obsolete option format_argv' if exists $opts{format_argv}; - @{$self->{options}} = grep { not $remove->($_) and $keep->($_) } @{$self->{options}}; } @@ -253,6 +235,12 @@ Save the options in a file. =head1 CHANGES +=head2 Version 1.04 (dpkg 1.20.0) + +Remove croak: For 'format_argv' in $conf->filter(). + +Remove methods: $conf->get(), $conf->set(). + =head2 Version 1.03 (dpkg 1.18.8) Obsolete option: 'format_argv' in $conf->filter(). -- cgit v1.2.3 From 6e6bd74a5664b3d354dc7fd892a08eaf928980ad Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 16 Nov 2019 00:41:57 +0100 Subject: Dpkg::Vendor: Remove obsolete 'keyrings' hook This hook has been obsoleted for a while and been emitting deprecation warnings, so it's safe to remove now. --- debian/changelog | 1 + scripts/Dpkg/Vendor/Debian.pm | 3 --- scripts/Dpkg/Vendor/Default.pm | 3 --- 3 files changed, 1 insertion(+), 6 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index d481e4b1d..d28e3257a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -69,6 +69,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium bool overload. - Dpkg::Checksums: Remove obsolete 'program' property warning. - Dpkg::Conf: Remove obsolete methods and obsolete croak for method option. + - Dpkg::Vendor: Remove obsolete 'keyrings' hook. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index 71aa59038..a37b23cfc 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -51,9 +51,6 @@ sub run_hook { if ($hook eq 'package-keyrings') { return ('/usr/share/keyrings/debian-keyring.gpg', '/usr/share/keyrings/debian-maintainers.gpg'); - } elsif ($hook eq 'keyrings') { - warnings::warnif('deprecated', 'deprecated keyrings vendor hook'); - return $self->run_hook('package-keyrings', @params); } elsif ($hook eq 'archive-keyrings') { return ('/usr/share/keyrings/debian-archive-keyring.gpg'); } elsif ($hook eq 'archive-keyrings-historic') { diff --git a/scripts/Dpkg/Vendor/Default.pm b/scripts/Dpkg/Vendor/Default.pm index ed05c3009..6b7c5204f 100644 --- a/scripts/Dpkg/Vendor/Default.pm +++ b/scripts/Dpkg/Vendor/Default.pm @@ -157,9 +157,6 @@ sub run_hook { if ($hook eq 'before-source-build') { my $srcpkg = shift @params; - } elsif ($hook eq 'keyrings') { - warnings::warnif('deprecated', 'obsolete keyrings vendor hook'); - return (); } elsif ($hook eq 'package-keyrings') { return (); } elsif ($hook eq 'archive-keyrings') { -- cgit v1.2.3 From ddb82d8bfe58e8a25444bdd772f534e0564efb3d Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 5 Oct 2019 04:26:23 +0200 Subject: Dpkg::Exit: Unregister all signal handlers once we have executed them We should cleanup the handlers to the previous state otherwise we end up changing the behavior globally, when this should be a local cleanup behavior. Closes: #932841 --- debian/changelog | 2 ++ scripts/Dpkg/Exit.pm | 23 ++++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index c5bad0b90..3bb18cef3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -71,6 +71,8 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Checksums: Remove obsolete 'program' property warning. - Dpkg::Conf: Remove obsolete methods and obsolete croak for method option. - Dpkg::Vendor: Remove obsolete 'keyrings' hook. + - Dpkg::Exit: Unregister all signal handlers once we have executed them. + Closes: #932841 * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Exit.pm b/scripts/Dpkg/Exit.pm index fb51a3abf..53c4981cd 100644 --- a/scripts/Dpkg/Exit.pm +++ b/scripts/Dpkg/Exit.pm @@ -52,6 +52,8 @@ Register a code reference into the exit function handlers stack. sub push_exit_handler { my ($func) = shift; + + _setup_exit_handlers() if @handlers == 0; push @handlers, $func; } @@ -62,6 +64,7 @@ Pop the last registered exit handler from the handlers stack. =cut sub pop_exit_handler { + _reset_exit_handlers() if @handlers == 1; pop @handlers; } @@ -80,9 +83,23 @@ sub _exit_handler { exit(127); } -$SIG{INT} = \&_exit_handler; -$SIG{HUP} = \&_exit_handler; -$SIG{QUIT} = \&_exit_handler; +my @SIGNAMES = qw(INT HUP QUIT); +my %SIGOLD; + +sub _setup_exit_handlers +{ + foreach my $signame (@SIGNAMES) { + $SIGOLD{$signame} = $SIG{$signame}; + $SIG{$signame} = \&_exit_handler; + } +} + +sub _reset_exit_handlers +{ + foreach my $signame (@SIGNAMES) { + $SIG{$signame} = $SIGOLD{$signame}; + } +} =back -- cgit v1.2.3 From b287a80263dd4e45bb82b7e6bad76faeb47358d4 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 5 Oct 2019 04:28:30 +0200 Subject: Dpkg::Exit: Register exit handlers also for __DIE__ This makes sure we execute the handlers on normal errors, and can thus remove the traps from several functions to run the handlers and to then rethrow the exception. --- debian/changelog | 1 + scripts/Dpkg/Exit.pm | 2 +- scripts/Dpkg/Source/Package.pm | 21 +++++---------------- 3 files changed, 7 insertions(+), 17 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 3bb18cef3..4367a5673 100644 --- a/debian/changelog +++ b/debian/changelog @@ -73,6 +73,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Vendor: Remove obsolete 'keyrings' hook. - Dpkg::Exit: Unregister all signal handlers once we have executed them. Closes: #932841 + - Dpkg::Exit: Register exit handlers also for __DIE__. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Exit.pm b/scripts/Dpkg/Exit.pm index 53c4981cd..70a29b1a6 100644 --- a/scripts/Dpkg/Exit.pm +++ b/scripts/Dpkg/Exit.pm @@ -83,7 +83,7 @@ sub _exit_handler { exit(127); } -my @SIGNAMES = qw(INT HUP QUIT); +my @SIGNAMES = qw(INT HUP QUIT __DIE__); my %SIGOLD; sub _setup_exit_handlers diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index d973c5643..d38e228e5 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -54,7 +54,6 @@ use Dpkg::Control; use Dpkg::Checksums; use Dpkg::Version; use Dpkg::Compression; -use Dpkg::Exit qw(run_exit_handlers); use Dpkg::Path qw(check_files_are_the_same find_command); use Dpkg::IPC; use Dpkg::Vendor qw(run_vendor_hook); @@ -520,11 +519,7 @@ sub extract { } # Try extract - eval { $self->do_extract($newdirectory) }; - if ($@) { - run_exit_handlers(); - die $@; - } + $self->do_extract($newdirectory); # Store format if non-standard so that next build keeps the same format if ($self->{fields}{'Format'} and @@ -569,11 +564,8 @@ sub before_build { sub build { my $self = shift; - eval { $self->do_build(@_) }; - if ($@) { - run_exit_handlers(); - die $@; - } + + $self->do_build(@_); } sub after_build { @@ -603,11 +595,8 @@ sub add_file { sub commit { my $self = shift; - eval { $self->do_commit(@_) }; - if ($@) { - run_exit_handlers(); - die $@; - } + + $self->do_commit(@_); } sub do_commit { -- cgit v1.2.3 From 7ab69d4acbdabd3af0f8c27801527750505c1a11 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 6 Nov 2019 02:07:17 +0100 Subject: Dpkg: Say class instead of object when appropriate These were referring to the type and not the instance, which makes using the incorrect nomenclature confusing. --- debian/changelog | 1 + scripts/Dpkg/BuildFlags.pm | 2 +- scripts/Dpkg/BuildOptions.pm | 2 +- scripts/Dpkg/Changelog.pm | 2 +- scripts/Dpkg/Changelog/Entry.pm | 2 +- scripts/Dpkg/Changelog/Entry/Debian.pm | 2 +- scripts/Dpkg/Checksums.pm | 2 +- scripts/Dpkg/Compression/FileHandle.pm | 18 +++++++++--------- scripts/Dpkg/Control/Changelog.pm | 2 +- scripts/Dpkg/Control/HashCore.pm | 4 ++-- scripts/Dpkg/Control/Info.pm | 2 +- scripts/Dpkg/Control/Tests.pm | 2 +- scripts/Dpkg/Control/Tests/Entry.pm | 2 +- scripts/Dpkg/Deps.pm | 8 ++++---- scripts/Dpkg/Deps/AND.pm | 2 +- scripts/Dpkg/Deps/KnownFacts.pm | 2 +- scripts/Dpkg/Deps/OR.pm | 2 +- scripts/Dpkg/Deps/Simple.pm | 5 +++-- scripts/Dpkg/Deps/Union.pm | 4 ++-- scripts/Dpkg/Index.pm | 2 +- scripts/Dpkg/Interface/Storable.pm | 4 ++-- scripts/Dpkg/Source/Format.pm | 2 +- scripts/Dpkg/Source/Package.pm | 4 ++-- scripts/Dpkg/Substvars.pm | 2 +- scripts/Dpkg/Vendor/Debian.pm | 4 ++-- scripts/Dpkg/Vendor/Default.pm | 8 ++++---- scripts/Dpkg/Vendor/Ubuntu.pm | 4 ++-- 27 files changed, 49 insertions(+), 47 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 4367a5673..d41eaa836 100644 --- a/debian/changelog +++ b/debian/changelog @@ -87,6 +87,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - man: Describe the SONAME formats supported in deb-shlibs(5). - man: Move template symbol documentation into new deb-src-symbols(5). - Dpkg::Changelog::Parse: Remove $ sigil from option names in POD. + - Dpkg: Say class instead of object when appropriate. * Code internals: - Dpkg::Source::Package: Refactor original tarball handling. - perl: Use File::Copy instead of spawning mv/cp commands. diff --git a/scripts/Dpkg/BuildFlags.pm b/scripts/Dpkg/BuildFlags.pm index edf16e4f3..53b3cad00 100644 --- a/scripts/Dpkg/BuildFlags.pm +++ b/scripts/Dpkg/BuildFlags.pm @@ -34,7 +34,7 @@ Dpkg::BuildFlags - query build flags =head1 DESCRIPTION -The Dpkg::BuildFlags object is used by dpkg-buildflags and can be used +This class is used by dpkg-buildflags and can be used to query the same information. =head1 METHODS diff --git a/scripts/Dpkg/BuildOptions.pm b/scripts/Dpkg/BuildOptions.pm index 263381b49..e03ea320b 100644 --- a/scripts/Dpkg/BuildOptions.pm +++ b/scripts/Dpkg/BuildOptions.pm @@ -34,7 +34,7 @@ Dpkg::BuildOptions - parse and update build options =head1 DESCRIPTION -The Dpkg::BuildOptions object can be used to manipulate options stored +This class can be used to manipulate options stored in environment variables like DEB_BUILD_OPTIONS and DEB_BUILD_MAINT_OPTIONS. diff --git a/scripts/Dpkg/Changelog.pm b/scripts/Dpkg/Changelog.pm index 1485ae583..04fa511ec 100644 --- a/scripts/Dpkg/Changelog.pm +++ b/scripts/Dpkg/Changelog.pm @@ -24,7 +24,7 @@ Dpkg::Changelog - base class to implement a changelog parser Dpkg::Changelog is a class representing a changelog file as an array of changelog entries (Dpkg::Changelog::Entry). -By deriving this object and implementing its parse method, you +By deriving this class and implementing its parse method, you add the ability to fill this object with changelog entries. =cut diff --git a/scripts/Dpkg/Changelog/Entry.pm b/scripts/Dpkg/Changelog/Entry.pm index 144dacb0f..d6ce55601 100644 --- a/scripts/Dpkg/Changelog/Entry.pm +++ b/scripts/Dpkg/Changelog/Entry.pm @@ -39,7 +39,7 @@ Dpkg::Changelog::Entry - represents a changelog entry =head1 DESCRIPTION -This object represents a changelog entry. It is composed +This class represents a changelog entry. It is composed of a set of lines with specific purpose: an header line, changes lines, a trailer line. Blank lines can be between those kind of lines. diff --git a/scripts/Dpkg/Changelog/Entry/Debian.pm b/scripts/Dpkg/Changelog/Entry/Debian.pm index 2d1c4e6a1..8658ae493 100644 --- a/scripts/Dpkg/Changelog/Entry/Debian.pm +++ b/scripts/Dpkg/Changelog/Entry/Debian.pm @@ -45,7 +45,7 @@ Dpkg::Changelog::Entry::Debian - represents a Debian changelog entry =head1 DESCRIPTION -This object represents a Debian changelog entry. It implements the +This class represents a Debian changelog entry. It implements the generic interface Dpkg::Changelog::Entry. Only functions specific to this implementation are described below. diff --git a/scripts/Dpkg/Checksums.pm b/scripts/Dpkg/Checksums.pm index 9b7316b07..93bdf4bd8 100644 --- a/scripts/Dpkg/Checksums.pm +++ b/scripts/Dpkg/Checksums.pm @@ -41,7 +41,7 @@ Dpkg::Checksums - generate and manipulate file checksums =head1 DESCRIPTION -This module provides an object that can generate and manipulate +This module provides a class that can generate and manipulate various file checksums as well as some methods to query information about supported checksums. diff --git a/scripts/Dpkg/Compression/FileHandle.pm b/scripts/Dpkg/Compression/FileHandle.pm index 23b39841a..c0d4b0787 100644 --- a/scripts/Dpkg/Compression/FileHandle.pm +++ b/scripts/Dpkg/Compression/FileHandle.pm @@ -31,14 +31,14 @@ use Dpkg::ErrorHandling; use parent qw(IO::File Tie::Handle); # Useful reference to understand some kludges required to -# have the object behave like a filehandle +# have the class behave like a filehandle # http://blog.woobling.org/2009/10/are-filehandles-objects.html =encoding utf8 =head1 NAME -Dpkg::Compression::FileHandle - object dealing transparently with file compression +Dpkg::Compression::FileHandle - class dealing transparently with file compression =head1 SYNOPSIS @@ -76,7 +76,7 @@ Dpkg::Compression::FileHandle - object dealing transparently with file compressi =head1 DESCRIPTION -Dpkg::Compression::FileHandle is an object that can be used +Dpkg::Compression::FileHandle is a class that can be used like any filehandle and that deals transparently with compressed files. By default, the compression scheme is guessed from the filename but you can override this behaviour with the method C. @@ -102,8 +102,8 @@ and you can't seek on a pipe. =head1 FileHandle METHODS -The object inherits from IO::File so all methods that work on this -object should work for Dpkg::Compression::FileHandle too. There +The class inherits from IO::File so all methods that work on this +class should work for Dpkg::Compression::FileHandle too. There may be exceptions though. =head1 PUBLIC METHODS @@ -121,7 +121,7 @@ obviously incompatible with automatic detection of the compression method. =cut -# Object methods +# Class methods sub new { my ($this, %args) = @_; my $class = ref($this) || $this; @@ -378,7 +378,7 @@ sub use_compression { =item $real_fh = $fh->get_filehandle() Returns the real underlying filehandle. Useful if you want to pass it -along in a derived object. +along in a derived class. =cut @@ -444,9 +444,9 @@ sub _cleanup { =back -=head1 DERIVED OBJECTS +=head1 DERIVED CLASSES -If you want to create an object that inherits from +If you want to create a class that inherits from Dpkg::Compression::FileHandle you must be aware that the object is a reference to a GLOB that is returned by Symbol::gensym() and as such it's not a HASH. diff --git a/scripts/Dpkg/Control/Changelog.pm b/scripts/Dpkg/Control/Changelog.pm index 1f65127c4..9184cedbc 100644 --- a/scripts/Dpkg/Control/Changelog.pm +++ b/scripts/Dpkg/Control/Changelog.pm @@ -32,7 +32,7 @@ Dpkg::Control::Changelog - represent info fields output by dpkg-parsechangelog =head1 DESCRIPTION -This object derives directly from Dpkg::Control with the type +This class derives directly from Dpkg::Control with the type CTRL_CHANGELOG. =head1 METHODS diff --git a/scripts/Dpkg/Control/HashCore.pm b/scripts/Dpkg/Control/HashCore.pm index 542069332..04a8a574b 100644 --- a/scripts/Dpkg/Control/HashCore.pm +++ b/scripts/Dpkg/Control/HashCore.pm @@ -43,7 +43,7 @@ Dpkg::Control::HashCore - parse and manipulate a block of RFC822-like fields =head1 DESCRIPTION -The Dpkg::Control::Hash object is a hash-like representation of a set of +The Dpkg::Control::Hash class is a hash-like representation of a set of RFC822-like fields. The fields names are case insensitive and are always capitalized the same when output (see field_capitalize function in Dpkg::Control::Fields). @@ -440,7 +440,7 @@ sub apply_substvars { package Dpkg::Control::HashCore::Tie; -# This object is used to tie a hash. It implements hash-like functions by +# This class is used to tie a hash. It implements hash-like functions by # normalizing the name of fields received in keys (using # Dpkg::Control::Fields::field_capitalize). It also stores the order in # which fields have been added in order to be able to dump them in the diff --git a/scripts/Dpkg/Control/Info.pm b/scripts/Dpkg/Control/Info.pm index 9b07eedbe..5759ab5ad 100644 --- a/scripts/Dpkg/Control/Info.pm +++ b/scripts/Dpkg/Control/Info.pm @@ -38,7 +38,7 @@ Dpkg::Control::Info - parse files like debian/control =head1 DESCRIPTION -It provides an object to access data of files that follow the same +It provides a class to access data of files that follow the same syntax as F. =head1 METHODS diff --git a/scripts/Dpkg/Control/Tests.pm b/scripts/Dpkg/Control/Tests.pm index 439eee8c8..3c8d1c006 100644 --- a/scripts/Dpkg/Control/Tests.pm +++ b/scripts/Dpkg/Control/Tests.pm @@ -34,7 +34,7 @@ Dpkg::Control::Tests - parse files like debian/tests/control =head1 DESCRIPTION -It provides an object to access data of files that follow the same +It provides a class to access data of files that follow the same syntax as F. =head1 METHODS diff --git a/scripts/Dpkg/Control/Tests/Entry.pm b/scripts/Dpkg/Control/Tests/Entry.pm index 92eea49f4..001a6f429 100644 --- a/scripts/Dpkg/Control/Tests/Entry.pm +++ b/scripts/Dpkg/Control/Tests/Entry.pm @@ -34,7 +34,7 @@ Dpkg::Control::Tests::Entry - represents a test suite entry =head1 DESCRIPTION -This object represents a test suite entry. +This class represents a test suite entry. =head1 METHODS diff --git a/scripts/Dpkg/Deps.pm b/scripts/Dpkg/Deps.pm index ec02fd8c8..80d249019 100644 --- a/scripts/Dpkg/Deps.pm +++ b/scripts/Dpkg/Deps.pm @@ -29,7 +29,7 @@ Dpkg::Deps - parse and manipulate dependencies of Debian packages =head1 DESCRIPTION -The Dpkg::Deps module provides objects implementing various types of +The Dpkg::Deps module provides classes implementing various types of dependencies. The most important function is deps_parse(), it turns a dependency line in @@ -429,11 +429,11 @@ sub deps_compare { } } -=head1 OBJECTS - Dpkg::Deps::* +=head1 CLASSES - Dpkg::Deps::* There are several kind of dependencies. A Dpkg::Deps::Simple dependency represents a single dependency statement (it relates to one package only). -Dpkg::Deps::Multiple dependencies are built on top of this object +Dpkg::Deps::Multiple dependencies are built on top of this class and combine several dependencies in different manners. Dpkg::Deps::AND represents the logical "AND" between dependencies while Dpkg::Deps::OR represents the logical "OR". Dpkg::Deps::Multiple objects can contain @@ -443,7 +443,7 @@ In practice, the code is only meant to handle the realistic cases which, given Debian's dependencies structure, imply those restrictions: AND can contain Simple or OR objects, OR can only contain Simple objects. -Dpkg::Deps::KnownFacts is a special object that is used while evaluating +Dpkg::Deps::KnownFacts is a special class that is used while evaluating dependencies and while trying to simplify them. It represents a set of installed packages along with the virtual packages that they might provide. diff --git a/scripts/Dpkg/Deps/AND.pm b/scripts/Dpkg/Deps/AND.pm index e16a2cf35..7b403c237 100644 --- a/scripts/Dpkg/Deps/AND.pm +++ b/scripts/Dpkg/Deps/AND.pm @@ -29,7 +29,7 @@ Dpkg::Deps::AND - list of AND dependencies =head1 DESCRIPTION -This object represents a list of dependencies that must be met at the same +This class represents a list of dependencies that must be met at the same time. It inherits from Dpkg::Deps::Multiple. =cut diff --git a/scripts/Dpkg/Deps/KnownFacts.pm b/scripts/Dpkg/Deps/KnownFacts.pm index a414eb49b..ef8655fdd 100644 --- a/scripts/Dpkg/Deps/KnownFacts.pm +++ b/scripts/Dpkg/Deps/KnownFacts.pm @@ -29,7 +29,7 @@ Dpkg::Deps::KnownFacts - list of installed real and virtual packages =head1 DESCRIPTION -This object represents a list of installed packages and a list of virtual +This class represents a list of installed packages and a list of virtual packages provided (by the set of installed packages). =cut diff --git a/scripts/Dpkg/Deps/OR.pm b/scripts/Dpkg/Deps/OR.pm index b2f8d03ed..4ce5c9818 100644 --- a/scripts/Dpkg/Deps/OR.pm +++ b/scripts/Dpkg/Deps/OR.pm @@ -29,7 +29,7 @@ Dpkg::Deps::OR - list of OR dependencies =head1 DESCRIPTION -This object represents a list of dependencies of which only one must be met +This class represents a list of dependencies of which only one must be met for the dependency to be true. It inherits from Dpkg::Deps::Multiple. =cut diff --git a/scripts/Dpkg/Deps/Simple.pm b/scripts/Dpkg/Deps/Simple.pm index efe635cec..aa23e7da2 100644 --- a/scripts/Dpkg/Deps/Simple.pm +++ b/scripts/Dpkg/Deps/Simple.pm @@ -29,7 +29,8 @@ Dpkg::Deps::Simple - represents a single dependency statement =head1 DESCRIPTION -This object has several interesting properties: +This class represents a single dependency statement. +It has several interesting properties: =over 4 @@ -576,7 +577,7 @@ sub get_evaluation { =item $dep->simplify_deps($facts, @assumed_deps) Simplifies the dependency as much as possible given the list of facts (see -object Dpkg::Deps::KnownFacts) and a list of other dependencies that are +class Dpkg::Deps::KnownFacts) and a list of other dependencies that are known to be true. =cut diff --git a/scripts/Dpkg/Deps/Union.pm b/scripts/Dpkg/Deps/Union.pm index 62cf5c38a..148e38ed3 100644 --- a/scripts/Dpkg/Deps/Union.pm +++ b/scripts/Dpkg/Deps/Union.pm @@ -29,8 +29,8 @@ Dpkg::Deps::Union - list of unrelated dependencies =head1 DESCRIPTION -This object represents a list of relationships. It inherits from -Dpkg::Deps::Multiple. +This class represents a list of relationships. +It inherits from Dpkg::Deps::Multiple. =cut diff --git a/scripts/Dpkg/Index.pm b/scripts/Dpkg/Index.pm index 7859bf669..cfe86ba17 100644 --- a/scripts/Dpkg/Index.pm +++ b/scripts/Dpkg/Index.pm @@ -39,7 +39,7 @@ Dpkg::Index - generic index of control information =head1 DESCRIPTION -This object represent a set of Dpkg::Control objects. +This class represent a set of Dpkg::Control objects. =head1 METHODS diff --git a/scripts/Dpkg/Interface/Storable.pm b/scripts/Dpkg/Interface/Storable.pm index 5ed308cf2..5ac078ac1 100644 --- a/scripts/Dpkg/Interface/Storable.pm +++ b/scripts/Dpkg/Interface/Storable.pm @@ -38,12 +38,12 @@ Dpkg::Interface::Storable - common methods related to object serialization =head1 DESCRIPTION Dpkg::Interface::Storable is only meant to be used as parent -class for other objects. It provides common methods that are +class for other classes. It provides common methods that are all implemented on top of two basic methods parse() and output(). =head1 BASE METHODS -Those methods must be provided by the object that wish to inherit +Those methods must be provided by the class that wish to inherit from Dpkg::Interface::Storable so that the methods provided can work. =over 4 diff --git a/scripts/Dpkg/Source/Format.pm b/scripts/Dpkg/Source/Format.pm index 55172a2ef..41596a233 100644 --- a/scripts/Dpkg/Source/Format.pm +++ b/scripts/Dpkg/Source/Format.pm @@ -24,7 +24,7 @@ Dpkg::Source::Format - manipulate debian/source/format files =head1 DESCRIPTION -This module provides an object that can manipulate Debian source +This module provides a class that can manipulate Debian source package F files. =cut diff --git a/scripts/Dpkg/Source/Package.pm b/scripts/Dpkg/Source/Package.pm index d38e228e5..337000cb8 100644 --- a/scripts/Dpkg/Source/Package.pm +++ b/scripts/Dpkg/Source/Package.pm @@ -24,7 +24,7 @@ Dpkg::Source::Package - manipulate Debian source packages =head1 DESCRIPTION -This module provides an object that can manipulate Debian source +This module provides a class that can manipulate Debian source packages. While it supports both the extraction and the creation of source packages, the only API that is officially supported is the one that supports the extraction of the source package. @@ -204,7 +204,7 @@ source package after its extraction. =cut -# Object methods +# Class methods sub new { my ($this, %args) = @_; my $class = ref($this) || $this; diff --git a/scripts/Dpkg/Substvars.pm b/scripts/Dpkg/Substvars.pm index 49ebd902b..27107fe3d 100644 --- a/scripts/Dpkg/Substvars.pm +++ b/scripts/Dpkg/Substvars.pm @@ -39,7 +39,7 @@ Dpkg::Substvars - handle variable substitution in strings =head1 DESCRIPTION -It provides an object which is able to substitute variables in strings. +It provides a class which is able to substitute variables in strings. =cut diff --git a/scripts/Dpkg/Vendor/Debian.pm b/scripts/Dpkg/Vendor/Debian.pm index a37b23cfc..c3e580da7 100644 --- a/scripts/Dpkg/Vendor/Debian.pm +++ b/scripts/Dpkg/Vendor/Debian.pm @@ -36,11 +36,11 @@ use parent qw(Dpkg::Vendor::Default); =head1 NAME -Dpkg::Vendor::Debian - Debian vendor object +Dpkg::Vendor::Debian - Debian vendor class =head1 DESCRIPTION -This vendor object customizes the behaviour of dpkg scripts for Debian +This vendor class customizes the behaviour of dpkg scripts for Debian specific behavior and policies. =cut diff --git a/scripts/Dpkg/Vendor/Default.pm b/scripts/Dpkg/Vendor/Default.pm index 6b7c5204f..42b0f0405 100644 --- a/scripts/Dpkg/Vendor/Default.pm +++ b/scripts/Dpkg/Vendor/Default.pm @@ -20,7 +20,7 @@ use warnings; our $VERSION = '0.01'; -# If you use this file as template to create a new vendor object, please +# If you use this file as template to create a new vendor class, please # uncomment the following lines #use parent qw(Dpkg::Vendor::Default); @@ -28,12 +28,12 @@ our $VERSION = '0.01'; =head1 NAME -Dpkg::Vendor::Default - default vendor object +Dpkg::Vendor::Default - default vendor class =head1 DESCRIPTION -A vendor object is used to provide vendor specific behaviour -in various places. This is the default object used in case +A vendor class is used to provide vendor specific behaviour +in various places. This is the default class used in case there's none for the current vendor or in case the vendor could not be identified (see Dpkg::Vendor documentation). diff --git a/scripts/Dpkg/Vendor/Ubuntu.pm b/scripts/Dpkg/Vendor/Ubuntu.pm index e6335c204..ddee2a192 100644 --- a/scripts/Dpkg/Vendor/Ubuntu.pm +++ b/scripts/Dpkg/Vendor/Ubuntu.pm @@ -34,11 +34,11 @@ use parent qw(Dpkg::Vendor::Debian); =head1 NAME -Dpkg::Vendor::Ubuntu - Ubuntu vendor object +Dpkg::Vendor::Ubuntu - Ubuntu vendor class =head1 DESCRIPTION -This vendor object customizes the behaviour of dpkg scripts for Ubuntu +This vendor class customizes the behaviour of dpkg scripts for Ubuntu specific behavior and policies. =cut -- cgit v1.2.3 From 2eafcd122aa4e772cd6bb40c3eb82ac27aff3646 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 5 Nov 2019 12:57:13 +0100 Subject: Dpkg::Changelog: Clarify inheritance and implementation references Make it clear that these classes inherit from some other base class, which will contain the missing documentation. Prompted-by: intrigeri --- debian/changelog | 3 +++ scripts/Dpkg/Changelog/Debian.pm | 13 ++++++++++--- scripts/Dpkg/Changelog/Entry/Debian.pm | 7 ++++--- 3 files changed, 17 insertions(+), 6 deletions(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index d41eaa836..3874bc4e1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -88,6 +88,9 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - man: Move template symbol documentation into new deb-src-symbols(5). - Dpkg::Changelog::Parse: Remove $ sigil from option names in POD. - Dpkg: Say class instead of object when appropriate. + - Dpkg::Changelog: Clarify that these classes inherit from some other + base class, which will contain the missing documentation. + Prompted by intrigeri . * Code internals: - Dpkg::Source::Package: Refactor original tarball handling. - perl: Use File::Copy instead of spawning mv/cp commands. diff --git a/scripts/Dpkg/Changelog/Debian.pm b/scripts/Dpkg/Changelog/Debian.pm index 937acb5e0..a85f3af12 100644 --- a/scripts/Dpkg/Changelog/Debian.pm +++ b/scripts/Dpkg/Changelog/Debian.pm @@ -24,6 +24,12 @@ Dpkg::Changelog::Debian - parse Debian changelogs =head1 DESCRIPTION +This class represents a Debian changelog file as an array of changelog +entries (Dpkg::Changelog::Entry::Debian). +It implements the generic interface Dpkg::Changelog. +Only methods specific to this implementation are described below, +the rest are inherited. + Dpkg::Changelog::Debian parses Debian changelogs as described in deb-changelog(5). @@ -118,10 +124,11 @@ my $ancient_delimiter_re = qr{ =over 4 -=item $c->parse($fh, $description) +=item $count = $c->parse($fh, $description) -Read the filehandle and parse a Debian changelog in it. The data in the -object is reset before parsing new data. +Read the filehandle and parse a Debian changelog in it, to store the entries +as an array of Dpkg::Changelog::Entry::Debian objects. +Any previous entries in the object are reset before parsing new data. Returns the number of changelog entries that have been parsed with success. diff --git a/scripts/Dpkg/Changelog/Entry/Debian.pm b/scripts/Dpkg/Changelog/Entry/Debian.pm index 8658ae493..1e7daf55b 100644 --- a/scripts/Dpkg/Changelog/Entry/Debian.pm +++ b/scripts/Dpkg/Changelog/Entry/Debian.pm @@ -45,9 +45,10 @@ Dpkg::Changelog::Entry::Debian - represents a Debian changelog entry =head1 DESCRIPTION -This class represents a Debian changelog entry. It implements the -generic interface Dpkg::Changelog::Entry. Only functions specific to this -implementation are described below. +This class represents a Debian changelog entry. +It implements the generic interface Dpkg::Changelog::Entry. +Only functions specific to this implementation are described below, +the rest are inherited. =cut -- cgit v1.2.3 From 89afa9af7cd589eb8384ed96b6d86dd59d56bdf5 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 5 Nov 2019 12:59:17 +0100 Subject: Dpkg::Source::Package::V3::Native: Do not say v1.0 for 3.0 formats --- debian/changelog | 1 + scripts/Dpkg/Source/Package/V3/Native.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts/Dpkg') diff --git a/debian/changelog b/debian/changelog index 3874bc4e1..b3a0fbe91 100644 --- a/debian/changelog +++ b/debian/changelog @@ -74,6 +74,7 @@ dpkg (1.20.0) UNRELEASED; urgency=medium - Dpkg::Exit: Unregister all signal handlers once we have executed them. Closes: #932841 - Dpkg::Exit: Register exit handlers also for __DIE__. + - Dpkg::Source::Package::V3::Native: Do not say v1.0 for 3.0 formats. * Documentation: - man: Fix uncommon wording constructs. - man: Use a minus sign for a literal string. diff --git a/scripts/Dpkg/Source/Package/V3/Native.pm b/scripts/Dpkg/Source/Package/V3/Native.pm index b53a30f3f..1d0de2b0f 100644 --- a/scripts/Dpkg/Source/Package/V3/Native.pm +++ b/scripts/Dpkg/Source/Package/V3/Native.pm @@ -49,7 +49,7 @@ sub do_extract { my $comp_ext_regex = compression_get_file_extension_regex(); foreach my $file ($self->get_files()) { if ($file =~ /^\Q$basenamerev\E\.tar\.$comp_ext_regex$/) { - error(g_('multiple tarfiles in v1.0 source package')) if $tarfile; + error(g_('multiple tarfiles in native source package')) if $tarfile; $tarfile = $file; } else { error(g_('unrecognized file for a native source package: %s'), $file); -- cgit v1.2.3