Package: dpkg
Version: 1.15.7.2
Severity: wishlist
Tags: patch
User: [email protected]
Usertags: origin-ubuntu ubuntu-patch maverick
Ubuntu's changelog parsing is nearly identical to Debian's, but may emit
an additional Launchpad-Bugs-Fixed header. Test that changelogs
matching the appropriate regex are parsed correctly both for Debian and
Ubuntu.
To do this, we take copies of the standard origin files and add an
internal mechanism allowing Dpkg::Vendor to be pointed at them; and we
run 600_Dpkg_Changelog.t a second time with DEB_VENDOR set, to avoid
duplicating lots of code. See the discussion in #536066 for background.
---
scripts/Dpkg/Vendor.pm | 5 ++++-
scripts/Makefile.am | 2 ++
scripts/t/600_Dpkg_Changelog.t | 18 +++++++++++++++---
scripts/t/600_Dpkg_Changelog/fields | 2 ++
scripts/t/600_Dpkg_Changelog_Ubuntu.t | 21 +++++++++++++++++++++
scripts/t/origins/debian | 3 +++
scripts/t/origins/default | 1 +
scripts/t/origins/ubuntu | 4 ++++
8 files changed, 52 insertions(+), 4 deletions(-)
create mode 100644 scripts/t/600_Dpkg_Changelog_Ubuntu.t
create mode 100644 scripts/t/origins/debian
create mode 120000 scripts/t/origins/default
create mode 100644 scripts/t/origins/ubuntu
diff --git a/scripts/Dpkg/Vendor.pm b/scripts/Dpkg/Vendor.pm
index fb1d34f..c487913 100644
--- a/scripts/Dpkg/Vendor.pm
+++ b/scripts/Dpkg/Vendor.pm
@@ -28,6 +28,9 @@ use base qw(Exporter);
our @EXPORT_OK = qw(get_vendor_info get_current_vendor get_vendor_file
get_vendor_object run_vendor_hook);
+my $origins = "/etc/dpkg/origins";
+$origins = $ENV{DPKG_TEST_ORIGINS} if $ENV{DPKG_TEST_ORIGINS};
+
=encoding utf8
=head1 NAME
@@ -84,7 +87,7 @@ sub get_vendor_file(;$) {
push @tries, $vendor, lc($vendor), ucfirst($vendor),
ucfirst(lc($vendor));
}
foreach my $name (@tries) {
- $file = "/etc/dpkg/origins/$name" if -e "/etc/dpkg/origins/$name";
+ $file = "$origins/$name" if -e "$origins/$name";
}
return $file;
}
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 2f05232..ed859b0 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -186,6 +186,7 @@ test_cases = \
t/400_Dpkg_Deps.t \
t/500_Dpkg_Path.t \
t/600_Dpkg_Changelog.t \
+ t/600_Dpkg_Changelog_Ubuntu.t \
t/700_Dpkg_Control.t \
t/750_Dpkg_Substvars.t \
t/800_Dpkg_IPC.t \
@@ -243,6 +244,7 @@ check: $(test_data) $(test_cases)
$(mkdir_p) $(test_tmpdir)
PATH="$(top_builddir)/src:$(top_builddir)/scripts:$(PATH)" \
srcdir=$(srcdir) DPKG_DATADIR=$(srcdir)/.. \
+ DPKG_TEST_ORIGINS=$(srcdir)/t/origins \
PERL5LIB=$(srcdir) PERL_DL_NONLAZY=1 \
$(PERL) -I$(srcdir) -MExtUtils::Command::MM \
-e "test_harness($(TEST_VERBOSE), '.')" \
diff --git a/scripts/t/600_Dpkg_Changelog.t b/scripts/t/600_Dpkg_Changelog.t
index 61281d0..5d3d531 100644
--- a/scripts/t/600_Dpkg_Changelog.t
+++ b/scripts/t/600_Dpkg_Changelog.t
@@ -25,7 +25,7 @@ BEGIN {
+ $no_err_examples * 2
+ 26 # countme
+ 13 # fields
- + 21;
+ + 22;
require Test::More;
import Test::More tests => $no_tests;
@@ -33,11 +33,14 @@ BEGIN {
BEGIN {
use_ok('Dpkg::Changelog');
use_ok('Dpkg::Changelog::Debian');
+ use_ok('Dpkg::Vendor', qw(get_current_vendor));
};
my $srcdir = $ENV{srcdir} || '.';
my $datadir = $srcdir . '/t/600_Dpkg_Changelog';
+my $vendor = get_current_vendor();
+
#########################
foreach my $file ("$datadir/countme", "$datadir/shadow", "$datadir/fields",
@@ -181,11 +184,13 @@ Changes:
fields (2.0-0etch1) stable; urgency=low
.
* Upload to stable (Closes: #1111111, #2222222)
+ * Fix more stuff. (LP: #54321, #2424242)
.
fields (2.0-1) unstable frozen; urgency=medium
.
[ Frank Lichtenheld ]
* Upload to unstable (Closes: #1111111, #2222222)
+ * Fix stuff. (LP: #12345, #424242)
.
[ Raphaël Hertzog ]
* New upstream release.
@@ -203,6 +208,9 @@ Changes:
Xb-Userfield2: foobar
Xc-Userfield: foobar
';
+ if ($vendor eq 'Ubuntu') {
+ $expected =~ s/^(Closes:.*)/$1\nLaunchpad-Bugs-Fixed: 12345 54321
424242 2424242/m;
+ }
cmp_ok($str,'eq',$expected,"fields handling");
$str = $changes->dpkg({ offset => 1, count => 2 });
@@ -218,6 +226,7 @@ Changes:
.
[ Frank Lichtenheld ]
* Upload to unstable (Closes: #1111111, #2222222)
+ * Fix stuff. (LP: #12345, #424242)
.
[ Raphaël Hertzog ]
* New upstream release.
@@ -230,6 +239,9 @@ Changes:
* Beta
Xc-Userfield: foobar
';
+ if ($vendor eq 'Ubuntu') {
+ $expected =~ s/^(Closes:.*)/$1\nLaunchpad-Bugs-Fixed: 12345
424242/m;
+ }
cmp_ok($str,'eq',$expected,"fields handling 2");
$str = $changes->rfc822({ offset => 2, count => 2 });
@@ -276,11 +288,11 @@ Xb-Userfield2: foobar
"get_timestamp");
my @items = $data[1]->get_change_items();
is($items[0], " [ Frank Lichtenheld ]\n", "change items 1");
- is($items[3], " * New upstream release.
+ is($items[4], " * New upstream release.
- implements a
- implements b
", "change items 2");
- is($items[4], " * Update S-V.\n", "change items 3");
+ is($items[5], " * Update S-V.\n", "change items 3");
}
SKIP: {
diff --git a/scripts/t/600_Dpkg_Changelog/fields
b/scripts/t/600_Dpkg_Changelog/fields
index 9530b88..df4638f 100644
--- a/scripts/t/600_Dpkg_Changelog/fields
+++ b/scripts/t/600_Dpkg_Changelog/fields
@@ -1,6 +1,7 @@
fields (2.0-0etch1) stable; urgency=low
* Upload to stable (Closes: #1111111, #2222222)
+ * Fix more stuff. (LP: #54321, #2424242)
-- Frank Lichtenheld <[email protected]> Sun, 13 Jan 2008 15:49:19 +0100
@@ -8,6 +9,7 @@ fields (2.0-1) unstable frozen; urgency=medium
[ Frank Lichtenheld ]
* Upload to unstable (Closes: #1111111, #2222222)
+ * Fix stuff. (LP: #12345, #424242)
[ Raphaël Hertzog ]
* New upstream release.
diff --git a/scripts/t/600_Dpkg_Changelog_Ubuntu.t
b/scripts/t/600_Dpkg_Changelog_Ubuntu.t
new file mode 100644
index 0000000..1034c2e
--- /dev/null
+++ b/scripts/t/600_Dpkg_Changelog_Ubuntu.t
@@ -0,0 +1,21 @@
+# -*- perl -*-
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+use warnings;
+
+$ENV{DEB_VENDOR} = 'Ubuntu';
+my $srcdir = $ENV{srcdir} || '.';
+do "$srcdir/t/600_Dpkg_Changelog.t";
diff --git a/scripts/t/origins/debian b/scripts/t/origins/debian
new file mode 100644
index 0000000..91f6ed1
--- /dev/null
+++ b/scripts/t/origins/debian
@@ -0,0 +1,3 @@
+Vendor: Debian
+Vendor-URL: http://www.debian.org/
+Bugs: debbugs://bugs.debian.org
diff --git a/scripts/t/origins/default b/scripts/t/origins/default
new file mode 120000
index 0000000..b2f7fd3
--- /dev/null
+++ b/scripts/t/origins/default
@@ -0,0 +1 @@
+debian
\ No newline at end of file
diff --git a/scripts/t/origins/ubuntu b/scripts/t/origins/ubuntu
new file mode 100644
index 0000000..7cc3ce2
--- /dev/null
+++ b/scripts/t/origins/ubuntu
@@ -0,0 +1,4 @@
+Vendor: Ubuntu
+Vendor-URL: http://www.ubuntu.com/
+Bugs: https://bugs.launchpad.net/ubuntu/+filebug
+Parent: Debian
--
1.7.1
--
Colin Watson [[email protected]]
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]