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
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
# assume it starts with lib
libdir=$($CC -print-file-name=libc.so | \
@ -58,7 +58,7 @@ if [ -n "$DO_INSTALL_LIBS" ] && [ "$DO_INSTALL_LIBS" != "n" ]; then
done
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}'`
sub_shell_it=`
cd "$prefix"
@ -81,13 +81,13 @@ 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
if [ x"$noclobber" = x"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
if [ x"$scriptwrapper" = x"y" ]; then
if [ x"$swrapall" != x"y" ] && [ x"$i" = x"/bin/sh" ]; then
ln $linkopts busybox "$prefix/$i" || exit 1
else
rm -f "$prefix/$i"
@ -95,17 +95,17 @@ for i in $h; do
chmod +x "$prefix/$i"
fi
echo " $prefix/$i"
elif [ "$binaries" = "y" ]; then
elif [ x"$binaries" = x"y" ]; then
# 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"
cp -pPR $sharedlib_dir/$app $prefix/$i || exit 1
cp -pPR "$sharedlib_dir/$app" "$prefix/$i" || exit 1
else
echo "Error: Could not find $sharedlib_dir/$app"
exit 1
fi
else
if [ "$2" = "--hardlinks" ]; then
if [ x"$linkopts" = x"-f" ]; then
bb_path="$prefix/bin/busybox"
else
case "$appdir" in