[Lunar-commits] r14631 - lunar-iso/trunk/scripts

Auke Kok sofar at lunar-linux.org
Sat May 7 14:12:27 UTC 2005


Author: sofar
Date: 2005-05-07 14:12:26 +0000 (Sat, 07 May 2005)
New Revision: 14631

Added:
   lunar-iso/trunk/scripts/ldd-gather
Log:
Adding this (backport + cleanup from 2.6 branch)


Added: lunar-iso/trunk/scripts/ldd-gather
===================================================================
--- lunar-iso/trunk/scripts/ldd-gather	2005-05-07 14:00:50 UTC (rev 14630)
+++ lunar-iso/trunk/scripts/ldd-gather	2005-05-07 14:12:26 UTC (rev 14631)
@@ -0,0 +1,67 @@
+#!/bin/bash
+
+#
+# Search for the dynamic libs the binaries are linked to.
+#
+# The binaries are served as a file on the commandline ( $1 ), 
+# one binary per line.
+#
+# The result is echoed to stdout.
+#
+# The resulting list has dual appearances elimininated.
+#
+# Supports "dual linking", e.g.: 
+# binary ---[ links to ]---> symlink.so.[0-9]* ---[ points to ]---> symlink.so
+#
+# Errors are echoed to stderr. 
+# 0 exit code for success, 1 otherwise.
+#
+
+usage()
+{
+	cat << EOF >&2
+
+Usage: 
+
+   $0 file
+
+where file is a list of binaries, one per line, that you want to know
+the dynamic linking of. 
+
+EOF
+
+	exit 1
+}
+
+
+if [ $# -gt 1 ]; then
+	usage
+elif [ $# -eq 1 ]; then
+	if [ ! -f ${1} ]; then
+		usage
+	fi
+fi
+
+cat $1 | while read binary ; do
+	if [ -x $binary ] ; then
+		ldd $binary
+	fi
+done | grep "=> /" | cut -d" " -f3 | sort | uniq | while read lib ; do
+    echo $lib
+    
+    symlinked=`readlink $lib`
+    dir=`dirname $lib`
+
+    symlink=$dir/$symlinked
+    if [ -e "$symlink" ]; then
+       echo "$symlink"
+    fi
+
+    stripped=${symlink%%.[0-9]*}
+    if [ -e ${stripped} ]; then
+       echo "${stripped}"
+    fi
+
+done
+
+exit 0



More information about the Lunar-commits mailing list