From: Frank Lichtenheld Date: Sun, 8 Jul 2007 22:12:49 +0000 (+0000) Subject: Dpkg::Shlibs::*: Code cleanup X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a5c4f07dbf4c9da41502671adfb305e06e04f2f8;p=dpkg Dpkg::Shlibs::*: Code cleanup Use the new Dpkg::* utility modules --- diff --git a/scripts/Dpkg/Shlibs/Objdump.pm b/scripts/Dpkg/Shlibs/Objdump.pm index b28c82dd..a389a645 100644 --- a/scripts/Dpkg/Shlibs/Objdump.pm +++ b/scripts/Dpkg/Shlibs/Objdump.pm @@ -16,7 +16,9 @@ package Dpkg::Shlibs::Objdump; -require 'dpkg-gettext.pl'; +use Dpkg::Gettext; +use Dpkg::ErrorHandling qw(syserr subprocerr warning); +textdomain("dpkg-dev"); sub new { my $this = shift; @@ -30,7 +32,7 @@ sub parse { my ($self, $file) = @_; local $ENV{LC_ALL} = 'C'; open(OBJDUMP, "-|", "objdump", "-w", "-p", "-T", $file) || - syserr(sprintf(_g("Can't execute objdump: %s"), $!)); + syserr(sprintf(_g("Can't execute objdump: %s"), $!)); my $obj = Dpkg::Shlibs::Objdump::Object->new($file); my $section = "none"; while (defined($_ = )) { @@ -141,7 +143,7 @@ sub parse_dynamic_symbol { } elsif ($line =~ /^[0-9a-f]+ (.{7})\s+(\S+)\s+[0-9a-f]+/) { # Same start but no version and no symbol ... just ignore } else { - main::warning(sprintf(_g("Couldn't parse one line of objdump's output: %s"), $line)); + warning(sprintf(_g("Couldn't parse one line of objdump's output: %s"), $line)); } } @@ -173,7 +175,8 @@ sub get_object { return $format{$file}; } else { local $ENV{LC_ALL} = "C"; - open(P, "objdump -a -- $file |") || syserr(_g("cannot fork for objdump")); + open(P, "-|", "objdump", "-a", "--", $file) + || syserr(_g("cannot fork for objdump")); while (

) { chomp; if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) { @@ -181,14 +184,15 @@ sub get_object { return $format{$file}; } } - close(P) or main::subprocerr(sprintf(_g("objdump on \`%s'"), $file)); + close(P) or subprocerr(sprintf(_g("objdump on \`%s'"), $file)); } } } sub is_elf { my ($file) = @_; - open(FILE, "<", $file) || main::syserr(sprintf(_g("Can't open %s for test: %s"), $file, $!)); + open(FILE, "<", $file) || + syserr(sprintf(_g("Can't open %s for test: %s"), $file, $!)); my ($header, $result) = ("", 0); if (read(FILE, $header, 4) == 4) { $result = 1 if ($header =~ /^\177ELF$/); diff --git a/scripts/Dpkg/Shlibs/SymbolFile.pm b/scripts/Dpkg/Shlibs/SymbolFile.pm index 43c17e1e..fb776486 100644 --- a/scripts/Dpkg/Shlibs/SymbolFile.pm +++ b/scripts/Dpkg/Shlibs/SymbolFile.pm @@ -16,9 +16,10 @@ package Dpkg::Shlibs::SymbolFile; -require 'dpkg-gettext.pl'; - +use Dpkg::Gettext; +use Dpkg::ErrorHandling qw(syserr warning); use Dpkg::Version qw(vercmp); +textdomain("dpkg-dev"); sub new { my $this = shift; @@ -50,7 +51,8 @@ sub clear_except { sub load { my ($self, $file) = @_; $self->{file} = $file; - open(SYM_FILE, "<", $file) || main::syserr(sprintf(_g("Can't open %s: %s"), $file)); + open(SYM_FILE, "<", $file) + || syserr(sprintf(_g("Can't open %s: %s"), $file)); my ($object); while (defined($_ = )) { chomp($_); @@ -80,7 +82,7 @@ sub load { 'deps' => [ "$2" ] }; } else { - main::warning(sprintf(_g("Failed to parse a line in %s: %s"), $file, $_)); + warning(sprintf(_g("Failed to parse a line in %s: %s"), $file, $_)); } } close(SYM_FILE); @@ -93,7 +95,8 @@ sub save { if ($file eq "-") { $fh = \*STDOUT; } else { - open(SYM_FILE, "> $file") || main::syserr(sprintf(_g("Can't open %s for writing: %s"), $file, $!)); + open(SYM_FILE, "> $file") + || syserr(sprintf(_g("Can't open %s for writing: %s"), $file, $!)); $fh = \*SYM_FILE; } $self->dump($fh); diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl index 28087dfd..df5c89d2 100755 --- a/scripts/dpkg-shlibdeps.pl +++ b/scripts/dpkg-shlibdeps.pl @@ -12,7 +12,7 @@ my $admindir = "/var/lib/dpkg"; BEGIN { $version="1.14.4"; # This line modified by Makefile - $dpkglibdir="/usr/lib/dpkg"; # This line modified by Makefile + $dpkglibdir="."; # This line modified by Makefile push(@INC,$dpkglibdir); } diff --git a/scripts/t/200_Dpkg_Shlibs.t b/scripts/t/200_Dpkg_Shlibs.t index ec74b7eb..81b39159 100644 --- a/scripts/t/200_Dpkg_Shlibs.t +++ b/scripts/t/200_Dpkg_Shlibs.t @@ -1,9 +1,9 @@ # -*- mode: cperl;-*- -use Test::More tests => 2; +use Test::More tests => 4; -use warnings; use strict; +use warnings; use_ok('Dpkg::Shlibs'); @@ -16,3 +16,6 @@ use Data::Dumper; is_deeply([qw(/nonexistant32 /nonexistant/lib64 /usr/local/lib /nonexistant/lib128 )], \@Dpkg::Shlibs::librarypaths, "parsed library paths"); + +use_ok('Dpkg::Shlibs::Objdump'); +use_ok('Dpkg::Shlibs::SymbolFile');