Kaynağa Gözat

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.
Raphael Hertzog 18 yıl önce
ebeveyn
işleme
a0d215a3d7
5 değiştirilmiş dosya ile 43 ekleme ve 8 silme
  1. 4 0
      ChangeLog
  2. 4 0
      debian/changelog
  3. 4 5
      man/dpkg-genchanges.1
  4. 1 1
      scripts/Dpkg/Version.pm
  5. 30 2
      scripts/dpkg-genchanges.pl

+ 4 - 0
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  <guillem@debian.org>
 
 	* m4/arch.m4 (_DPKG_ARCHITECTURE): Do not use backticks inside double

+ 4 - 0
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

+ 4 - 5
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.

+ 1 - 1
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
 

+ 30 - 2
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<maintainer>           override control's maintainer value.
   -e<maintainer>           override changelog's maintainer value.
   -u<uploadfilesdir>       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");