File: dh_sodeps

package info (click to toggle)
pkg-kde-tools 0.15.29
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 752 kB
  • sloc: perl: 4,178; ansic: 628; sh: 481; python: 48; makefile: 3
file content (119 lines) | stat: -rwxr-xr-x 3,462 bytes parent folder | download | duplicates (5)
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/perl -w

# 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/>

=head1 NAME

dh_sodeps - generate library dependencies for development *.so symlinks

=head1 SYNOPSIS

B<dh_sodeps> [S<I<debhelper options>>] [B<-V>I<versioninfo>]

=head1 DESCRIPTION

dh_sodeps is a helper program that generates library dependencies for *.so
symlinks that are typically found in the library development packages.

It basically looks for F<usr/lib/*.so> in the package build directory, finds
all local arch specific packages that actually contain targets of those
symlinks and adds dependencies on the discovered packages to the C<so:Depends>
substitution variable. Dependencies are strict by default, i.e.
(=${binary:Version}) if the package containing *.so is arch specific or
(>=${source:Version}) if it is arch independent.

=head1 OPTIONS

=over 4

=item B<-V>I<versioninfo>, B<--version-info>=I<versioninfo>

Use the specified version information for dependencies. If this option is not
specified, dh_sodeps will generate a strict dependency as explained above.
Please note that you don't need to enclose the value in brackets. dh_sodeps
will do this automatically.

=item B<-X>I<item>, B<--exclude> I<item>

Do not calculate dependencies for *.so files that contain "item" anywhere in
their path/filename. You may use this option multiple times to build up a list
of things to exclude.

=back

=cut

use strict;
use warnings;

use Debian::Debhelper::Dh_Lib;

my $opt_verinfo;

init(options => {
    'version-info|V' => \$opt_verinfo,
});

exit 0 unless @{$dh{DOPACKAGES}};

my @packages = getpackages("arch");

foreach my $package (@{$dh{DOPACKAGES}}) {
    my $tmpdir = tmpdir($package);
    my $globstring = "$tmpdir/usr/lib/*.so";
    my $multiarch = dpkg_architecture_value("DEB_HOST_MULTIARCH");
    if (defined $multiarch) {
        $globstring = "$globstring $tmpdir/usr/lib/$multiarch/*.so"
    }
    my @solinks = grep { -l $_ } glob($globstring);

    if (@solinks) {
        my $arch = package_arch($package);
        my $verinfo;

        if (defined $opt_verinfo) {
            $verinfo = $opt_verinfo;
        } elsif ($arch eq "all") {
            $verinfo = '>= ${source:Version}';
        } else {
            $verinfo = '= ${binary:Version}';
        }

        foreach my $solink (@solinks) {
            next if excludefile($solink);

            my $target = readlink($solink);
            foreach my $p (@packages) {
                next if $p eq $package;
                if (-e "debian/$p/usr/lib/$target" || (defined $multiarch and -e "debian/$p/usr/lib/$multiarch/$target")) {
                    addsubstvar($package, "so:Depends", $p, $verinfo);
                }
            }
        }
    }
}

exit 0;

=head1 SEE ALSO

L<debhelper(7)>

=head1 AUTHOR

Modestas Vainius <modax@debian.org>

=cut