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. --- scripts/Dpkg/Source/Package/V2.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts/Dpkg/Source') 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/Source') 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 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/Source') 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/Source') 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 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/Source') 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 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/Source') 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/Source') 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/Source') 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 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/Source') 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 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/Source') 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/Source') 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/Source') 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/Source') 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/Source') 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/Source') 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/Source') 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 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/Source') 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 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/Source') 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/Source') 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 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/Source') 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/Source') 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/Source') 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/Source') 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 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/Source') 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 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/Source') 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 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/Source') 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 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/Source') 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/Source') 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 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/Source') 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