Control: tags 762715 +patch

On Mon, Oct 31, 2016 at 12:10:37PM -0400, Antoine Beaupré wrote:
> On 2016-10-28 20:10:43, Holger Levsen wrote:
> >> Since this may change again in the future before this issue is resolved,
> >> maybe it's better to just refer to the LTS notes here:
> >> https://wiki.debian.org/LTS/Development#Build_the_update
> >
> > no. "dch --lts" should do the right thing - and just like "dch --bpo" it
> > will be outdated & in need of an update once in a while - each time we
> > release… \o/ yay! :)
> 
> There are probably ways to make it use variables instead of hardcoding
> (say) "wheezy-security"... :)
> 
> I looked at the code and there are around 14 instances of "$opt_s" in
> the code. Either we need to duplicate that or make --lts enable $opt_s
> and customize some bits of it.

I ended up copying the -s option the same way lamby copied the --bpo
option to create --sru in #871657. Not ideal, but at this point it's the
way of the land...

So attached are patches to add a --lts option. I figured I would do
*some* refactoring while I was there to avoid further code duplication.
I haven't tested all scenarios (and the test suite is limited in that
regard) but this mostly works in my tests locally.

A.
From 0d1b329ac97c54a3163d350b9e5d37cfc9e9dad8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anar...@debian.org>
Date: Mon, 23 Oct 2017 10:29:28 -0400
Subject: [PATCH 1/2] unify version information

instead of having a guessed version info per type of upload (stable,
bpo, but also eventually lts, security, etc), we just have a single
variable we use.

we also merge the bpo and stable information hashes because they
mostly contain the same data. only stable had less information, but if
the info wasn't found, it was falling back to the previous entry in
the changelog, which is not better than our guess.

this also partly fixes -s uploads distro guessing.
---
 scripts/debchange.pl | 57 +++++++++++++++++++++++-----------------------------
 1 file changed, 25 insertions(+), 32 deletions(-)

diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index ef8b84b5..00da3b6d 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -611,11 +611,10 @@ ()
 my $MAINTAINER = 'MAINTAINER';
 my $EMAIL = 'EMAIL';
 my $DISTRIBUTION = 'UNRELEASED';
-my $bpo_dist = '';
-my %bpo_dists = ( 60, 'squeeze', 70, 'wheezy', 8, 'jessie', 9, 'stretch' );
-my $stable_dist = '';
-my %stable_dists = ( 8, 'jessie', 9, 'stretch' );
+my %dists = ( 60, 'squeeze', 70, 'wheezy', 7, 'wheezy', 8, 'jessie', 9, 'stretch' );
 my $latest_dist = '9';
+# dist guessed from backports, SRU, security uploads...
+my $guessed_dist = '';
 my $CHANGES = '';
 # Changelog urgency, possibly propogated to NEWS files
 my $CL_URGENCY = '';
@@ -1168,31 +1167,25 @@ ()
 		    $end++;
 		}
 
-		# Attempt to set the distribution for a backport correctly
-		# based on the version of the previous backport
-		if ($opt_bpo) {
-		    my $previous_dist = $start;
-		    $previous_dist =~ s/^.*~bpo(\d+)\+$/$1/;
-		    if (defined $previous_dist and defined
-			$bpo_dists{$previous_dist}) {
-			$bpo_dist = $bpo_dists{$previous_dist} . '-backports';
-		    } else {
-			# Fallback to using the previous distribution
-			$bpo_dist = $changelog->{Distribution};
-		    }
-		}
-
 		# Attempt to set the distribution for a stable upload correctly
 		# based on the version of the previous upload
-		if ($opt_stable) {
+		if ($opt_stable || $opt_bpo || $opt_s) {
 		    my $previous_dist = $start;
-		    $previous_dist =~ s/^.*+deb(\d+)u$/$1/;
+		    $previous_dist =~ s/^.*[+~]deb(\d+)u$/$1/;
 		    if (defined $previous_dist and defined
-			$stable_dists{$previous_dist}) {
-			$stable_dist = $stable_dists{$previous_dist};
-		    } else {
+			$dists{$previous_dist}) {
+                        if ($opt_s) {
+                            $guessed_dist = $dists{$previous_dist} . '-security';
+                        } elsif ($opt_bpo) {
+                            $guessed_dist = $dists{$previous_dist} . '-backports';
+                        } else {
+                            $guessed_dist = $dists{$previous_dist};
+                        }
+                    } elsif ($opt_s) {
+                        $guessed_dist = $dists{$latest_dist} . '-security';
+                    } else {
 			# Fallback to using the previous distribution
-			$stable_dist = $changelog->{Distribution};
+			$guessed_dist = $changelog->{Distribution};
 		    }
 		}
 
@@ -1231,12 +1224,12 @@ ()
     }
 
     if ($opt_bpo) {
-	$bpo_dist ||= $bpo_dists{$latest_dist} . '-backports';
+	$guessed_dist ||= $dists{$latest_dist} . '-backports';
     }
     if ($opt_stable) {
-	$stable_dist ||= $stable_dists{$latest_dist};
+	$guessed_dist ||= $dists{$latest_dist};
     }
-    my $distribution = $opt_D || $bpo_dist || $stable_dist || (($opt_release_heuristic eq 'changelog') ? "UNRELEASED" : $DISTRIBUTION);
+    my $distribution = $opt_D || $guessed_dist || (($opt_release_heuristic eq 'changelog') ? "UNRELEASED" : $DISTRIBUTION);
 
     my $urgency = $opt_u;
     if ($opt_news) {
@@ -1275,7 +1268,7 @@ ()
 	    print O "  * Team upload.\n";
 	    $line = 1;
 	} elsif ($opt_bpo && ! $opt_news) {
-	    print O "  * Rebuild for $bpo_dist.\n";
+	    print O "  * Rebuild for $guessed_dist.\n";
 	    $line = 1;
 	}
 	if (@closes_text or $TEXT or $EMPTY_TEXT) {
@@ -1334,11 +1327,11 @@ ()
 	    else {
 		my $tmpver = $1;
 		$tmpver =~ s/^\s+//;
-		if ($tmpver =~ m/~bpo(\d+)\+/ && exists $bpo_dists{$1}) {
-		    $dist_indicator = "$bpo_dists{$1}-backports";
+		if ($tmpver =~ m/~bpo(\d+)\+/ && exists $dists{$1}) {
+		    $dist_indicator = "$dists{$1}-backports";
 		}
-		if ($tmpver =~ m/\+deb(\d+)u/ && exists $stable_dists{$1}) {
-		    $dist_indicator = "$stable_dists{$1}";
+		if ($tmpver =~ m/\+deb(\d+)u/ && exists $dists{$1}) {
+		    $dist_indicator = "$dists{$1}";
 		}
 	    }
 	}
-- 
2.11.0

From 982eb2bfb24539ea2b6ddbdb2c7743ccb9794323 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anar...@debian.org>
Date: Mon, 23 Oct 2017 10:30:18 -0400
Subject: [PATCH 2/2] add support for preparing uploads to LTS

---
 scripts/debchange.1               |  4 ++++
 scripts/debchange.bash_completion |  2 +-
 scripts/debchange.pl              | 33 +++++++++++++++++++++------------
 test/test_debchange               |  3 +++
 4 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/scripts/debchange.1 b/scripts/debchange.1
index f5394944..f29d6816 100644
--- a/scripts/debchange.1
+++ b/scripts/debchange.1
@@ -246,6 +246,10 @@ appending a "build1" or by incrementing a rebuild version number.
 Increment the Debian release number for a Debian Security Team non-maintainer
 upload, and add a \fBSecurity Team upload\fR changelog comment.
 .TP
+.BR \-\-lts
+Increment the Debian release number for a LTS Security Team non-maintainer
+upload, and add a \fBLTS Security Team upload\fR changelog comment.
+.TP
 .B \-\-team
 Increment the Debian release number for a team upload, and add a \fBTeam upload\fR
 changelog comment.
diff --git a/scripts/debchange.bash_completion b/scripts/debchange.bash_completion
index 85df2820..d136eb6c 100644
--- a/scripts/debchange.bash_completion
+++ b/scripts/debchange.bash_completion
@@ -11,7 +11,7 @@ _debchange()
     prev=${COMP_WORDS[COMP_CWORD-1]}
     options='-a --append -i --increment -v --newversion -e --edit\
              -r --release --force-save-on-release --no-force-save-on-release\
-             --create --empty --package --auto-nmu --no-auto-nmu -n --nmu\
+             --create --empty --package --auto-nmu --no-auto-nmu -n --nmu --lts\
              --bin-nmu -q --qa -R --rebuild -s --security --team -U --upstream\
              --bpo --stable -l --local -b --force-bad-version --allow-lower-version\
              --force-distribution --closes --noquery --query -d --fromdirname\
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index 00da3b6d..d01ca9a8 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -154,6 +154,8 @@ ()
          Increment the Debian release number for a no-change rebuild
   -s, --security
          Increment the Debian release number for a Debian Security Team upload
+  --lts
+         Increment the Debian release number for a LTS Security Team upload
   --team
          Increment the Debian release number for a team upload
   -U, --upstream
@@ -231,7 +233,7 @@ ()
   --version
          Display version information
   At most one of -a, -i, -e, -r, -v, -d, -n, --bin-nmu, -q, --qa, -R, -s,
-  --team, --bpo, --stable, -l (or their long equivalents) may be used.
+  --lts, --team, --bpo, --stable, -l (or their long equivalents) may be used.
   With no options, one of -i or -a is chosen by looking at the release
   specified in the changelog.
 
@@ -351,7 +353,7 @@ ()
 # with older debchange versions.
 my ($opt_help, $opt_version);
 my ($opt_i, $opt_a, $opt_e, $opt_r, $opt_v, $opt_b, $opt_d, $opt_D, $opt_u, $opt_force_dist);
-my ($opt_n, $opt_bn, $opt_qa, $opt_R, $opt_s, $opt_team, $opt_U, $opt_bpo, $opt_stable, $opt_l, $opt_c, $opt_m, $opt_M, $opt_create, $opt_package, @closes);
+my ($opt_n, $opt_bn, $opt_qa, $opt_R, $opt_s, $opt_lts, $opt_team, $opt_U, $opt_bpo, $opt_stable, $opt_l, $opt_c, $opt_m, $opt_M, $opt_create, $opt_package, @closes);
 my ($opt_news);
 my ($opt_level, $opt_regex, $opt_noconf, $opt_empty);
 
@@ -381,6 +383,7 @@ ()
 	   "team" => \$opt_team,
 	   "U|upstream" => \$opt_U,
 	   "bpo" => \$opt_bpo,
+           "lts" => \$opt_lts,
 	   "stable" => \$opt_stable,
 	   "l|local=s" => \$opt_l,
 	   "query!" => \$opt_query,
@@ -433,8 +436,8 @@ ()
 if (defined $opt_regex) { $check_dirname_regex = $opt_regex; }
 
 # Only allow at most one non-help option
-fatal "Only one of -a, -i, -e, -r, -v, -d, -n/--nmu, --bin-nmu, -q/--qa, -R/--rebuild, -s/--security, --team, --bpo, --stable, -l/--local is allowed;\ntry $progname --help for more help"
-    if ($opt_i?1:0) + ($opt_a?1:0) + ($opt_e?1:0) + ($opt_r?1:0) + ($opt_v?1:0) + ($opt_d?1:0) + ($opt_n?1:0) + ($opt_bn?1:0) + ($opt_qa?1:0) + ($opt_R?1:0) + ($opt_s?1:0) + ($opt_team?1:0) + ($opt_bpo?1:0) + ($opt_l?1:0) > 1;
+fatal "Only one of -a, -i, -e, -r, -v, -d, -n/--nmu, --bin-nmu, -q/--qa, -R/--rebuild, -s/--security, --lts, --team, --bpo, --stable, -l/--local is allowed;\ntry $progname --help for more help"
+    if ($opt_i?1:0) + ($opt_a?1:0) + ($opt_e?1:0) + ($opt_r?1:0) + ($opt_v?1:0) + ($opt_d?1:0) + ($opt_n?1:0) + ($opt_bn?1:0) + ($opt_qa?1:0) + ($opt_R?1:0) + ($opt_s?1:0) + ($opt_lts?1:0) + ($opt_team?1:0) + ($opt_bpo?1:0) + ($opt_l?1:0) > 1;
 
 if ($opt_s) {
     $opt_u = "high";
@@ -468,7 +471,7 @@ ()
     }
 }
 $vendor ||= 'Debian';
-if ($vendor eq 'Ubuntu' and ($opt_n or $opt_bn or $opt_qa or $opt_bpo or $opt_stable)) {
+if ($vendor eq 'Ubuntu' and ($opt_n or $opt_bn or $opt_qa or $opt_bpo or $opt_stable or $opt_lts)) {
     $vendor = 'Debian';
 }
 
@@ -543,9 +546,9 @@ ()
 
 if ($opt_create) {
     if ($opt_a || $opt_i || $opt_e || $opt_r || $opt_b || $opt_n || $opt_bn ||
-	    $opt_qa || $opt_R || $opt_s || $opt_team || $opt_bpo || $opt_l ||
+	    $opt_qa || $opt_R || $opt_s || $opt_team || $opt_lts || $opt_bpo || $opt_l ||
 	    $opt_allow_lower) {
-	warn "$progname warning: ignoring -a/-i/-e/-r/-b/--allow-lower-version/-n/--bin-nmu/-q/--qa/-R/-s/--team/--bpo/--stable,-l options with --create\n";
+	warn "$progname warning: ignoring -a/-i/-e/-r/-b/--allow-lower-version/-n/--bin-nmu/-q/--qa/-R/-s/--lts/--team/--bpo/--stable,-l options with --create\n";
 	$warnings++;
     }
     if ($opt_package && $opt_d) {
@@ -612,6 +615,7 @@ ()
 my $EMAIL = 'EMAIL';
 my $DISTRIBUTION = 'UNRELEASED';
 my %dists = ( 60, 'squeeze', 70, 'wheezy', 7, 'wheezy', 8, 'jessie', 9, 'stretch' );
+my $lts_dist = '7';
 my $latest_dist = '9';
 # dist guessed from backports, SRU, security uploads...
 my $guessed_dist = '';
@@ -819,7 +823,7 @@ ()
 
 #####
 
-if ($opt_auto_nmu eq 'yes' and ! $opt_v and ! $opt_l and ! $opt_s and
+if ($opt_auto_nmu eq 'yes' and ! $opt_v and ! $opt_l and ! $opt_s and ! $opt_lts and
     ! $opt_team and ! $opt_qa and ! $opt_R and ! $opt_bpo and ! $opt_bn and
     ! $opt_n and ! $opt_c and ! $opt_stable and
     ! (exists $ENV{'CHANGELOG'} and length $ENV{'CHANGELOG'}) and ! $opt_M and
@@ -956,7 +960,7 @@ ()
 
 # Are we going to have to figure things out for ourselves?
 if (! $opt_i && ! $opt_v && ! $opt_d && ! $opt_a && ! $opt_e && ! $opt_r &&
-    ! $opt_n && ! $opt_bn && ! $opt_qa && ! $opt_R && ! $opt_s && ! $opt_team &&
+    ! $opt_n && ! $opt_bn && ! $opt_qa && ! $opt_R && ! $opt_s && !$opt_lts && ! $opt_team &&
     ! $opt_bpo && ! $opt_stable && ! $opt_l && ! $opt_create) {
     # Yes, we are
     if ($opt_release_heuristic eq 'log') {
@@ -1033,7 +1037,7 @@ ()
 my $optionsok=0;
 my $merge=0;
 
-if (($opt_i || $opt_n || $opt_bn || $opt_qa || $opt_R || $opt_s || $opt_team ||
+if (($opt_i || $opt_n || $opt_bn || $opt_qa || $opt_R || $opt_s || $opt_lts || $opt_team ||
      $opt_bpo || $opt_stable || $opt_l || $opt_v || $opt_d ||
     ($opt_news && $VERSION ne $changelog->{Version})) && ! $opt_create) {
 
@@ -1138,6 +1142,9 @@ ()
 		$end .= "~bpo$latest_dist+1";
 	    } elsif ($opt_stable and not $start =~ /\+deb\d+u/) {
 		$end .= "+deb${latest_dist}u1";
+            } elsif ($opt_lts and not $start =~ /\+deb\d+u/) {
+                $end .= "+deb${lts_dist}u1";
+                $guessed_dist = $dists{$lts_dist} . '-security';
 	    } elsif ($opt_l and not $start =~ /\Q$opt_l\E/) {
 		# If it's not already a local package make it so
 		# otherwise we can be safe if we behave like dch -i
@@ -1169,12 +1176,12 @@ ()
 
 		# Attempt to set the distribution for a stable upload correctly
 		# based on the version of the previous upload
-		if ($opt_stable || $opt_bpo || $opt_s) {
+		if ($opt_stable || $opt_lts || $opt_bpo || $opt_s) {
 		    my $previous_dist = $start;
 		    $previous_dist =~ s/^.*[+~]deb(\d+)u$/$1/;
 		    if (defined $previous_dist and defined
 			$dists{$previous_dist}) {
-                        if ($opt_s) {
+                        if ($opt_lts || $opt_s) {
                             $guessed_dist = $dists{$previous_dist} . '-security';
                         } elsif ($opt_bpo) {
                             $guessed_dist = $dists{$previous_dist} . '-backports';
@@ -1183,6 +1190,8 @@ ()
                         }
                     } elsif ($opt_s) {
                         $guessed_dist = $dists{$latest_dist} . '-security';
+		    } elsif ($opt_lts) {
+                        $guessed_dist = $dists{$lts_dist} . '-security';
                     } else {
 			# Fallback to using the previous distribution
 			$guessed_dist = $changelog->{Distribution};
diff --git a/test/test_debchange b/test/test_debchange
index 79d64be6..58222d09 100755
--- a/test/test_debchange
+++ b/test/test_debchange
@@ -164,6 +164,9 @@ testEncoding() {
     success "-s \"Security upload\""
     verifyMaintainer "dch -s"
 
+    success "-s \"LTS Security upload\""
+    verifyMaintainer "dch --lts"
+
     success "--bpo \"Backports upload\""
     verifyMaintainer "dch --bpo"
 
-- 
2.11.0

Attachment: signature.asc
Description: PGP signature

Reply via email to