File: pkgkde-gensymbols

package info (click to toggle)
pkg-kde-tools 0.15.32
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 752 kB
  • sloc: perl: 4,178; ansic: 628; sh: 481; python: 48; makefile: 1
file content (76 lines) | stat: -rwxr-xr-x 2,164 bytes parent folder | download
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
#!/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(find_exe_in_path);

my $old_symbolfile_parse;

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

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);
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
unless (do $exe) {
    print STDERR $@;
    exit 1;
}

# vim: noexpandtab ts=8 sw=4