Fix install with hardlinks and a custom PREFIX. Closes 10801

Trying to install busybox with hardlinks and a custom PREFIX will fail
for applets not in the /bin directory, because relative pathnames are
used. applets/install.sh is *supposed to* use the absolute pathname
for hardlinks but it fails to do so because the wrong check is used
in the if statement.

While fixing it, shore up other sloppy coding in applets/install.sh

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2018-02-23 16:29:26 +01:00
parent 3177626033
commit bf39d97e9d

View File

@ -38,7 +38,7 @@ while [ ${#} -gt 0 ]; do
shift shift
done done
if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then if [ -n "$DO_INSTALL_LIBS" ] && [ x"$DO_INSTALL_LIBS" != x"n" ]; then
# get the target dir for the libs # get the target dir for the libs
# assume it starts with lib # assume it starts with lib
libdir=$($CC -print-file-name=libc.so | \ libdir=$($CC -print-file-name=libc.so | \
@ -58,7 +58,7 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
done done
fi fi
if [ "$cleanup" = "1" ] && [ -e "$prefix/bin/busybox" ]; then if [ x"$cleanup" = x"1" ] && [ -e "$prefix/bin/busybox" ]; then
inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'` inode=`ls -i "$prefix/bin/busybox" | awk '{print $1}'`
sub_shell_it=` sub_shell_it=`
cd "$prefix" cd "$prefix"
@ -81,13 +81,13 @@ install -m 755 busybox "$prefix/bin/busybox" || exit 1
for i in $h; do for i in $h; do
appdir=`dirname "$i"` appdir=`dirname "$i"`
app=`basename "$i"` app=`basename "$i"`
if [ "$noclobber" = "1" ] && [ -e "$prefix/$i" ]; then if [ x"$noclobber" = x"1" ] && [ -e "$prefix/$i" ]; then
echo " $prefix/$i already exists" echo " $prefix/$i already exists"
continue continue
fi fi
mkdir -p "$prefix/$appdir" || exit 1 mkdir -p "$prefix/$appdir" || exit 1
if [ "$scriptwrapper" = "y" ]; then if [ x"$scriptwrapper" = x"y" ]; then
if [ "$swrapall" != "y" ] && [ "$i" = "/bin/sh" ]; then if [ x"$swrapall" != x"y" ] && [ x"$i" = x"/bin/sh" ]; then
ln $linkopts busybox "$prefix/$i" || exit 1 ln $linkopts busybox "$prefix/$i" || exit 1
else else
rm -f "$prefix/$i" rm -f "$prefix/$i"
@ -95,17 +95,17 @@ for i in $h; do
chmod +x "$prefix/$i" chmod +x "$prefix/$i"
fi fi
echo " $prefix/$i" echo " $prefix/$i"
elif [ "$binaries" = "y" ]; then elif [ x"$binaries" = x"y" ]; then
# Copy the binary over rather # Copy the binary over rather
if [ -e $sharedlib_dir/$app ]; then if [ -e "$sharedlib_dir/$app" ]; then
echo " Copying $sharedlib_dir/$app to $prefix/$i" echo " Copying $sharedlib_dir/$app to $prefix/$i"
cp -pPR $sharedlib_dir/$app $prefix/$i || exit 1 cp -pPR "$sharedlib_dir/$app" "$prefix/$i" || exit 1
else else
echo "Error: Could not find $sharedlib_dir/$app" echo "Error: Could not find $sharedlib_dir/$app"
exit 1 exit 1
fi fi
else else
if [ "$2" = "--hardlinks" ]; then if [ x"$linkopts" = x"-f" ]; then
bb_path="$prefix/bin/busybox" bb_path="$prefix/bin/busybox"
else else
case "$appdir" in case "$appdir" in