summaryrefslogtreecommitdiff
path: root/scripts/dpkg-shlibdeps.pl
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-03-18 23:08:34 +0100
committerGuillem Jover <guillem@debian.org>2015-05-18 02:03:51 +0200
commit20a5b3509e94c1a349657c2a9e656d5ddbe558b6 (patch)
treea277f5810d01722a1200450fa4ad42efdf802667 /scripts/dpkg-shlibdeps.pl
parent9aa0a60a2491caeed59af5fd760c064b3be3cc00 (diff)
downloaddpkg-20a5b3509e94c1a349657c2a9e656d5ddbe558b6.tar.gz
dpkg-shlibdeps: Use Dpkg::Substvars instead of ad-hoc parsing the file
Diffstat (limited to 'scripts/dpkg-shlibdeps.pl')
-rwxr-xr-xscripts/dpkg-shlibdeps.pl33
1 files changed, 13 insertions, 20 deletions
diff --git a/scripts/dpkg-shlibdeps.pl b/scripts/dpkg-shlibdeps.pl
index f54dfb3ea..c5cf56d14 100755
--- a/scripts/dpkg-shlibdeps.pl
+++ b/scripts/dpkg-shlibdeps.pl
@@ -38,6 +38,7 @@ use Dpkg::Version;
use Dpkg::Shlibs qw(find_library get_library_paths);
use Dpkg::Shlibs::Objdump;
use Dpkg::Shlibs::SymbolFile;
+use Dpkg::Substvars;
use Dpkg::Arch qw(get_host_arch);
use Dpkg::Deps;
use Dpkg::Control::Info;
@@ -63,6 +64,7 @@ my $shlibslocal = 'debian/shlibs.local';
my $packagetype = 'deb';
my $dependencyfield = 'Depends';
my $varlistfile = 'debian/substvars';
+my $varlistfilenew;
my $varnameprefix = 'shlibs';
my $ignore_missing_info = 0;
my $warnings = 3;
@@ -447,25 +449,15 @@ if ($error_count >= 1) {
}
# Open substvars file
-my $fh;
+
+my $substvars = Dpkg::Substvars->new();
if ($stdout) {
- $fh = \*STDOUT;
+ $varlistfilenew = '-';
} else {
- open(my $new_fh, '>', "$varlistfile.new")
- or syserr(g_("open new substvars file '%s'"), "$varlistfile.new");
- if (-e $varlistfile) {
- open(my $old_fh, '<', $varlistfile)
- or syserr(g_("open old substvars file '%s' for reading"),
- $varlistfile);
- while (my $entry = <$old_fh>) {
- next if $entry =~ m/^\Q$varnameprefix\E:/;
- print { $new_fh } $entry
- or syserr(g_("copy old entry to new substvars file '%s'"),
- "$varlistfile.new");
- }
- close($old_fh);
- }
- $fh = $new_fh;
+ $substvars->load($varlistfile) if -e $varlistfile;
+ $substvars->filter(remove => sub { $_[0] =~ m/^\Q$varnameprefix\E:/ });
+
+ $varlistfilenew = "$varlistfile.new";
}
# Write out the shlibs substvars
@@ -527,14 +519,15 @@ foreach my $field (reverse @depfields) {
my $obj = deps_parse($dep);
error(g_('invalid dependency got generated: %s'), $dep) unless defined $obj;
$obj->sort();
- print { $fh } "$varnameprefix:$field=$obj\n";
+ $substvars->set_as_used("$varnameprefix:$field", "$obj");
}
}
+$substvars->save($varlistfilenew);
+
# Replace old file by new one
if (!$stdout) {
- close($fh) or syserr(g_('cannot close %s'), "$varlistfile.new");
- rename "$varlistfile.new", $varlistfile
+ rename $varlistfilenew, $varlistfile
or syserr(g_("install new varlist file '%s'"), $varlistfile);
}