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

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.
Raphael Hertzog лет назад: 18
Родитель
Сommit
a7c9cb9869

+ 9 - 0
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  <guillem@debian.org>
 

+ 2 - 0
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)

+ 1 - 0
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

+ 40 - 0
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;

+ 1 - 0
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 \

+ 1 - 0
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';

+ 1 - 30
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) = @_;
 

+ 1 - 0
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';

+ 1 - 0
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';

+ 1 - 0
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();
 

+ 1 - 0
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;