~mitya57/pkg-kde-tools/0.15.16ubuntu1

« back to all changes in this revision

Viewing changes to pkgkde-gensymbols

  • Committer: Bazaar Package Importer
  • Author(s): Modestas Vainius
  • Date: 2010-04-08 13:41:29 UTC
  • mfrom: (0.1.20 sid)
  • Revision ID: james.westby@ubuntu.com-20100408134129-bsr1dutc0fnb5192
Tags: 0.7.0.1
Remove perl from pkg-kde-tools Depends to workaround (and use to our own
advantage) brokeness in experimental buildds.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
# Copyright (C) 2010 Modestas Vainius <modax@debian.org>
 
4
#
 
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.
 
9
#
 
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.
 
14
#
 
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/>
 
17
 
 
18
use strict;
 
19
use warnings;
 
20
 
 
21
use Dpkg;
 
22
use Debian::PkgKde qw(setup_datalibdir);
 
23
 
 
24
my $old_symbolfile_parse;
 
25
 
 
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';
 
31
    }
 
32
    return &$old_symbolfile_parse($self, $fh, $file, $seen, $obj_ref,
 
33
        $base_symbol);
 
34
}
 
35
 
 
36
sub check_dpkg_version {
 
37
    my @need = @_;
 
38
    my @ver = split(/[.]/, $Dpkg::version);
 
39
    my $ok = 0;
 
40
    for (my $i = 0; ! $ok && $i < @need && $i < @ver; $i++) {
 
41
        if ($ver[$i] > $need[$i]) {
 
42
            $ok = 1;
 
43
        } elsif ($ver[$i] == $need[$i]) {
 
44
            if ($i == $#need) {
 
45
                $ok = 1;
 
46
            }
 
47
        } else {
 
48
            # Less
 
49
            last;
 
50
        }
 
51
    }
 
52
    return $ok;
 
53
}
 
54
 
 
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));
 
58
    if (defined $dir) {
 
59
        # Finally, run stock dpkg-gensymbols
 
60
        my $exe = "$dir/dpkg-gensymbols.pl";
 
61
 
 
62
        # Compatibility with dpkg 1.15.5
 
63
        require Dpkg::IPC;
 
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;
 
70
        }
 
71
 
 
72
        eval "use Dpkg::Shlibs::SymbolFile";
 
73
        eval "use Debian::PkgKde::SymbolsHelper::Symbol";
 
74
 
 
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;
 
80
 
 
81
        do "$exe";
 
82
    } else {
 
83
        print STDERR "pkgkde-gensymbols: unable to determine execution context.", "\n";
 
84
        exit 1;
 
85
    }
 
86
} else {
 
87
    exec '/usr/bin/dpkg-gensymbols', @ARGV;
 
88
}