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

scripts: Improve error messages when debian/control has no package stanza

dpkg-gencontrol and dpkg-gensymbols now give a descriptive error message
when no binary package stanza is found in debian/control.

Closes: #642473

Based-on-patch-by: Kyle Willmon <kylewillmon@gmail.com>
Signed-off-by: Guillem Jover <guillem@debian.org>
Guillem Jover лет назад: 14
Родитель
Сommit
e255fe0c79
3 измененных файлов с 11 добавлено и 2 удалено
  1. 3 0
      debian/changelog
  2. 4 1
      scripts/dpkg-gencontrol.pl
  3. 4 1
      scripts/dpkg-gensymbols.pl

+ 3 - 0
debian/changelog

@@ -19,6 +19,9 @@ dpkg (1.16.2) UNRELEASED; urgency=low
       the host architecture, for which dpkg itself is not required.
       the host architecture, for which dpkg itself is not required.
     - Reduces the amount of work performed, including loading and parsing
     - Reduces the amount of work performed, including loading and parsing
       unnecessary table files or calling either of gcc or dpkg programs.
       unnecessary table files or calling either of gcc or dpkg programs.
+  * Improve error message in dpkg-gencontrol and dpkg-gensymbols when
+    debian/control does not have any package stanza. Closes: #642473
+    Based on a patch by Kyle Willmon <kylewillmon@gmail.com>.
 
 
   [ Updated dpkg translations ]
   [ Updated dpkg translations ]
   * Italian (Milo Casagrande). Closes: #627832
   * Italian (Milo Casagrande). Closes: #627832

+ 4 - 1
scripts/dpkg-gencontrol.pl

@@ -152,9 +152,12 @@ if (defined($oppackage)) {
     defined($pkg) || error(_g("package %s not in control info"), $oppackage);
     defined($pkg) || error(_g("package %s not in control info"), $oppackage);
 } else {
 } else {
     my @packages = map { $_->{'Package'} } $control->get_packages();
     my @packages = map { $_->{'Package'} } $control->get_packages();
-    @packages==1 ||
+    if (@packages == 0) {
+        error(_g("no package stanza found in control info"));
+    } elsif (@packages > 1) {
         error(_g("must specify package since control info has many (%s)"),
         error(_g("must specify package since control info has many (%s)"),
               "@packages");
               "@packages");
+    }
     $pkg = $control->get_pkg_by_idx(1);
     $pkg = $control->get_pkg_by_idx(1);
 }
 }
 $substvars->set_msg_prefix(sprintf(_g("package %s: "), $pkg->{Package}));
 $substvars->set_msg_prefix(sprintf(_g("package %s: "), $pkg->{Package}));

+ 4 - 1
scripts/dpkg-gensymbols.pl

@@ -155,9 +155,12 @@ if (not defined($sourceversion)) {
 if (not defined($oppackage)) {
 if (not defined($oppackage)) {
     my $control = Dpkg::Control::Info->new();
     my $control = Dpkg::Control::Info->new();
     my @packages = map { $_->{'Package'} } $control->get_packages();
     my @packages = map { $_->{'Package'} } $control->get_packages();
-    @packages == 1 ||
+    if (@packages == 0) {
+	error(_g("no package stanza found in control info"));
+    } elsif (@packages > 1) {
 	error(_g("must specify package since control info has many (%s)"),
 	error(_g("must specify package since control info has many (%s)"),
 	      "@packages");
 	      "@packages");
+    }
     $oppackage = $packages[0];
     $oppackage = $packages[0];
 }
 }