Debian Codegraph @

dh_sodeps

raw
1 #!/usr/bin/perl -w
2
3 # Copyright (C) 2010 Modestas Vainius <[email protected]>
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 =head1 NAME
19
20 dh_sodeps - generate library dependencies for development *.so symlinks
21
22 =head1 SYNOPSIS
23
24 B<dh_sodeps> [S<I<debhelper options>>] [B<-V>I<versioninfo>]
25
26 =head1 DESCRIPTION
27
28 dh_sodeps is a helper program that generates library dependencies for *.so
29 symlinks that are typically found in the library development packages.
30
31 It basically looks for F<usr/lib/*.so> in the package build directory, finds
32 all local arch specific packages that actually contain targets of those
33 symlinks and adds dependencies on the discovered packages to the C<so:Depends>
34 substitution variable. Dependencies are strict by default, i.e.
35 (=${binary:Version}) if the package containing *.so is arch specific or
36 (>=${source:Version}) if it is arch independent.
37
38 =head1 OPTIONS
39
40 =over 4
41
42 =item B<-V>I<versioninfo>, B<--version-info>=I<versioninfo>
43
44 Use the specified version information for dependencies. If this option is not
45 specified, dh_sodeps will generate a strict dependency as explained above.
46 Please note that you don't need to enclose the value in brackets. dh_sodeps
47 will do this automatically.
48
49 =item B<-X>I<item>, B<--exclude> I<item>
50
51 Do not calculate dependencies for *.so files that contain "item" anywhere in
52 their path/filename. You may use this option multiple times to build up a list
53 of things to exclude.
54
55 =back
56
57 =cut
58
59 use strict;
60 use warnings;
61
62 use Debian::Debhelper::Dh_Lib;
63
64 my $opt_verinfo;
65
66 init(options => {
67 'version-info|V' => \$opt_verinfo,
68 });
69
70 exit 0 unless @{$dh{DOPACKAGES}};
71
72 my @packages = getpackages("arch");
73
74 foreach my $package (@{$dh{DOPACKAGES}}) {
75 my $tmpdir = tmpdir($package);
76 my $globstring = "$tmpdir/usr/lib/*.so";
77 my $multiarch = dpkg_architecture_value("DEB_HOST_MULTIARCH");
78 if (defined $multiarch) {
79 $globstring = "$globstring $tmpdir/usr/lib/$multiarch/*.so"
80 }
81 my @solinks = grep { -l $_ } glob($globstring);
82
83 if (@solinks) {
84 my $arch = package_arch($package);
85 my $verinfo;
86
87 if (defined $opt_verinfo) {
88 $verinfo = $opt_verinfo;
89 } elsif ($arch eq "all") {
90 $verinfo = '>= ${source:Version}';
91 } else {
92 $verinfo = '= ${binary:Version}';
93 }
94
95 foreach my $solink (@solinks) {
96 next if excludefile($solink);
97
98 my $target = readlink($solink);
99 foreach my $p (@packages) {
100 next if $p eq $package;
101 if (-e "debian/$p/usr/lib/$target" || (defined $multiarch and -e "debian/$p/usr/lib/$multiarch/$target")) {
102 addsubstvar($package, "so:Depends", $p, $verinfo);
103 }
104 }
105 }
106 }
107 }
108
109 exit 0;
110
111 =head1 SEE ALSO
112
113 L<debhelper(7)>
114
115 =head1 AUTHOR
116
117 Modestas Vainius <[email protected]>
118
119 =cut