Merge branch 'debian'
[live-boot-grml.git] / debian / live-boot-grml.init
index cd2e4cd..5799c44 100644 (file)
@@ -47,15 +47,28 @@ cache_path()
                find "${path}" -type f | xargs cat > /dev/null 2>&1
        elif [ -f "${path}" ]
        then
-               if [ -x "${path}" ]
+               if file -L "${path}" | grep -q 'dynamically linked'
                then
-                       if file -L "${path}" | grep -q 'dynamically linked'
-                       then
-                               for lib in $(ldd "${path}" | awk '{ print $3 }')
-                               do
-                                       cache_path "${lib}"
-                               done
-                       fi
+                       # ldd output can be of three forms:
+                       # 1. linux-vdso.so.1 =>  (0x00007fffe3fb4000)
+                       #    This is a virtual, kernel shared library and we want to skip it
+                       # 2. libc.so.6 => /lib/libc.so.6 (0x00007f5e9dc0c000)
+                       #    We want to cache the third word.
+                       # 3. /lib64/ld-linux-x86-64.so.2 (0x00007f5e9df8b000)
+                       #    We want to cache the first word.
+                       ldd "${path}" | while read line
+                       do
+                               if echo "$line" | grep -qs ' =>  '
+                               then
+                                       continue
+                               elif echo "$line" | grep -qs ' => '
+                               then
+                                       lib=$(echo "${line}" | awk '{ print $3 }')
+                               else
+                                       lib=$(echo "${line}" | awk '{ print $1 }')
+                               fi
+                               cache_path "${lib}"
+                       done
                fi
 
                cat "${path}" >/dev/null 2>&1