From 4048f1250fcd6324541b3e316875dd194a21a5ac Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 11 Apr 2007 01:17:35 +0000 Subject: [PATCH] Reorder a bit fields in output files. --- ChangeLog | 21 +++++++++++++++++++++ debian/changelog | 1 + scripts/changelog/debian.pl | 8 +++++--- scripts/controllib.pl | 29 ++++++++++++++++++++++++++--- scripts/dpkg-genchanges.pl | 10 ++++++---- scripts/dpkg-gencontrol.pl | 12 ++++++------ scripts/dpkg-scanpackages.pl | 30 ++++++------------------------ scripts/dpkg-source.pl | 11 +++++------ 8 files changed, 76 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 298352c8..43ed64aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2007-04-11 Guillem Jover + + * scripts/controllib.pl (@pkg_dep_fields): Reorder fields by + importance. + (set_field_importance): New function. + (sort_field_by_importance): Likewise. + (outputclose): Use sort_field_by_importance instead of direct sorting. + * scripts/changelog/debian.pl (%fieldimps): Do not set directly, use + set_field_importance instead. + * scripts/dpkg-genchanges.pl: Likewise. + * scripts/dpkg-gencontrol.pl: Likewise. + * scripts/dpkg-source.pl: Likewise. + * scripts/changelog/debian.pl (@changelog_fields): New variable. + * scripts/dpkg-genchanges.pl (@changes_fields): New variable. + * scripts/dpkg-gencontrol.pl (@control_fields): New variable. + * scripts/dpkg-source.pl (@dsc_fields): New variable. + * scripts/dpkg-scanpackages.pl: Require 'controllib.pl'. + (@pkg_dep_fields): Declare as 'our'. + (@fieldpri): Reorder fields, use '@pkg_dep_fields' instead of + hardcoded list. + 2007-04-05 Guillem Jover * scripts/controllib.pl (get_host_arch): New function. diff --git a/debian/changelog b/debian/changelog index 645ed733..a5882ab0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -61,6 +61,7 @@ dpkg (1.14.0) UNRELEASED; urgency=low * Fix typo in German dpkg man page. Closes: #416167 Thanks to Martin Weis. * Properly sort Uploaders field in generated .dsc files. + * Reorder a bit fields in output files. [ Updated dpkg translations ] * Romanian (Eddy Petrișor). diff --git a/scripts/changelog/debian.pl b/scripts/changelog/debian.pl index 3443a3a4..ea343c9c 100755 --- a/scripts/changelog/debian.pl +++ b/scripts/changelog/debian.pl @@ -21,6 +21,10 @@ $progname= "parsechangelog/$progname"; $since=''; +my @changelog_fields = qw(Source Version Distribution Urgency Maintainer + Date Closes Changes)); + + sub version { printf _g("Debian %s version %s.\n"), $progname, $version; @@ -60,9 +64,6 @@ while (@ARGV) { } %mapkv=(); # for future use -$i=100;grep($fieldimps{$_}=$i--, - qw(Source Version Distribution Urgency Maintainer Date Closes - Changes)); $i=1;grep($urgencies{$_}=$i++, qw(low medium high critical emergency)); @@ -162,6 +163,7 @@ while ($f{'Changes'} =~ /closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*/i } $f{'Closes'} = join(' ',sort { $a <=> $b} @closes); +set_field_importance(@changelog_fields); outputclose(); sub clerror diff --git a/scripts/controllib.pl b/scripts/controllib.pl index fd68a5cf..c5ce7c79 100755 --- a/scripts/controllib.pl +++ b/scripts/controllib.pl @@ -20,8 +20,8 @@ textdomain("dpkg-dev"); $parsechangelog= 'dpkg-parsechangelog'; -@pkg_dep_fields = qw(Replaces Provides Depends Pre-Depends Recommends Suggests - Conflicts Enhances); +@pkg_dep_fields = qw(Pre-Depends Depends Recommends Suggests Enhances + Conflicts Replaces Provides); @src_dep_fields = qw(Build-Depends Build-Depends-Indep Build-Conflicts Build-Conflicts-Indep); @@ -170,6 +170,29 @@ sub substvars { return $v; } +sub set_field_importance(@) +{ + my @fields = @_; + my $i = 1; + + grep($fieldimps{$_} = $i++, @fields); +} + +sub sort_field_by_importance($$) +{ + my ($a, $b) = @_; + + if (defined $fieldimps{$a} && defined $fieldimps{$b}) { + $fieldimps{$a} <=> $fieldimps{$b}; + } elsif (defined($fieldimps{$a})) { + -1; + } elsif (defined($fieldimps{$b})) { + 1; + } else { + $a cmp $b; + } +} + sub outputclose { my ($varlistfile) = @_; @@ -177,7 +200,7 @@ sub outputclose { &parsesubstvars($varlistfile) if (defined($varlistfile)); - for $f (sort { $fieldimps{$b} <=> $fieldimps{$a} } keys %f) { + for $f (sort sort_field_by_importance keys %f) { $v= $f{$f}; if (defined($varlistfile)) { $v= &substvars($v); diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 32f3abc4..13ddf0c5 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -31,6 +31,11 @@ require 'controllib.pl'; require 'dpkg-gettext.pl'; textdomain("dpkg-dev"); +my @changes_fields = qw(Format Date Source Binary Architecture Version + Distribution Urgency Maintainer Changed-By + Description Closes Changes Files); + + sub version { printf _g("Debian %s version %s.\n"), $progname, $version; @@ -74,10 +79,6 @@ Options: "), $progname; } -$i=100;grep($fieldimps{$_}=$i--, - qw(Format Date Source Binary Architecture Version - Distribution Urgency Maintainer Changed-By Description - Closes Changes Files)); while (@ARGV) { $_=shift(@ARGV); @@ -384,5 +385,6 @@ for $f (qw(Urgency)) { for $f (keys %override) { $f{&capit($f)}= $override{$f}; } for $f (keys %remove) { delete $f{&capit($f)}; } +set_field_importance(@changes_fields); outputclose(); diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 14be6782..0ed7946f 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -18,6 +18,11 @@ require 'controllib.pl'; require 'dpkg-gettext.pl'; textdomain("dpkg-dev"); +my @control_fields = (qw(Package Source Version Architecture Essential Origin + Bugs Maintainer Installed-Size), @pkg_dep_fields, + qw(Section Priority Description)); + + sub version { printf _g("Debian %s version %s.\n"), $progname, $version; @@ -55,12 +60,6 @@ Options: "), $progname; } -$i=100;grep($fieldimps{$_}=$i--, - qw(Package Version Section Priority Architecture Essential - Pre-Depends Depends Recommends Suggests Enhances Optional - Conflicts Replaces Provides Installed-Size Origin Maintainer - Bugs Source Description Build-Depends Build-Depends-Indep - Build-Conflicts Build-Conflicts-Indep )); while (@ARGV) { $_=shift(@ARGV); @@ -294,6 +293,7 @@ if (!$stdout) { binmode(STDOUT); } +set_field_importance(@control_fields); outputclose($varlistfile); if (!$stdout) { diff --git a/scripts/dpkg-scanpackages.pl b/scripts/dpkg-scanpackages.pl index 3dbb12b8..5be21b2a 100755 --- a/scripts/dpkg-scanpackages.pl +++ b/scripts/dpkg-scanpackages.pl @@ -12,9 +12,12 @@ my $dpkglibdir= "."; # This line modified by Makefile ($0) = $0 =~ m:.*/(.+):; push(@INC,$dpkglibdir); +require 'controllib.pl'; require 'dpkg-gettext.pl'; textdomain("dpkg-dev"); +our @pkg_dep_fields; + my (@samemaint, @changedmaint); my %packages; my %overridden; @@ -25,30 +28,9 @@ my %kmap= (optional => 'suggests', package_revision => 'revision', ); -my @fieldpri= ('Package', - 'Source', - 'Version', - 'Priority', - 'Section', - 'Essential', - 'Maintainer', - 'Pre-Depends', - 'Depends', - 'Recommends', - 'Suggests', - 'Conflicts', - 'Provides', - 'Replaces', - 'Enhances', - 'Architecture', - 'Filename', - 'Size', - 'Installed-Size', - 'MD5sum', - 'Description', - 'Origin', - 'Bugs' - ); +my @fieldpri = (qw(Package Source Version Architecture Essential Origin Bugs + Maintainer Installed-Size), @pkg_dep_fields, qw(Filename + Size MD5sum Section Priority Description)); # This maps the fields into the proper case my %field_case; diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index 551de9bf..369c72f6 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -45,6 +45,10 @@ require 'controllib.pl'; require 'dpkg-gettext.pl'; textdomain("dpkg-dev"); +my @dsc_fields = (qw(Format Source Binary Architecture Version Origin + Maintainer Uploaders Standards-Version), @src_dep_fields); + + # Make sure patch doesn't get any funny ideas delete $ENV{'POSIXLY_CORRECT'}; @@ -120,12 +124,6 @@ sub handleformat { } -$i = 100; -grep ($fieldimps {$_} = $i--, - qw(Format Source Version Binary Origin Maintainer Uploaders Architecture - Standards-Version Build-Depends Build-Depends-Indep Build-Conflicts - Build-Conflicts-Indep)); - while (@ARGV && $ARGV[0] =~ m/^-/) { $_=shift(@ARGV); if (m/^-b$/) { @@ -582,6 +580,7 @@ if ($opmode eq 'build') { || &syserr(_g("write building message")); open(STDOUT,"> $basenamerev.dsc") || &syserr(sprintf(_g("create %s"), "$basenamerev.dsc")); + set_field_importance(@dsc_fields); outputclose($varlistfile); if ($ur) { -- 2.39.5