summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2016-05-13 17:26:01 +0200
committerGuillem Jover <guillem@debian.org>2016-07-03 21:02:06 +0200
commit90324cfa942ba23d5d44b28b1087fbd510340502 (patch)
tree8ea6172e909f564cdab65d63ef5e50965743c3c3
parentff8c1d6aad5a8976c1f60dff6c2a7fc75f3cfe33 (diff)
downloaddpkg-90324cfa942ba23d5d44b28b1087fbd510340502.tar.gz
dpkg-source: Generate Testsuite-Triggers field from test dependencies
Sometimes autopkgtests regress due to change in a package which is only a test dependency (Depends: in debian/tests/control), not a build or binary one. It is useful to trigger a test if such a test dependency changes. Record the union of all test dependency packages in a new Testsuite-Triggers field in the .dsc, so that they will be recorded in the Sources package index. Ignore versions and flatten OR dependencies as they are not interesting for determining reverse test dependencies and should not be (ab)used for replacing debian/tests/control parsing. Closes: #779559 LP: #1491145 Based-on-patch-by: Martin Pitt <martin.pitt@ubuntu.com> Signed-off-by: Guillem Jover <guillem@debian.org>
-rw-r--r--debian/changelog3
-rw-r--r--scripts/Dpkg/Control/FieldsCore.pm8
-rwxr-xr-xscripts/dpkg-source.pl31
3 files changed, 40 insertions, 2 deletions
diff --git a/debian/changelog b/debian/changelog
index 1d1e33410..63de0d337 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,9 @@ dpkg (1.18.8) UNRELEASED; urgency=medium
under either the dpkg system or user configuration directories.
Closes: #539692, #765494
* Check that debian/tests/control is a regular file before parsing it.
+ * Generate Testsuite-Triggers field from test dependencies in dpkg-source
+ into .dsc files. Based on a patch by Martin Pitt <martin.pitt@ubuntu.com>.
+ Closes: #779559
* Perl modules:
- Use warnings::warnif() instead of carp() for deprecated warnings.
- Add new format_range() method and deprecate dpkg() and rfc822() methods
diff --git a/scripts/Dpkg/Control/FieldsCore.pm b/scripts/Dpkg/Control/FieldsCore.pm
index 0c7ce4b1f..e3b43648d 100644
--- a/scripts/Dpkg/Control/FieldsCore.pm
+++ b/scripts/Dpkg/Control/FieldsCore.pm
@@ -354,6 +354,10 @@ our %FIELDS = (
allowed => ALL_SRC,
separator => FIELD_SEP_COMMA,
},
+ 'Testsuite-Triggers' => {
+ allowed => ALL_SRC,
+ separator => FIELD_SEP_COMMA,
+ },
'Timestamp' => {
allowed => CTRL_CHANGELOG,
},
@@ -439,8 +443,8 @@ our %FIELD_ORDER = (
qw(Format Source Binary Architecture Version Origin Maintainer
Uploaders Homepage Standards-Version Vcs-Browser
Vcs-Arch Vcs-Bzr Vcs-Cvs Vcs-Darcs Vcs-Git Vcs-Hg Vcs-Mtn
- Vcs-Svn Testsuite), &field_list_src_dep(), qw(Package-List),
- @checksum_fields, qw(Files)
+ Vcs-Svn Testsuite Testsuite-Triggers), &field_list_src_dep(),
+ qw(Package-List), @checksum_fields, qw(Files)
],
CTRL_FILE_CHANGES() => [
qw(Format Date Source Binary Binary-Only Built-For-Profiles Architecture
diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl
index 7d71e05e1..50885bb87 100755
--- a/scripts/dpkg-source.pl
+++ b/scripts/dpkg-source.pl
@@ -41,7 +41,9 @@ use Dpkg::Deps;
use Dpkg::Compression;
use Dpkg::Conf;
use Dpkg::Control::Info;
+use Dpkg::Control::Tests;
use Dpkg::Control::Fields;
+use Dpkg::Index;
use Dpkg::Substvars;
use Dpkg::Version;
use Dpkg::Vars;
@@ -359,6 +361,7 @@ if ($options{opmode} =~ /^(build|print-format|(before|after)-build|commit)$/) {
# Check if we have a testsuite, and handle manual and automatic values.
set_testsuite_field($fields);
+ set_testsuite_triggers_field($fields, @binarypackages);
# Scan fields of dpkg-parsechangelog
foreach (keys %{$changelog}) {
@@ -515,6 +518,34 @@ sub set_testsuite_field
$fields->{'Testsuite'} = join ', ', sort keys %testsuite;
}
+sub set_testsuite_triggers_field
+{
+ my ($fields, @binarypackages) = @_;
+ my %testdeps;
+
+ # Never overwrite a manually defined field.
+ return if $fields->{'Testsuite-Triggers'};
+
+ # We only support autopkgtests.
+ return unless -e "$dir/debian/tests/control";
+
+ my $tests = Dpkg::Control::Tests->new();
+ $tests->load("$dir/debian/tests/control");
+
+ foreach my $test ($tests->get()) {
+ next unless $test->{Depends};
+
+ my $deps = deps_parse($test->{Depends}, use_arch => 0, tests_dep => 1);
+ deps_iterate($deps, sub { $testdeps{$_[0]->{package}} = 1 });
+ }
+
+ # Remove our own binaries and meta-depends.
+ foreach my $pkg (@binarypackages, qw(@ @builddeps@)) {
+ delete $testdeps{$pkg};
+ }
+ $fields->{'Testsuite-Triggers'} = join ', ', sort keys %testdeps;
+}
+
sub setopmode {
my $opmode = shift;