Message ID | 1506543829-11565-1-git-send-email-marcelo.cerri@canonical.com |
---|---|
State | New |
Headers | show |
Series | [T/X/Z/A,v2] UBUNTU: d/s/m/insert-ubuntu-changes: use full version numbers | expand |
On 27.09.2017 16:23, Marcelo Henrique Cerri wrote: > Ignore: yes > > Make insert-ubuntu-changes to consider full version numbers when looping > through debian.master/changelog entries and comparing the version number > of each entry with the arguments passed to the script to decide which > entries should be included in the output changelog file. > > Previously, only the last number in the version was used in this > comparison. For example, when comparing 4.4.0-50.51 and 4.4.0-83.84 only > the numbers 51 and 84 were actually used in the comparison. That however > might not work properly when the major version is bumped. > > For instance, using "end" as 4.4.0-50.51 and "start" as 4.4.0-83.84 used > to work fine because 84 is greater than 51. However when using "end" > as 4.11.0-10.11 and "start" as 4.13.0-2.3, no entry was being selected > since 3 is not greater than 11. > > Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com> Acked-by: Stefan Bader <stefan.bader@canonical.com> > --- > debian/scripts/misc/insert-ubuntu-changes | 32 ++++++++++++++++++++++++++----- > 1 file changed, 27 insertions(+), 5 deletions(-) > > diff --git a/debian/scripts/misc/insert-ubuntu-changes b/debian/scripts/misc/insert-ubuntu-changes > index 9ede7f3950d7..7af9c20c1215 100755 > --- a/debian/scripts/misc/insert-ubuntu-changes > +++ b/debian/scripts/misc/insert-ubuntu-changes > @@ -5,8 +5,30 @@ if ($#ARGV != 2) { > } > my ($changelog, $end, $start) = @ARGV; > > -$end =~ s/.*\.//; > -$start =~ s/.*\.//; > +$end =~ s/^\D+//; > +$start =~ s/^\D+//; > + > +sub version_cmp($$) { > + my @a = split(/[\.-]+/, $_[0]); > + my @b = split(/[\.-]+/, $_[1]); > + for (my $i = 1;; $i++) { > + if (!defined $a[$i]) { > + if (!defined $b[$i]) { > + return 0; > + } > + return -1; > + } > + if (!defined $b[$i]) { > + return 1; > + } > + if ($a[$i] < $b[$i]) { > + return -1; > + } > + if ($a[$i] > $b[$i]) { > + return 1; > + } > + } > +} > > my @changes = (); > my $output = 0; > @@ -14,11 +36,11 @@ open(CHG, "<debian.master/changelog") || > open(CHG, "<debian/changelog") || > die "$0: debian/changelog: open failed - $!\n"; > while (<CHG>) { > - if (/^\S+\s+\((.*\.(\d+))\)/) { > - if ($2 <= $end) { > + if (/^\S+\s+\((.*)\)/) { > + if (version_cmp($1, $end) <= -1) { > last; > } > - if ($2 == $start) { > + if ($1 eq $start) { > $output = 1; > } > if ($output) { >
On Wed, Sep 27, 2017 at 05:23:49PM -0300, Marcelo Henrique Cerri wrote: > Ignore: yes > > Make insert-ubuntu-changes to consider full version numbers when looping > through debian.master/changelog entries and comparing the version number > of each entry with the arguments passed to the script to decide which > entries should be included in the output changelog file. > > Previously, only the last number in the version was used in this > comparison. For example, when comparing 4.4.0-50.51 and 4.4.0-83.84 only > the numbers 51 and 84 were actually used in the comparison. That however > might not work properly when the major version is bumped. > > For instance, using "end" as 4.4.0-50.51 and "start" as 4.4.0-83.84 used > to work fine because 84 is greater than 51. However when using "end" > as 4.11.0-10.11 and "start" as 4.13.0-2.3, no entry was being selected > since 3 is not greater than 11. > > Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com> Applied to artful/master-next and unstable/master, thanks.
Applied to trusty, xenial and zesty master-next branches. Thanks. Cascardo. Applied-to: trusty/master-next Applied-to: xenial/master-next Applied-to: zesty/master-next
diff --git a/debian/scripts/misc/insert-ubuntu-changes b/debian/scripts/misc/insert-ubuntu-changes index 9ede7f3950d7..7af9c20c1215 100755 --- a/debian/scripts/misc/insert-ubuntu-changes +++ b/debian/scripts/misc/insert-ubuntu-changes @@ -5,8 +5,30 @@ if ($#ARGV != 2) { } my ($changelog, $end, $start) = @ARGV; -$end =~ s/.*\.//; -$start =~ s/.*\.//; +$end =~ s/^\D+//; +$start =~ s/^\D+//; + +sub version_cmp($$) { + my @a = split(/[\.-]+/, $_[0]); + my @b = split(/[\.-]+/, $_[1]); + for (my $i = 1;; $i++) { + if (!defined $a[$i]) { + if (!defined $b[$i]) { + return 0; + } + return -1; + } + if (!defined $b[$i]) { + return 1; + } + if ($a[$i] < $b[$i]) { + return -1; + } + if ($a[$i] > $b[$i]) { + return 1; + } + } +} my @changes = (); my $output = 0; @@ -14,11 +36,11 @@ open(CHG, "<debian.master/changelog") || open(CHG, "<debian/changelog") || die "$0: debian/changelog: open failed - $!\n"; while (<CHG>) { - if (/^\S+\s+\((.*\.(\d+))\)/) { - if ($2 <= $end) { + if (/^\S+\s+\((.*)\)/) { + if (version_cmp($1, $end) <= -1) { last; } - if ($2 == $start) { + if ($1 eq $start) { $output = 1; } if ($output) {
Ignore: yes Make insert-ubuntu-changes to consider full version numbers when looping through debian.master/changelog entries and comparing the version number of each entry with the arguments passed to the script to decide which entries should be included in the output changelog file. Previously, only the last number in the version was used in this comparison. For example, when comparing 4.4.0-50.51 and 4.4.0-83.84 only the numbers 51 and 84 were actually used in the comparison. That however might not work properly when the major version is bumped. For instance, using "end" as 4.4.0-50.51 and "start" as 4.4.0-83.84 used to work fine because 84 is greater than 51. However when using "end" as 4.11.0-10.11 and "start" as 4.13.0-2.3, no entry was being selected since 3 is not greater than 11. Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com> --- debian/scripts/misc/insert-ubuntu-changes | 32 ++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-)