[Lunar-commits] r14552 - lunar-iso/branches/lunar-iso-2.6/initrd

Jaime Buffery nestu at lunar-linux.org
Sun May 1 11:30:03 UTC 2005


Author: nestu
Date: 2005-05-01 11:30:02 +0000 (Sun, 01 May 2005)
New Revision: 14552

Added:
   lunar-iso/branches/lunar-iso-2.6/initrd/get_bins_dynamic_lib_links
Log:
Will be Used by initrd's creation code. It searches for
the list of libs the bins it is served are linked to.
Thus eliminates the need of adding the libs to the initrd.list*
files.


Added: lunar-iso/branches/lunar-iso-2.6/initrd/get_bins_dynamic_lib_links
===================================================================
--- lunar-iso/branches/lunar-iso-2.6/initrd/get_bins_dynamic_lib_links	2005-05-01 10:37:22 UTC (rev 14551)
+++ lunar-iso/branches/lunar-iso-2.6/initrd/get_bins_dynamic_lib_links	2005-05-01 11:30:02 UTC (rev 14552)
@@ -0,0 +1,80 @@
+#!/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
+
+(
+   while read binary
+   do
+      ldd $binary
+   done < $1
+) | grep "=> /" > $1.lib
+
+# special case
+# echo "/lib/ld-linux.so.2" >> $1.lib
+
+# Leave out dual appearances
+cut -d" " -f3 $1.lib | sort | uniq > $1.lib.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 < $1.lib.uniq
+
+# remove the temp files created
+
+rm $1.lib $1.lib.uniq
+
+exit 0


Property changes on: lunar-iso/branches/lunar-iso-2.6/initrd/get_bins_dynamic_lib_links
___________________________________________________________________
Name: svn:executable
   + *



More information about the Lunar-commits mailing list