]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_makeshlibs
r273: * dh_installdocs.1: clarified how the doc-id is determined. Closes: #44864
[debhelper.git] / dh_makeshlibs
index a09e26f69f2dcb9c414e5092e0b9152c6409071f..c3742267eeaf78a5ecdb22bfd3ff4d74f7ec7ba9 100755 (executable)
@@ -1,30 +1,47 @@
-#!/bin/sh -e
+#!/usr/bin/perl -w
 #
 # Automatically generate shlibs files.
 
-PATH=debian:$PATH:/usr/lib/debhelper
-. dh_lib
+BEGIN { push @INC, "debian", "/usr/share/debhelper" }
+use 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
+       doit("rm", "-f", "$TMP/DEBIAN/shlibs");
 
-       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
+       open (FIND, "find $TMP -type f -name '*.so.*' |");
+       while (<FIND>) {
+               chomp;
+               ($library, $major)=m#.*/(.*)\.so\.(\d*)\.?#;
+               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 '') {
+                       complex_doit("echo '$library $major $deps' >>$TMP/DEBIAN/shlibs");
+               }
+       }
+       close FIND;
 
-       if [ -e "debian/$TMP/DEBIAN/shlibs" ]; then
-               doit "chown root.root debian/$TMP/DEBIAN/shlibs"
-       fi
-done
+       if (-e "$TMP/DEBIAN/shlibs") {
+               doit("chmod",644,"$TMP/DEBIAN/shlibs");
+               doit("chown","root.root","$TMP/DEBIAN/shlibs");
+       }
+}