]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_makeshlibs
r420: big monsta changes
[debhelper.git] / dh_makeshlibs
index 237602b4984cd9998f1cc65864afaf5d1314ecd6..20644d80e6be01d4be417da8179cc7622148dcba 100755 (executable)
@@ -2,25 +2,38 @@
 #
 # Automatically generate shlibs files.
 
+use strict;
 use Debian::Debhelper::Dh_Lib;
 init();
 
-foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
-       $TMP=tmpdir($PACKAGE);
+foreach my $package (@{$dh{DOPACKAGES}}) {
+       my $tmp=tmpdir($package);
 
-       doit("rm", "-f", "$TMP/DEBIAN/shlibs");
+       my %seen;
+       my $need_ldconfig = 0;
 
-       open (FIND, "find $TMP -type f -name '*.so.*' |");
+       doit("rm", "-f", "$tmp/DEBIAN/shlibs");
+
+       open (FIND, "find $tmp -xtype f -name '*.so*' |");
        while (<FIND>) {
+               my $library;
+               my $major;
+       
                chomp;
-               ($library, $major)=m#.*/(.*)\.so\.(\d*)\.?#;
+               $need_ldconfig=1;
+               # The second evil regexp is for db3, whose author should
+               # be shot.
+               if (m#.*/([^/]*)\.so\.(\d*)\.?# || m#.*/([^/]*)-([^\s/]+)\.so$#) {
+                       $library = $1;
+                       $major = $2;
+               }
                if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
                        $major=$dh{M_PARAMS};
                }
-               if (! -d "$TMP/DEBIAN") {
-                       doit("install","-d","$TMP/DEBIAN");
+               if (! -d "$tmp/DEBIAN") {
+                       doit("install","-d","$tmp/DEBIAN");
                }
-               $deps=$PACKAGE;
+               my $deps=$package;
                if ($dh{V_FLAG_SET}) {
                        if ($dh{V_FLAG} ne '') {
                                $deps=$dh{V_FLAG};
@@ -28,19 +41,30 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
                        else {
                                # Call isnative becuase it sets $dh{VERSION}
                                # as a side effect.
-                               isnative($PACKAGE);
-                               $deps="$PACKAGE (>= $dh{VERSION})";
+                               isnative($package);
+                               $deps="$package (>= $dh{VERSION})";
                        }
                }
-               if (defined($library) && defined($major) && defined($deps) && 
+               if (defined($library) && defined($major) && defined($deps) &&
                    $library ne '' && $major ne '' && $deps ne '') {
-                       complex_doit("echo '$library $major $deps' >>$TMP/DEBIAN/shlibs");
+                       # Prevent duplicate lines from entering the file.
+                       my $line="$library $major $deps";
+                       if (! $seen{$line}) {
+                               $seen{$line}=1;
+                               complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
+                       }
                }
        }
        close FIND;
 
-       if (-e "$TMP/DEBIAN/shlibs") {
-               doit("chmod",644,"$TMP/DEBIAN/shlibs");
-               doit("chown","root.root","$TMP/DEBIAN/shlibs");
+       # New as of dh_v3.
+       if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
+               autoscript($package,"postinst","postinst-makeshlibs");
+               autoscript($package,"postrm","postrm-makeshlibs");
+       }
+
+       if (-e "$tmp/DEBIAN/shlibs") {
+               doit("chmod",644,"$tmp/DEBIAN/shlibs");
+               doit("chown","0.0","$tmp/DEBIAN/shlibs");
        }
 }