]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_makeshlibs
r388: * Ok, I tihnk we have a db3 fix that will really work now.
[debhelper.git] / dh_makeshlibs
index a09e26f69f2dcb9c414e5092e0b9152c6409071f..6c708e8676c0ae936d4208623d91d17f152938a2 100755 (executable)
@@ -1,30 +1,58 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Automatically generate shlibs files.
 
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
+use Debian::Debhelper::Dh_Lib;
+init();
 
-for PACKAGE in $DH_DOPACKAGES; do
-       TMP=`tmpdir $PACKAGE`
+foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
+       $TMP=tmpdir($PACKAGE);
 
-       if [ -e "debian/$TMP/DEBIAN/shlibs" ]; then
-               error "debian/$TMP/DEBIAN/shlibs already exists."
-       fi
+       my %seen;
 
-       for file in `find debian/$TMP -type f -name "*.so*" | tr "\n" " "` ; do
-               LIBRARY=`expr $file : ".*/\(.*\)\.so\..*"` || true
-               VERSION=`expr $file : ".*/.*\.so\.\(.*\)"` || true
-               MAJOR=`expr $VERSION : "\([0-9]*\)\."` || true
-               LIBSTUB=`expr $file : "\(.*\/.*\.so\)\..*"` || true
-               if [ ! -d "debian/$TMP/DEBIAN" ] ; then
-                       doit "install -d debian/$TMP/DEBIAN"
-               fi
-               verbose_echo "echo \"$LIBRARY $MAJOR $PACKAGE\" >>debian/$TMP/DEBIAN/shlibs"
-               echo "$LIBRARY $MAJOR $PACKAGE" >>debian/$TMP/DEBIAN/shlibs
-       done
+       doit("rm", "-f", "$TMP/DEBIAN/shlibs");
 
-       if [ -e "debian/$TMP/DEBIAN/shlibs" ]; then
-               doit "chown root.root debian/$TMP/DEBIAN/shlibs"
-       fi
-done
+       open (FIND, "find $TMP -xtype f -name '*.so.*' |");
+       while (<FIND>) {
+               chomp;
+               # 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");
+               }
+               $deps=$PACKAGE;
+               if ($dh{V_FLAG_SET}) {
+                       if ($dh{V_FLAG} ne '') {
+                               $deps=$dh{V_FLAG};
+                       }       
+                       else {
+                               # Call isnative becuase it sets $dh{VERSION}
+                               # as a side effect.
+                               isnative($PACKAGE);
+                               $deps="$PACKAGE (>= $dh{VERSION})";
+                       }
+               }
+               if (defined($library) && defined($major) && defined($deps) &&
+                   $library ne '' && $major ne '' && $deps ne '') {
+                       # 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","0.0","$TMP/DEBIAN/shlibs");
+       }
+}