1 diff --git a/functions b/functions
2 index a3f6b19..f4d9acb 100644
5 @@ -291,3 +291,9 @@ find_modules_by_class_mit() {
9 +# get possible paths for specifed patter containing LIBDIR
11 + for dir in lib lib64 libx32; do
12 + echo -n "${1/LIBDIR/$dir} "
15 diff --git a/geninitrd b/geninitrd
16 index b8ee2a3..7b962b5 100755
19 @@ -505,7 +505,7 @@ inst() {
22 verbose "+ cp $* DESTDIR$dest"
23 - cp -HR "$@" "$DESTDIR$dest"
24 + cp -HRp "$@" "$DESTDIR$dest"
28 @@ -553,17 +553,20 @@ inst_exec() {
30 # hack for uclibc linked binaries requiring this fixed path
31 # XXX: shouldn't rpath be used here instead so th
32 - if [ -f $DESTDIR/$_lib/libc.so.0 ]; then
33 - lib=$DESTDIR/$_lib/libc.so.0
34 - lib=$(ldd "$lib" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
35 - libdir=$(cd $(dirname "$lib"); pwd)
36 - if [ ! -e $DESTDIR$libdir ]; then
37 - libdir=$(dirname "$libdir")
39 - verbose "+ ln -s /$_lib $DESTDIR$libdir"
40 - ln -s /$_lib $DESTDIR$libdir
41 + for _lib in $(get_libdir LIBDIR); do
42 + if [ -f $DESTDIR/$_lib/libc.so.0 ]; then
43 + lib=$DESTDIR/$_lib/libc.so.0
44 + lib=$(ldd "$lib" | awk '/statically|linux-(gate|vdso)\.so/{next} NF == 2 {print $1} /=/{print $3}' | sort -u)
45 + libdir=$(cd $(dirname "$lib"); pwd)
46 + if [ ! -e $DESTDIR$libdir ]; then
47 + libdir=$(dirname "$libdir")
49 + verbose "+ ln -s /$_lib $DESTDIR$libdir"
50 + ln -s /$_lib $DESTDIR$libdir
58 # output modules.conf / modprobe.conf
59 @@ -999,6 +1002,12 @@ initrd_gen_initramfs_switchroot() {
60 mknod -m 660 $device b $maj $min
63 + # XXX hack, fallback to rootdev from geninitrd time
64 + if [ ! -e "$device" ]; then
66 + echo "DEVICE set to $device based on fstab entry from initrd gen time"
69 # XXX hack, if no device, try to parse it from /proc/partitions using /proc/sys/kernel/real-root-dev
70 if [ ! -e "$device" ]; then
71 rrd=$(cat /proc/sys/kernel/real-root-dev)
72 @@ -1052,6 +1061,14 @@ initrd_gen_initramfs_switchroot() {
73 [ "$DEBUGINITRD" ] || usleep 10000000
76 + # systemd[1]: /usr appears to be on its own filesytem and is not
77 + # already mounted. This is not a supported setup. Some things will
78 + # probably break (sometimes even silently) in mysterious ways. Consult
79 + # http://freedesktop.org/wiki/Software/systemd/separate-usr-is-broken
80 + # for more information.
81 + echo trying to mount /usr
82 + chroot /newroot mount -n /usr
84 exec switch_root /newroot $init ${1:+"$@"}
86 # FIXME: this code is never executed, as "exec" does not return!
87 @@ -1355,19 +1372,10 @@ for dir in libx32 lib64 lib; do
91 -if [ -d /libx32 -a -d /usr/libx32 ]; then
93 -elif [ -d /lib64 -a -d /usr/lib64 ]; then
99 kernel_version=$(echo "$kernel" | awk -F. '{gsub(/[_-].*/, "", $0); print sprintf("%03d%03d",$1,$2)}')
100 kernel_version_long=$(echo "$kernel" | awk -F. '{gsub(/[_-].*/, "", $0); print sprintf("%03d%03d%03d",$1,$2,$3)}')
102 verbose "# geninitrd $VERSION"
103 -debug "Using _lib: $_lib"
104 debug "Using initrd_dir: $initrd_dir"
106 busybox=$(find_tool $initrd_dir/busybox $initrd_dir/initrd-busybox /bin/initrd-busybox) || die "Couldn't find busybox suitable for initrd"
107 diff --git a/mod-multipath.sh b/mod-multipath.sh
108 index f918dd5..559eb55 100644
109 --- a/mod-multipath.sh
110 +++ b/mod-multipath.sh
111 @@ -112,13 +112,19 @@ initrd_gen_multipath() {
112 inst_exec /sbin/multipath /sbin
115 - local scsi_id=$(find_tool /$_lib/udev/scsi_id /lib/udev/scsi_id /sbin/scsi_id)
116 + local scsi_id=$(find_tool $(get_libdir /LIBDIR/udev/scsi_id) /lib/udev/scsi_id /sbin/scsi_id)
117 inst_exec $scsi_id /lib/udev
119 - if [ -d /$_lib/multipath ]; then
120 - inst_d /$_lib/multipath
121 - inst_exec /$_lib/multipath/* /$_lib/multipath
124 + for _lib in $(get_libdir LIBDIR); do
125 + if [ -d /$_lib/multipath ]; then
126 + inst_d /$_lib/multipath
127 + inst_exec /$_lib/multipath/* /$_lib/multipath
132 + if [ "$installed" -eq 0 ]; then
133 inst_exec /sbin/mpath* /sbin
136 diff --git a/mod-suspend.sh b/mod-suspend.sh
137 index 48efd57..c984e77 100644
140 @@ -13,7 +13,7 @@ setup_mod_suspend() {
141 warn "Tuxonice and mainline suspend are exclusive!"
144 - resume=$(find_tool $initrd_dir/resume /usr/${_lib}/suspend/resume /usr/sbin/resume)
145 + resume=$(find_tool $(get_libdir /usr/LIBDIR/suspend/resume) $initrd_dir/resume /usr/sbin/resume)
147 if [ ! -x "$resume" ] || [ ! -f /etc/suspend.conf ]; then
149 @@ -58,11 +58,7 @@ initrd_gen_suspend() {
150 inst $resume_dev $resume_dev
152 inst /etc/suspend.conf /etc/suspend.conf
153 - if [ -x /usr/${_lib}/suspend/resume ]; then
154 - inst_exec /usr/${_lib}/suspend/resume /bin/resume
156 - inst_exec /usr/sbin/resume /bin/resume
158 + inst_exec $resume /bin/resume
162 diff --git a/mod-udev.sh b/mod-udev.sh
163 index 147b070..30114cd 100644
166 @@ -58,6 +58,16 @@ initrd_gen_udev() {
172 + inst /etc/nsswitch.conf /etc/nsswitch.conf
173 + for _lib in $(get_libdir LIBDIR); do
174 + if (ls /$_lib/libnss_files*.so* > /dev/null 2>&1); then
175 + inst_exec /$_lib/libnss_files*.so* /$_lib/
178 + awk -F: ' { if ($3 < 1000) { print $1":"$2":"$3":" } } ' /etc/group > $DESTDIR/etc/group
180 # blkid installed by mod-blkid
181 if ! is_yes "$USE_BLKID"; then
182 warn "BLKID support missing"