File: pkgkde-gensymbols

package info (click to toggle)
pkg-kde-tools 0.15.15~bpo70%2B1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 684 kB
  • sloc: perl: 5,271; ansic: 628; sh: 421; makefile: 3
file content (81 lines) | stat: -rwxr-xr-x 2,387 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/perl

# Copyright (C) 2010 Modestas Vainius <modax@debian.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

use strict;
use warnings;

use Dpkg;
use Debian::PkgKde qw(setup_datalibdir find_exe_in_path);

my $old_symbolfile_parse;

sub new_symbolfile_parse {
    # Use Debian::PkgKde::SymbolsHelper::Symbol as base symbol
    my ($self, $fh, $file, $seen, $obj_ref, $base_symbol) = @_;
    unless (defined $base_symbol) {
	$base_symbol = 'Debian::PkgKde::SymbolsHelper::Symbol';
    }
    return &$old_symbolfile_parse($self, $fh, $file, $seen, $obj_ref,
	$base_symbol);
}

sub check_dpkg_version {
    my @need = @_;
    my @ver = split(/[.]/, $Dpkg::version);
    my $ok = 0;
    for (my $i = 0; ! $ok && $i < @need && $i < @ver; $i++) {
	if ($ver[$i] > $need[$i]) {
	    $ok = 1;
	} elsif ($ver[$i] == $need[$i]) {
	    if ($i == $#need) {
		$ok = 1;
	    }
	} else {
	    # Less
	    last;
	}
    }
    return $ok;
}

my $exe = find_exe_in_path("dpkg-gensymbols", $0);

# Export global datalibdir if needed
my $dir = setup_datalibdir(qw(Dpkg/Shlibs/SymbolFile.pm));
if (defined $dir) {
    unless ($exe) {
	print STDERR "pkgkde-gensymbols: dpkg-gensymbols could not be found in PATH", "\n";
	exit 1;
    }

    eval "use Dpkg::Shlibs::SymbolFile";
    eval "use Debian::PkgKde::SymbolsHelper::Symbol";

    # Replace Dpkg::Shlibs::SymbolFile::load with a custom version
    # which uses Debian::PkgKde::SymbolsHelper::Symbol rather than
    # Dpkg::Shlibs::Symbol
    $old_symbolfile_parse = *Dpkg::Shlibs::SymbolFile::parse;
    *Dpkg::Shlibs::SymbolFile::parse = *new_symbolfile_parse;

    # Finally, run stock dpkg-gensymbols
    do "$exe";
} else {
    print STDERR "pkgkde-gensymbols: unable to determine execution context.", "\n";
    exit 1;
}

# vim: noexpandtab ts=8 sw=4