From: Raphael Hertzog Date: Mon, 14 Apr 2008 19:31:52 +0000 (+0200) Subject: dpkg-genchanges: use Package-Type control field to detect udebs X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43cfe89b684b4a51d0bc8c25f62949dbad1c8e43;p=dpkg dpkg-genchanges: use Package-Type control field to detect udebs * scripts/Dpkg/Fields.pm (find_custom_field, get_custom_field): New function to handle custom fields (X[SBC]*-*). * scripts/dpkg-genchanges.pl: Use Package-Type control field to decide if a package is an udeb instead of relying on the file extension of a generated package since that doesn't work when generating source-only uploads for example. --- diff --git a/ChangeLog b/ChangeLog index 1ad0cafc..08c89e7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-04-14 Raphael Hertzog + + * scripts/Dpkg/Fields.pm (find_custom_field, get_custom_field): + New function to handle custom fields (X[SBC]*-*). + * scripts/dpkg-genchanges.pl: Use Package-Type control field to + decide if a package is an udeb instead of relying on the file + extension of a generated package since that doesn't work when + generating source-only uploads for example. + 2008-04-14 Raphael Hertzog * scripts/Dpkg/Source/Patch.pm (_fail_not_same_type): Fix diff --git a/debian/changelog b/debian/changelog index c9b72933..686c20e9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,9 @@ dpkg (1.14.19) UNRELEASED; urgency=low original tarball in the current extraction directory. Closes: #475668 * Fix the dpkg-source error message about unrepresentable changes to source because the type of a file changed (new and old were inverted). + * Fix dpkg-genchanges to detect udeb based on Package-Type control + header instead of file extension analysis on uploaded files. + Closes: #476113 [ Updated dpkg translations ] * Galician (Jacobo Tarrio). diff --git a/scripts/Dpkg/Fields.pm b/scripts/Dpkg/Fields.pm index a41fab7f..6504a1fa 100644 --- a/scripts/Dpkg/Fields.pm +++ b/scripts/Dpkg/Fields.pm @@ -131,6 +131,33 @@ sub NEXTKEY { return undef; } +=head2 tied(%hash)->find_custom_field($name) + +Scan the fields and look for a user specific field whose name matches the +following regex: /X[SBC]+-$name/i. Return the name of the field found or +undef if nothing has been found. + +=cut +sub find_custom_field { + my ($self, $name) = @_; + foreach my $key (keys %{$self->[0]}) { + return $key if $key =~ /^X[SBC]*-\Q$name\E$/i; + } + return undef; +} + +=head2 tied(%hash)->get_custom_field($name) + +Identify a user field and retrieve its value. + +=cut +sub get_custom_field { + my ($self, $name) = @_; + my $key = $self->find_custom_field($name); + return $self->[0]->{$key} if defined $key; + return undef; +} + =head2 my $str = tied(%hash)->dump() =head2 tied(%hash)->dump($fh) diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index c886cd3d..a59918f5 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -276,13 +276,15 @@ foreach my $pkg ($control->get_packages()) { my $a = $pkg->{"Architecture"}; my $d = $pkg->{"Description"} || "no description available"; $d = $1 if $d =~ /^(.*)\n/; + my $pkg_type = $pkg->{"Package-Type"} || + tied(%$pkg)->get_custom_field("Package-Type") || "deb"; my @f; # List of files for this binary package push @f, @{$p2f{$p}} if defined $p2f{$p}; # Add description of all binary packages my $desc = sprintf("%-10s - %-.65s", $p, $d); - $desc .= " (udeb)" if (grep(/\.udeb$/, @f)); # XXX: Check Package-Type field instead + $desc .= " (udeb)" if $pkg_type eq "udeb"; push @descriptions, $desc; if (not defined($p2f{$p})) {