From: Raphael Hertzog Date: Wed, 21 Nov 2007 16:00:41 +0000 (+0100) Subject: Add new module Dpkg::Fields replacing parts of controllib.pl X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7c9cb9869838f92e98a71ec2ba1cc641cbeac44;p=dpkg Add new module Dpkg::Fields replacing parts of controllib.pl New module containing 3 functions moved out of controllib.pl (capit(), set_field_importance(), sort_by_field_importance()). Adapt all the scripts accordingly. --- diff --git a/ChangeLog b/ChangeLog index 8ec8c254..684e269e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,15 @@ empty dependency fields are correctly handled. * scripts/Makefile.am: Include the new data files required by the tests above. + * scrips/Dpkg/Fields.pm: New module containing 3 functions moved + out of controllib.pl (capit(), set_field_importance(), + sort_by_field_importance()). + * scripts/controllib.pl: Removed the 3 functions above. + * scripts/dpkg-shlibdeps.pl: Use Dpkg::Fields for capit(). + * scripts/dpkg-genchanges.pl: Use Dpkg::Fields for capit() and + set_field_importance(). + * scripts/dpkg-gencontrol.pl: Likewise. + * scripts/dpkg-source.pl: Likewise. 2007-11-20 Guillem Jover diff --git a/debian/changelog b/debian/changelog index 63e2cdd0..70832f5f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,8 @@ dpkg (1.14.10) UNRELEASED; urgency=low [ Raphael Hertzog ] * dpkg-shlibdeps now correctly identify private libraries (avoid many warnings with perl/python modules). + * Move capit() to a Dpkg::Fields module and use it in dpkg-shlibdeps. + Closes: #452262 [ Updated man pages translations ] * Swedish (Peter Karlsson) diff --git a/debian/dpkg-dev.install b/debian/dpkg-dev.install index 8124ae59..8d2a6123 100644 --- a/debian/dpkg-dev.install +++ b/debian/dpkg-dev.install @@ -64,6 +64,7 @@ usr/share/perl5/Dpkg/Arch.pm usr/share/perl5/Dpkg/BuildOptions.pm usr/share/perl5/Dpkg/ErrorHandling.pm usr/share/perl5/Dpkg/Deps.pm +usr/share/perl5/Dpkg/Fields.pm usr/share/perl5/Dpkg/Path.pm usr/share/perl5/Dpkg/Shlibs usr/share/perl5/Dpkg/Shlibs.pm diff --git a/scripts/Dpkg/Fields.pm b/scripts/Dpkg/Fields.pm new file mode 100644 index 00000000..7602ac13 --- /dev/null +++ b/scripts/Dpkg/Fields.pm @@ -0,0 +1,40 @@ +package Dpkg::Fields; + +use strict; +use warnings; + +use Exporter; +our @ISA = qw(Exporter); +our @EXPORT_OK = qw(capit set_field_importance sort_field_by_importance); + +sub capit { + my @pieces = map { ucfirst(lc) } split /-/, $_[0]; + return join '-', @pieces; +} + +our %fieldimps; + +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; + } +} + +1; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 1e161a07..30ce4059 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -78,6 +78,7 @@ nobase_dist_perllib_DATA = \ Dpkg/BuildOptions.pm \ Dpkg/ErrorHandling.pm \ Dpkg/Deps.pm \ + Dpkg/Fields.pm \ Dpkg/Gettext.pm \ Dpkg/Path.pm \ Dpkg/Shlibs.pm \ diff --git a/scripts/changelog/debian.pl b/scripts/changelog/debian.pl index 85a0b2e3..2760c147 100755 --- a/scripts/changelog/debian.pl +++ b/scripts/changelog/debian.pl @@ -6,6 +6,7 @@ use warnings; use Dpkg; use Dpkg::Gettext; use Dpkg::ErrorHandling qw(error internerr usageerr); +use Dpkg::Fields qw(set_field_importance); push(@INC,$dpkglibdir); require 'controllib.pl'; diff --git a/scripts/controllib.pl b/scripts/controllib.pl index 8c54fbeb..6e2a4b40 100755 --- a/scripts/controllib.pl +++ b/scripts/controllib.pl @@ -9,6 +9,7 @@ use Dpkg; use Dpkg::Gettext; use Dpkg::ErrorHandling qw(warning error failure internerr syserr subprocerr); use Dpkg::Arch qw(get_host_arch debarch_is); +use Dpkg::Fields qw(capit sort_field_by_importance); textdomain("dpkg-dev"); @@ -74,11 +75,6 @@ sub getfowner return @fowner; } -sub capit { - my @pieces = map { ucfirst(lc) } split /-/, $_[0]; - return join '-', @pieces; -} - sub substvars { my ($v) = @_; my $lhs; @@ -105,31 +101,6 @@ sub substvars { return $v; } -my %fieldimps; - -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) = @_; diff --git a/scripts/dpkg-genchanges.pl b/scripts/dpkg-genchanges.pl index 5cc61e48..c2dbb7d7 100755 --- a/scripts/dpkg-genchanges.pl +++ b/scripts/dpkg-genchanges.pl @@ -10,6 +10,7 @@ use Dpkg::Gettext; use Dpkg::ErrorHandling qw(warning error failure unknown internerr syserr subprocerr usageerr); use Dpkg::Arch qw(get_host_arch debarch_eq debarch_is); +use Dpkg::Fields qw(capit set_field_importance sort_field_by_importance); push(@INC,$dpkglibdir); require 'controllib.pl'; diff --git a/scripts/dpkg-gencontrol.pl b/scripts/dpkg-gencontrol.pl index 623809fc..d7493604 100755 --- a/scripts/dpkg-gencontrol.pl +++ b/scripts/dpkg-gencontrol.pl @@ -11,6 +11,7 @@ use Dpkg::ErrorHandling qw(warning error failure unknown internerr syserr subprocerr usageerr); use Dpkg::Arch qw(get_host_arch debarch_eq debarch_is); use Dpkg::Deps qw(@pkg_dep_fields %dep_field_type); +use Dpkg::Fields qw(capit set_field_importance); push(@INC,$dpkglibdir); require 'controllib.pl'; diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 1599aa6d..8902b948 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -14,6 +14,7 @@ use Dpkg::Shlibs qw(find_library); use Dpkg::Shlibs::Objdump; use Dpkg::Shlibs::SymbolFile; use Dpkg::Arch qw(get_host_arch); +use Dpkg::Fields qw(capit); our $host_arch= get_host_arch(); diff --git a/scripts/dpkg-source.pl b/scripts/dpkg-source.pl index d9542a91..b82b9d14 100755 --- a/scripts/dpkg-source.pl +++ b/scripts/dpkg-source.pl @@ -10,6 +10,7 @@ use Dpkg::ErrorHandling qw(warning warnerror error failure unknown $warnable_error $quiet_warnings); use Dpkg::Arch qw(debarch_eq); use Dpkg::Deps qw(@src_dep_fields %dep_field_type); +use Dpkg::Fields qw(capit set_field_importance); my @filesinarchive; my %dirincluded;