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;
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($_ = <OBJDUMP>)) {
} 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));
}
}
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 (<P>) {
chomp;
if (/^\s*\S+:\s*file\s+format\s+(\S+)\s*$/) {
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$/);
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;
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($_ = <SYM_FILE>)) {
chomp($_);
'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);
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);
# -*- mode: cperl;-*-
-use Test::More tests => 2;
+use Test::More tests => 4;
-use warnings;
use strict;
+use warnings;
use_ok('Dpkg::Shlibs');
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');