Harald Hoyer d1bf89
From 9f88b0370dc9433b87686f67c1156f2080b35a1d Mon Sep 17 00:00:00 2001
Harald Hoyer d1bf89
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer d1bf89
Date: Mon, 18 Jun 2012 19:23:25 +0200
Harald Hoyer d1bf89
Subject: [PATCH] TEST-20-NFS: libnss cleanup
Harald Hoyer d1bf89
Harald Hoyer d1bf89
---
Harald Hoyer d1bf89
 test/TEST-20-NFS/test.sh |   75 +++++++++++++++++++++++++++++++++-------------
Harald Hoyer d1bf89
 1 file changed, 55 insertions(+), 20 deletions(-)
Harald Hoyer d1bf89
Harald Hoyer d1bf89
diff --git a/test/TEST-20-NFS/test.sh b/test/TEST-20-NFS/test.sh
Harald Hoyer d1bf89
index ea65c2a..faa2bb3 100755
Harald Hoyer d1bf89
--- a/test/TEST-20-NFS/test.sh
Harald Hoyer d1bf89
+++ b/test/TEST-20-NFS/test.sh
Harald Hoyer d1bf89
@@ -211,10 +211,37 @@ test_setup() {
Harald Hoyer d1bf89
     mkdir $TESTDIR/mnt
Harald Hoyer d1bf89
     sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
-    kernel=$KVERSION
Harald Hoyer d1bf89
-    (
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+    export kernel=$KVERSION
Harald Hoyer d1bf89
+    export srcmods="/lib/modules/$kernel/"
Harald Hoyer d1bf89
+    # Detect lib paths
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+    . $basedir/dracut-functions.sh
Harald Hoyer d1bf89
+    if ! [[ $libdirs ]] ; then
Harald Hoyer d1bf89
+	if strstr "$(ldd /bin/sh)" "/lib64/" &>/dev/null \
Harald Hoyer d1bf89
+            && [[ -d /lib64 ]]; then
Harald Hoyer d1bf89
+            libdirs+=" /lib64"
Harald Hoyer d1bf89
+            [[ -d /usr/lib64 ]] && libdirs+=" /usr/lib64"
Harald Hoyer d1bf89
+	else
Harald Hoyer d1bf89
+            libdirs+=" /lib"
Harald Hoyer d1bf89
+            [[ -d /usr/lib ]] && libdirs+=" /usr/lib"
Harald Hoyer d1bf89
+	fi
Harald Hoyer d1bf89
+    fi
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+   (
Harald Hoyer d1bf89
     	initdir=$TESTDIR/mnt
Harald Hoyer d1bf89
-	. $basedir/dracut-functions.sh
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+	for _f in modules.builtin.bin modules.builtin; do
Harald Hoyer d1bf89
+	    [[ $srcmods/$_f ]] && break
Harald Hoyer d1bf89
+	done || {
Harald Hoyer d1bf89
+	    dfatal "No modules.builtin.bin and modules.builtin found!"
Harald Hoyer d1bf89
+	    return 1
Harald Hoyer d1bf89
+	}
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+        for _f in modules.builtin.bin modules.builtin modules.order; do
Harald Hoyer d1bf89
+	    [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
Harald Hoyer d1bf89
+	done
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
 	dracut_install sh ls shutdown poweroff stty cat ps ln ip \
Harald Hoyer d1bf89
 	    dmesg mkdir cp ping exportfs \
Harald Hoyer d1bf89
 	    modprobe rpc.nfsd rpc.mountd showmount tcpdump \
Harald Hoyer d1bf89
@@ -235,26 +262,28 @@ test_setup() {
Harald Hoyer d1bf89
 	inst ./dhcpd.conf /etc/dhcpd.conf
Harald Hoyer d1bf89
 	dracut_install /etc/nsswitch.conf /etc/rpc /etc/protocols
Harald Hoyer d1bf89
 	dracut_install rpc.idmapd /etc/idmapd.conf
Harald Hoyer d1bf89
-	if ldd $(type -P rpc.idmapd) |grep -q lib64; then
Harald Hoyer d1bf89
-	    LIBDIR="/lib64"
Harald Hoyer d1bf89
-	else
Harald Hoyer d1bf89
-	    LIBDIR="/lib"
Harald Hoyer d1bf89
-	fi
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
-	dracut_install $(ls {/usr,}$LIBDIR/libnfsidmap*.so* 2>/dev/null )
Harald Hoyer d1bf89
-	dracut_install $(ls {/usr,}$LIBDIR/libnss*.so 2>/dev/null)
Harald Hoyer d1bf89
+	inst_libdir_file 'libnfsidmap_nsswitch.so*'
Harald Hoyer d1bf89
+	inst_libdir_file 'libnfsidmap/*.so*'
Harald Hoyer d1bf89
+	inst_libdir_file 'libnfsidmap*.so*'
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
Harald Hoyer d1bf89
+	    |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
Harald Hoyer d1bf89
+        _nsslibs=${_nsslibs#|}
Harald Hoyer d1bf89
+        _nsslibs=${_nsslibs%|}
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+	inst_libdir_file -n "$_nsslibs" 'libnss*.so*'
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
 	(
Harald Hoyer d1bf89
 	    cd "$initdir";
Harald Hoyer d1bf89
-	    mkdir -p dev sys proc etc var/run tmp var/lib/{dhcpd,rpcbind}
Harald Hoyer d1bf89
+	    mkdir -p dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
Harald Hoyer d1bf89
 	    mkdir -p var/lib/nfs/{v4recovery,rpc_pipefs}
Harald Hoyer d1bf89
 	    chmod 777 var/lib/rpcbind var/lib/nfs
Harald Hoyer d1bf89
 	)
Harald Hoyer d1bf89
 	inst /etc/nsswitch.conf /etc/nsswitch.conf
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
 	inst /etc/passwd /etc/passwd
Harald Hoyer d1bf89
 	inst /etc/group /etc/group
Harald Hoyer d1bf89
-	for i in /lib*/libnss_files**;do
Harald Hoyer d1bf89
-	    inst_library $i
Harald Hoyer d1bf89
-	done
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
 	/sbin/depmod -a -b "$initdir" $kernel
Harald Hoyer d1bf89
 	cp -a /etc/ld.so.conf* $initdir/etc
Harald Hoyer d1bf89
@@ -266,7 +295,6 @@ test_setup() {
Harald Hoyer d1bf89
     mkdir -p $initdir
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
     (
Harald Hoyer d1bf89
-	. $basedir/dracut-functions.sh
Harald Hoyer d1bf89
 	dracut_install sh shutdown poweroff stty cat ps ln ip \
Harald Hoyer d1bf89
             mount dmesg mkdir cp ping grep
Harald Hoyer d1bf89
         for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
Harald Hoyer d1bf89
@@ -276,15 +304,23 @@ test_setup() {
Harald Hoyer d1bf89
 	inst ./client-init.sh /sbin/init
Harald Hoyer d1bf89
 	(
Harald Hoyer d1bf89
 	    cd "$initdir"
Harald Hoyer d1bf89
-	    mkdir -p dev sys proc etc
Harald Hoyer d1bf89
+	    mkdir -p dev sys proc etc run
Harald Hoyer d1bf89
 	    mkdir -p var/lib/nfs/rpc_pipefs
Harald Hoyer d1bf89
 	)
Harald Hoyer d1bf89
 	inst /etc/nsswitch.conf /etc/nsswitch.conf
Harald Hoyer d1bf89
 	inst /etc/passwd /etc/passwd
Harald Hoyer d1bf89
 	inst /etc/group /etc/group
Harald Hoyer d1bf89
-	for i in /lib*/libnss_files*;do
Harald Hoyer d1bf89
-	    inst_library $i
Harald Hoyer d1bf89
-	done
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+	inst_libdir_file 'libnfsidmap_nsswitch.so*'
Harald Hoyer d1bf89
+	inst_libdir_file 'libnfsidmap/*.so*'
Harald Hoyer d1bf89
+	inst_libdir_file 'libnfsidmap*.so*'
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
Harald Hoyer d1bf89
+	    |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
Harald Hoyer d1bf89
+        _nsslibs=${_nsslibs#|}
Harald Hoyer d1bf89
+        _nsslibs=${_nsslibs%|}
Harald Hoyer d1bf89
+
Harald Hoyer d1bf89
+	inst_libdir_file -n "$_nsslibs" 'libnss*.so*'
Harald Hoyer d1bf89
 
Harald Hoyer d1bf89
 	cp -a /etc/ld.so.conf* $initdir/etc
Harald Hoyer d1bf89
 	sudo ldconfig -r "$initdir"
Harald Hoyer d1bf89
@@ -301,7 +337,6 @@ test_setup() {
Harald Hoyer d1bf89
     (
Harald Hoyer d1bf89
 	initdir=$TESTDIR/overlay
Harald Hoyer d1bf89
 	mkdir $TESTDIR/overlay
Harald Hoyer d1bf89
-	. $basedir/dracut-functions.sh
Harald Hoyer d1bf89
 	dracut_install poweroff shutdown
Harald Hoyer d1bf89
 	inst_hook emergency 000 ./hard-off.sh
Harald Hoyer d1bf89
 	inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules