[devscripts] 02/06: debchange: unify version information
Mattia Rizzolo
mattia at debian.org
Sat Nov 11 23:16:38 UTC 2017
This is an automated email from the git hooks/post-receive script.
mattia pushed a commit to branch master
in repository devscripts.
commit 5069d90b56f7bb28e2ef61c5f27bab9568f15dd9
Author: Antoine Beaupré <anarcat at debian.org>
Date: Sat Nov 11 23:40:36 2017 +0100
debchange: 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.
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
---
scripts/debchange.pl | 58 +++++++++++++++++++++++-----------------------------
test/test_debchange | 22 ++++++++++++++++++++
2 files changed, 48 insertions(+), 32 deletions(-)
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index ca69411..9b353d3 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -611,11 +611,11 @@ my $VERSION = 'VERSION';
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' );
+# when updating the lines below also update the help text, the manpage and the testcases.
+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 +1168,25 @@ if (($opt_i || $opt_n || $opt_bn || $opt_qa || $opt_R || $opt_s || $opt_team ||
$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 +1225,12 @@ if (($opt_i || $opt_n || $opt_bn || $opt_qa || $opt_R || $opt_s || $opt_team ||
}
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 +1269,7 @@ if (($opt_i || $opt_n || $opt_bn || $opt_qa || $opt_R || $opt_s || $opt_team ||
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 +1328,11 @@ if (($opt_r || $opt_a || $merge) && ! $opt_create) {
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}";
}
}
}
diff --git a/test/test_debchange b/test/test_debchange
index 30280ca..03e496d 100755
--- a/test/test_debchange
+++ b/test/test_debchange
@@ -1,6 +1,7 @@
#!/bin/bash
# Copyright (C) 2012, Benjamin Drung <bdrung at debian.org>
+# © 2017 Mattia Rizzolo <mattia at debian.org>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
@@ -196,4 +197,25 @@ testEmptyMessage() {
verifyEntryLines "--team ''"
}
+verifyGuessedDistribution() {
+ # $1 → initial suite
+ # $2 → action
+ # $3 → expected suite after the action
+ rm -f "$CHANGELOG"
+ success "--create -D $1 --package test-package -v 1.0-1 'First upload'"
+ success "$2 'Second Upload'"
+ success "-r ''"
+ local dist="$(dpkg-parsechangelog -l"$CHANGELOG" -SDistribution)"
+ assertEquals "$3" "$dist"
+}
+
+testGuessedDistribution() {
+ verifyGuessedDistribution unstable -i unstable
+ verifyGuessedDistribution experimental -i experimental
+ verifyGuessedDistribution jessie-backports -i jessie-backports
+ verifyGuessedDistribution jessie -i jessie
+ verifyGuessedDistribution unstable --bpo stretch-backports
+ verifyGuessedDistribution unstable --stable stretch
+}
+
. shunit2
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git
More information about the devscripts-devel
mailing list