applets/install: respect noclobber for script wrappers too
authorYann E. MORIN <yann.morin.1998@free.fr>
Thu, 28 Dec 2017 22:49:47 +0000 (23:49 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 4 Jan 2018 13:36:17 +0000 (14:36 +0100)
Simplify the handling of --noclobber so that it applies to all types of
installation types, even to script wrappers.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
applets/install.sh

index f6c097e57e9b1527eee68bef96b7ec1a723932c4..4b70df96e227fa05be73830843fbb896b8013c44 100755 (executable)
@@ -77,6 +77,10 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1
 for i in $h; do
        appdir=`dirname "$i"`
        app=`basename "$i"`
+       if [ "$noclobber" = "1" ] && [ -e "$prefix/$i" ]; then
+               echo "  $prefix/$i already exists"
+               continue
+       fi
        mkdir -p "$prefix/$appdir" || exit 1
        if [ "$scriptwrapper" = "y" ]; then
                if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then
@@ -90,12 +94,8 @@ for i in $h; do
        elif [ "$binaries" = "y" ]; then
                # Copy the binary over rather
                if [ -e $sharedlib_dir/$app ]; then
-                       if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
-                               echo "   Copying $sharedlib_dir/$app to $prefix/$i"
-                               cp -pPR $sharedlib_dir/$app $prefix/$i || exit 1
-                       else
-                               echo "  $prefix/$i already exists"
-                       fi
+                       echo "   Copying $sharedlib_dir/$app to $prefix/$i"
+                       cp -pPR $sharedlib_dir/$app $prefix/$i || exit 1
                else
                        echo "Error: Could not find $sharedlib_dir/$app"
                        exit 1
@@ -123,12 +123,8 @@ for i in $h; do
                        ;;
                        esac
                fi
-               if [ "$noclobber" = "0" ] || [ ! -e "$prefix/$i" ]; then
-                       echo "  $prefix/$i -> $bb_path"
-                       ln $linkopts "$bb_path" "$prefix/$i" || exit 1
-               else
-                       echo "  $prefix/$i already exists"
-               fi
+               echo "  $prefix/$i -> $bb_path"
+               ln $linkopts "$bb_path" "$prefix/$i" || exit 1
        fi
 done