[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] dpkg-genchanges: Enhance logic to decide if we include orig tarballs



By default, include orig tarballs only if the current upstream version
differs from the previous changelog entry. Closes: #28701
---
 man/dpkg-genchanges.1      |    9 ++++-----
 scripts/dpkg-genchanges.pl |   31 ++++++++++++++++++++++++++++---
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/man/dpkg-genchanges.1 b/man/dpkg-genchanges.1
index 37ab325..2662cca 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-genchanges.pl b/scripts/dpkg-genchanges.pl
index 3e5f6d5..d825581 100755
--- a/scripts/dpkg-genchanges.pl
+++ b/scripts/dpkg-genchanges.pl
@@ -110,7 +110,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.
@@ -189,7 +189,11 @@ my $changelog = parse_changelog(%options);
 delete $options{"since"};
 $options{"count"} = 1;
 $options{"offset"} = 1;
-my $prev_changelog = parse_changelog(%options);
+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();
@@ -402,7 +406,28 @@ 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_uv = $sversion;
+	my $prev_uv = $prev_changelog->{"Version"};
+	$prev_uv =~ s/^\d+://;
+	$cur_uv =~ s/-[^-]+$//;
+	$prev_uv =~ s/-[^-]+$//;
+	$include_tarball = ($cur_uv ne $prev_uv) ? 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");
-- 
1.5.3.8


Reply to: