3
# Copyright (C) 2010 Modestas Vainius <modax@debian.org>
5
# This program is free software: you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation, either version 3 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program. If not, see <http://www.gnu.org/licenses/>
22
use Debian::PkgKde qw(setup_datalibdir);
24
my $old_symbolfile_parse;
26
sub new_symbolfile_parse {
27
# Use Debian::PkgKde::SymbolsHelper::Symbol as base symbol
28
my ($self, $fh, $file, $seen, $obj_ref, $base_symbol) = @_;
29
unless (defined $base_symbol) {
30
$base_symbol = 'Debian::PkgKde::SymbolsHelper::Symbol';
32
return &$old_symbolfile_parse($self, $fh, $file, $seen, $obj_ref,
36
sub check_dpkg_version {
38
my @ver = split(/[.]/, $Dpkg::version);
40
for (my $i = 0; ! $ok && $i < @need && $i < @ver; $i++) {
41
if ($ver[$i] > $need[$i]) {
43
} elsif ($ver[$i] == $need[$i]) {
55
if (check_dpkg_version(1, 15, 5)) {
56
# Export global datalibdir if needed
57
my $dir = setup_datalibdir(qw(Dpkg/Shlibs/SymbolFile.pm dpkg-gensymbols.pl));
59
# Finally, run stock dpkg-gensymbols
60
my $exe = "$dir/dpkg-gensymbols.pl";
62
# Compatibility with dpkg 1.15.5
64
if (! Dpkg::IPC->can("spawn") && Dpkg::IPC->can("fork_and_exec")) {
65
*Dpkg::IPC::spawn = *Dpkg::IPC::fork_and_exec;
66
push @Dpkg::IPC::EXPORT, "spawn";
67
# Fool perl not to emit a warning
68
my $nowarning = \&Dpkg::IPC::spawn;
69
$nowarning = \&Dpkg::IPC::fork_and_exec;
72
eval "use Dpkg::Shlibs::SymbolFile";
73
eval "use Debian::PkgKde::SymbolsHelper::Symbol";
75
# Replace Dpkg::Shlibs::SymbolFile::load with a custom version
76
# which uses Debian::PkgKde::SymbolsHelper::Symbol rather than
77
# Dpkg::Shlibs::Symbol
78
$old_symbolfile_parse = *Dpkg::Shlibs::SymbolFile::parse;
79
*Dpkg::Shlibs::SymbolFile::parse = *new_symbolfile_parse;
83
print STDERR "pkgkde-gensymbols: unable to determine execution context.", "\n";
87
exec '/usr/bin/dpkg-gensymbols', @ARGV;