소스 검색

dpkg-source: add some supplementary checks of debian/control

We're now ensuring that debian/control contains a source entry
and at least one entry for a binary package. And we also ensure
that the Architecture field is present. This a new restriction
but it's really in-line with the change made in dpkg where we
complain of the lack of this field.

Reported-by: Niels Thykier <niels@thykier.net>
Raphaël Hertzog 15 년 전
부모
커밋
1c1653ef4d
5개의 변경된 파일19개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 0
      debian/changelog
  2. 5 1
      scripts/Dpkg/Control/Info.pm
  3. 5 0
      scripts/dpkg-source.pl
  4. 4 0
      scripts/t/700_Dpkg_Control.t
  5. 3 0
      scripts/t/700_Dpkg_Control/control-1

+ 2 - 0
debian/changelog

@@ -42,6 +42,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
     LP: #798793, #424358 Closes: #560251
   * Use "special" instead of "particular" to qualify the "3.0 (custom)" format
     in dpkg-source(1). Closes: #631435
+  * Add some supplementary checks to ensure debian/control has the required
+    fields. Closes: #631439
 
   [ Guillem Jover ]
   * Install deb-src-control(5) man pages in dpkg-dev. Closes: #620520

+ 5 - 1
scripts/Dpkg/Control/Info.pm

@@ -107,8 +107,12 @@ sub parse {
         last if not $cdata->parse($fh, $desc);
 	push @{$self->{packages}}, $cdata;
 	unless (exists $cdata->{Package}) {
-	    syntaxerr($desc, _g("block lacks a package field"));
+	    syntaxerr($desc, _g("block lacks the '%s' field"), "Package");
 	}
+	unless (exists $cdata->{Architecture}) {
+	    syntaxerr($desc, _g("block lacks the '%s' field"), "Architecture");
+	}
+
     }
 }
 

+ 5 - 0
scripts/dpkg-source.pl

@@ -223,6 +223,8 @@ if ($options{'opmode'} =~ /^(-b|--print-format|--(before|after)-build)$/) {
 
     # Scan control info of source package
     my $src_fields = $control->get_source();
+    error(_g("%s doesn't contain any information about the source package"),
+          $controlfile) unless defined $src_fields;
     my $src_sect = $src_fields->{'Section'} || "unknown";
     my $src_prio = $src_fields->{'Priority'} || "unknown";
     foreach $_ (keys %{$src_fields}) {
@@ -283,6 +285,9 @@ if ($options{'opmode'} =~ /^(-b|--print-format|--(before|after)-build)$/) {
             }
 	}
     }
+    unless (scalar(@pkglist)) {
+	error(_g("%s doesn't list any binary package"), $controlfile);
+    }
     if (grep($_ eq 'any', @sourcearch)) {
         # If we encounter one 'any' then the other arches become insignificant
         # except for 'all' that must also be kept

+ 4 - 0
scripts/t/700_Dpkg_Control.t

@@ -41,12 +41,15 @@ Long-Field: line1
 Empty-Field: 
 
 Package: mypackage1
+Architecture: any
 Depends: libc6
 
 Package: mypackage2
+Architecture: all
 Depends: hello
 
 Package: mypackage3
+Architecture: all
 Depends: hello
 Description: short one
  long one
@@ -80,5 +83,6 @@ $pkg->output($io);
 
 is(${$io->string_ref()},
 'Package: mypackage2
+Architecture: all
 Depends: hello
 ', "Dump of second binary package of $datadir/control-1");

+ 3 - 0
scripts/t/700_Dpkg_Control/control-1

@@ -12,13 +12,16 @@ empty-field:
      
 # First package
 Package: mypackage1
+Architecture: any
 Depends: libc6
 
 # Second package
 Package: mypackage2
+Architecture: all
 Depends: hello
 
 Package: mypackage3
+Architecture: all
 Depends:hello
 Description:   short one
  long one