From a0d215a3d7703b46e7c15024569e43b1e182ca88 Mon Sep 17 00:00:00 2001 From: Raphael Hertzog Date: Mon, 14 Jan 2008 23:16:32 +0100 Subject: [PATCH] dpkg-genchanges: Enhance logic to decide if we include the original tarball * scripts/dpkg-genchanges.pl: Change logic of -si option to include the original tarball only if the current upstream version differs from the upstream version of the previous changelog entry. Lack of previous entry also results in the inclusion of the original tarball. --- ChangeLog | 4 ++++ debian/changelog | 4 ++++ man/dpkg-genchanges.1 | 9 ++++----- scripts/Dpkg/Version.pm | 2 +- scripts/dpkg-genchanges.pl | 32 ++++++++++++++++++++++++++++++-- 5 files changed, 43 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 61948a66..07fb92d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,10 @@ the modified parse_changelog(). * scripts/dpkg-gensymbols.pl, scripts/dpkg-source.pl: Likewise. + * scripts/dpkg-genchanges.pl: Change logic of -si option to + include the original tarball only if the current upstream version differs + from the upstream version of the previous changelog entry. + 2008-01-18 Guillem Jover * m4/arch.m4 (_DPKG_ARCHITECTURE): Do not use backticks inside double diff --git a/debian/changelog b/debian/changelog index 546172d2..6749004f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -54,6 +54,10 @@ dpkg (1.14.16) UNRELEASED; urgency=low lesser priority (when -d is used). * Fix behaviour of dpkg-shlibdeps when the same binary was passed multiple times for use in different dependency fields (-d option). + * Change logic of -si option of dpkg-genchanges to include the original + tarball only if the current upstream version differs from the upstream + version of the previous changelog entry. Replaces the heuristic based + on revision number (-0, -0.1 or -1). Closes: #28701 [ Updated manpages translations ] * Fix typo in French. Closes: #460021 diff --git a/man/dpkg-genchanges.1 b/man/dpkg-genchanges.1 index 37ab3256..2662cca0 100644 --- a/man/dpkg-genchanges.1 +++ b/man/dpkg-genchanges.1 @@ -35,11 +35,10 @@ included in the upload if any source is being generated (i.e. haven't been used). .TP .B \-si -By default, or if specified, the original source will be included if the -version number ends in -.BR \-0 " or " \-1 , -i.e. if the Debian revision part of the version number is -.BR 0 " or " 1 . +By default, or if specified, the original source will be included only if +the upstream version number (the version without epoch and without Debian +revision) differs from the upstream version number of the previous +changelog entry. .TP .B \-sa Forces the inclusion of the original source. diff --git a/scripts/Dpkg/Version.pm b/scripts/Dpkg/Version.pm index 3c1f01ed..18dd312a 100644 --- a/scripts/Dpkg/Version.pm +++ b/scripts/Dpkg/Version.pm @@ -25,7 +25,7 @@ use Dpkg::ErrorHandling qw(error); use Exporter; our @ISA = qw(Exporter); -our @EXPORT_OK = qw(vercmp compare_versions check_version); +our @EXPORT_OK = qw(vercmp compare_versions check_version parseversion); =head1 NAME diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 7c8d8595..0255bcba 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -18,6 +18,7 @@ use Dpkg::Cdata; use Dpkg::Substvars; use Dpkg::Vars; use Dpkg::Changelog qw(parse_changelog); +use Dpkg::Version qw(parseversion); textdomain("dpkg-dev"); @@ -111,7 +112,7 @@ Options: -m override control's maintainer value. -e override changelog's maintainer value. -u directory with files (default is \`..'). - -si (default) src includes orig for debian-revision 0 or 1. + -si (default) src includes orig if new upstream. -sa source includes orig src. -sd source is diff and .dsc only. -q quiet - no informational messages on stderr. @@ -186,6 +187,15 @@ my %options = (file => $changelogfile); $options{"changelogformat"} = $changelogformat if $changelogformat; $options{"since"} = $since if $since; my $changelog = parse_changelog(%options); +# Change options to retrieve info of the former changelog entry +delete $options{"since"}; +$options{"count"} = 1; +$options{"offset"} = 1; +my ($prev_changelog, $bad_parser); +eval { # Do not fail if parser failed due to unsupported options + $prev_changelog = parse_changelog(%options); +}; +$bad_parser = 1 if ($@); # Other initializations my $control = Dpkg::Control->new($controlfile); my $fields = Dpkg::Fields::Object->new(); @@ -398,7 +408,25 @@ if (!is_binaryonly) { $f2pri{$f} = $pri; } - if (($sourcestyle =~ m/i/ && $sversion !~ m/-(0|1|0\.1)$/ || + # Compare upstream version to previous upstream version to decide if + # the .orig tarballs must be included + my $include_tarball; + if (defined($prev_changelog)) { + my %cur = parseversion($changelog->{"Version"}); + my %prev = parseversion($prev_changelog->{"Version"}); + $include_tarball = ($cur{"version"} ne $prev{"version"}) ? 1 : 0; + } else { + if ($bad_parser) { + # The parser doesn't support extracting a previous version + # Fallback to version check + $include_tarball = ($sversion =~ /-(0|1|0\.1)$/) ? 1 : 0; + } else { + # No previous entry means first upload, tarball required + $include_tarball = 1; + } + } + + if ((($sourcestyle =~ m/i/ && not($include_tarball)) || $sourcestyle =~ m/d/) && grep(m/\.diff\.$comp_regex$/,@sourcefiles)) { $origsrcmsg= _g("not including original source code in upload"); -- 2.39.5