Просмотр исходного кода

dpkg-source: Automatically add the Testsuite field

This is a comma-separated field. The only currently known value for the
field is autopkgtest, which requires the debian/tests/control file to
be present, even if empty, otherwise it is a deb822-style file.

Existing and unknown values will be preserved, and autopkgtest will be
appended. If the autopkgtest value is present but there is no
debian/tests/control file, then the value will be removed and a warning
emitted.
Guillem Jover лет назад: 12
Родитель
Сommit
db3c4abdd2
2 измененных файлов с 20 добавлено и 0 удалено
  1. 1 0
      debian/changelog
  2. 19 0
      scripts/dpkg-source.pl

+ 1 - 0
debian/changelog

@@ -43,6 +43,7 @@ dpkg (1.17.11) UNRELEASED; urgency=low
     performed on the input, and gets reflected on the output.
   * Add new dpkg-query virtual fields db:Status-Want, db:Status-Status and
     db:Status-Eflag to allow fine-grained access to the Status values.
+  * Automatically add the Testsuite field in dpkg-source to the .dsc file.
 
   [ Updated programs translations ]
   * Danish (Joe Dalton). Closes: #754127

+ 19 - 0
scripts/dpkg-source.pl

@@ -330,6 +330,9 @@ if ($options{opmode} =~ /^(-b|--print-format|--(before|after)-build|--commit)$/)
     $fields->{'Architecture'} = join(' ', @sourcearch);
     $fields->{'Package-List'} = "\n" . join("\n", sort @pkglist);
 
+    # Check if we have a testsuite, and handle manual and automatic values.
+    set_testsuite_field($fields);
+
     # Scan fields of dpkg-parsechangelog
     foreach (keys %{$changelog}) {
         my $v = $changelog->{$_};
@@ -465,6 +468,22 @@ if ($options{opmode} =~ /^(-b|--print-format|--(before|after)-build|--commit)$/)
     exit(0);
 }
 
+sub set_testsuite_field
+{
+    my ($fields) = @_;
+
+    my $testsuite_field = $fields->{'Testsuite'} // '';
+    my %testsuite = map { $_ => 1 } split /\s*,\s*/, $testsuite_field;
+    if (-e "$dir/debian/tests/control") {
+        $testsuite{autopkgtest} = 1;
+    } elsif ($testsuite{autopkgtest}) {
+        warning(_g('%s field contains value %s, but no tests control file %s'),
+                'Testsuite', 'autopkgtest', 'debian/tests/control');
+        delete $testsuite{autopkgtest};
+    }
+    $fields->{'Testsuite'} = join ', ', sort keys %testsuite;
+}
+
 sub setopmode {
     if (defined($options{opmode})) {
 	usageerr(_g('only one of -x, -b or --print-format allowed, and only once'));