]> git.donarmstrong.com Git - debhelper.git/blob - dh_makeshlibs
r420: big monsta changes
[debhelper.git] / dh_makeshlibs
1 #!/usr/bin/perl -w
2 #
3 # Automatically generate shlibs files.
4
5 use strict;
6 use Debian::Debhelper::Dh_Lib;
7 init();
8
9 foreach my $package (@{$dh{DOPACKAGES}}) {
10         my $tmp=tmpdir($package);
11
12         my %seen;
13         my $need_ldconfig = 0;
14
15         doit("rm", "-f", "$tmp/DEBIAN/shlibs");
16
17         open (FIND, "find $tmp -xtype f -name '*.so*' |");
18         while (<FIND>) {
19                 my $library;
20                 my $major;
21         
22                 chomp;
23                 $need_ldconfig=1;
24                 # The second evil regexp is for db3, whose author should
25                 # be shot.
26                 if (m#.*/([^/]*)\.so\.(\d*)\.?# || m#.*/([^/]*)-([^\s/]+)\.so$#) {
27                         $library = $1;
28                         $major = $2;
29                 }
30                 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
31                         $major=$dh{M_PARAMS};
32                 }
33                 if (! -d "$tmp/DEBIAN") {
34                         doit("install","-d","$tmp/DEBIAN");
35                 }
36                 my $deps=$package;
37                 if ($dh{V_FLAG_SET}) {
38                         if ($dh{V_FLAG} ne '') {
39                                 $deps=$dh{V_FLAG};
40                         }       
41                         else {
42                                 # Call isnative becuase it sets $dh{VERSION}
43                                 # as a side effect.
44                                 isnative($package);
45                                 $deps="$package (>= $dh{VERSION})";
46                         }
47                 }
48                 if (defined($library) && defined($major) && defined($deps) &&
49                     $library ne '' && $major ne '' && $deps ne '') {
50                         # Prevent duplicate lines from entering the file.
51                         my $line="$library $major $deps";
52                         if (! $seen{$line}) {
53                                 $seen{$line}=1;
54                                 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
55                         }
56                 }
57         }
58         close FIND;
59
60         # New as of dh_v3.
61         if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
62                 autoscript($package,"postinst","postinst-makeshlibs");
63                 autoscript($package,"postrm","postrm-makeshlibs");
64         }
65
66         if (-e "$tmp/DEBIAN/shlibs") {
67                 doit("chmod",644,"$tmp/DEBIAN/shlibs");
68                 doit("chown","0.0","$tmp/DEBIAN/shlibs");
69         }
70 }