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