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

dpkg-genchanges: some code refactoring to simplify the code

* scripts/dpkg-genchanges.pl: Some code refactoring. Also fix the
generation of the Description field to not have duplicate description
in case of udeb (a single description per binary package is enough).
Raphael Hertzog лет назад: 18
Родитель
Сommit
73ef29c8e8
3 измененных файлов с 52 добавлено и 46 удалено
  1. 7 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 42 46
      scripts/dpkg-genchanges.pl

+ 7 - 0
ChangeLog

@@ -12,6 +12,13 @@
 	include the original tarball only if the current upstream version differs
 	from the upstream version of the previous changelog entry.
 
+	* scripts/dpkg-genchanges.pl: Some code refactoring. Also fix the
+	generation of the Description field to not have duplicate description
+	in case of udeb (a single description per binary package is enough).
+	Source only uploads will loose their Description: fields since they
+	have no associated binary packages and Descriptions are only added
+	for binary packages where we have a corresponding .deb to upload.
+
 2008-01-18  Guillem Jover  <guillem@debian.org>
 
 	* m4/arch.m4 (_DPKG_ARCHITECTURE): Do not use backticks inside double

+ 3 - 0
debian/changelog

@@ -58,6 +58,9 @@ dpkg (1.14.16) UNRELEASED; urgency=low
     tarball only if the current upstream version differs from the upstream
     version of the previous changelog entry. Replaces the heuristic based
     on revision number (-0, -0.1 or -1). Closes: #28701
+  * Some code refactoring on dpkg-genchanges and bug fixes in the generation
+    of the Description: field. As a result, source only uploads will no more
+    have Description fields.
 
   [ Updated manpages translations ]
   * Fix typo in French. Closes: #460021

+ 42 - 46
scripts/dpkg-genchanges.pl

@@ -259,58 +259,54 @@ foreach $_ (keys %{$src_fields}) {
     }
 }
 
-# Scan control info of all binary packages
-foreach my $pkg ($control->get_packages()) {
+# Scan control info of all binary packages unless
+# we have a source only upload
+my @pkg;
+push @pkg, $control->get_packages() unless is_sourceonly;
+foreach my $pkg (@pkg) {
     my $p = $pkg->{"Package"};
     my $a = $pkg->{"Architecture"};
+
+    if (not defined($p2f{$p})) {
+	# No files for this package... warn if it's unexpected
+	if ((debarch_eq('all', $a) and ($include & ARCH_INDEP)) ||
+	    (grep(debarch_is($host_arch, $_), split(/\s+/, $a))
+		  and ($include & ARCH_DEP))) {
+	    warning(_g("package %s in control file but not in files list"),
+		    $p);
+	}
+	next; # and skip it
+    }
+
+    my @f = @{$p2f{$p}}; # List of files for this binary package
+    $p2arch{$p} = $a;
+
     foreach $_ (keys %{$pkg}) {
 	my $v = $pkg->{$_};
-	if (!defined($p2f{$p}) && not is_sourceonly) {
-	    if ((debarch_eq('all', $a) and ($include & ARCH_INDEP)) ||
-		(grep(debarch_is($host_arch, $_), split(/\s+/, $a))
-		      and ($include & ARCH_DEP))) {
-		warning(_g("package %s in control file but not in files list"),
-		        $p);
-		next;
+
+	if (m/^Description$/) {
+	    $v = $1 if $v =~ m/^(.*)\n/;
+	    my $desc = sprintf("%-10s - %-.65s", $p, $v);
+	    $desc .= " (udeb)" if (grep(/\.udeb$/, @f));
+	    push @descriptions, $desc;
+	} elsif (m/^Section$/) {
+	    $f2seccf{$_} = $v foreach (@f);
+	} elsif (m/^Priority$/) {
+	    $f2pricf{$_} = $v foreach (@f);
+	} elsif (s/^X[BS]*C[BS]*-//i) { # Include XC-* fields
+	    $fields->{$_} = $v;
+	} elsif (m/^Architecture$/) {
+	    if (grep(debarch_is($host_arch, $_), split(/\s+/, $v))
+		and ($include & ARCH_DEP)) {
+		$v = $host_arch;
+	    } elsif (!debarch_eq('all', $v)) {
+		$v = '';
 	    }
+	    push(@archvalues,$v) unless !$v || $archadded{$v}++;
+	} elsif (m/^$control_pkg_field_regex$/ || m/^X[BS]+-/i) {
+	    # Silently ignore valid fields
 	} else {
-	    my @f;
-	    @f = @{$p2f{$p}} if defined($p2f{$p});
-	    $p2arch{$p}=$a;
-
-	    if (m/^Description$/) {
-		$v=$PREMATCH if $v =~ m/\n/;
-		my %d;
-		# dummy file to get each description at least once (e.g. -S)
-		foreach my $f (("", @f)) {
-		    my $desc = sprintf("%-10s - %-.65s%s", $p, $v,
-				       $f =~ m/\.udeb$/ ? " (udeb)" : '');
-		    $d{$desc}++;
-		}
-		push @descriptions, keys %d;
-	    } elsif (m/^Section$/) {
-		$f2seccf{$_} = $v foreach (@f);
-	    } elsif (m/^Priority$/) {
-		$f2pricf{$_} = $v foreach (@f);
-	    } elsif (s/^X[BS]*C[BS]*-//i) { # Include XC-* fields
-		$fields->{$_} = $v;
-	    } elsif (m/^Architecture$/) {
-		if (not is_sourceonly) {
-		    if (grep(debarch_is($host_arch, $_), split(/\s+/, $v))
-			and ($include & ARCH_DEP)) {
-			$v = $host_arch;
-		    } elsif (!debarch_eq('all', $v)) {
-			$v = '';
-		    }
-		} else {
-		    $v = '';
-		}
-		push(@archvalues,$v) unless !$v || $archadded{$v}++;
-	    } elsif (m/^$control_pkg_field_regex$/ || m/^X[BS]+-/i) {
-		# Silently ignore valid fields
-	    } else {
-		unknown(_g("package's section of control info file"));
-	    }
+	    unknown(_g("package's section of control info file"));
 	}
     }
 }