Toolchain: Fix expansion bugs and make BuildIt.sh shellcheck compliant

BuildIt.sh had a bunch of SC2086 errors, where we were not quoting
variables in variable expansions. The logic being:

    Quoting variables prevents word splitting and glob expansion,
    and prevents the script from breaking when input contains spaces,
    line feeds, glob characters and such.

    Reference: https://github.com/koalaman/shellcheck/wiki/SC2086

As bcoles noticed in #6772, shellcheck actually found a real bug here,
where the user's build directory included spaces.

Close: #6772
This commit is contained in:
Brian Gianforcaro 2021-05-04 21:46:18 -07:00 committed by Andreas Kling
parent f558a44610
commit 8b856bd5a1
Notes: sideshowbarker 2024-07-18 18:40:36 +09:00

View file

@ -258,8 +258,8 @@ pushd "$DIR/Build/$ARCH"
perl -pi -e 's/-no-pie/-nopie/g' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/configure"
fi
if [ ! -f $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-userland.h ]; then
cp $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h
if [ ! -f "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-userland.h" ]; then
cp "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h" "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h"
fi
for STAGE in Userland Kernel; do
@ -277,9 +277,9 @@ pushd "$DIR/Build/$ARCH"
REALTARGET="$PREFIX/Kernel"
fi
cp $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h
cp "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity-kernel.h" "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h"
if [ "$STAGE" = "Userland" ]; then
sed -i='' 's@-fno-exceptions @@' $DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h
sed -i='' 's@-fno-exceptions @@' "$DIR/Tarballs/gcc-$GCC_VERSION/gcc/config/serenity.h"
fi
buildstep "gcc/configure/${STAGE,,}" "$DIR/Tarballs/gcc-$GCC_VERSION/configure" --prefix="$PREFIX" \
@ -302,16 +302,16 @@ pushd "$DIR/Build/$ARCH"
fi
buildstep "libgcc/build" "$MAKE" -j "$MAKEJOBS" all-target-libgcc || exit 1
echo "XXX install gcc and libgcc"
buildstep "gcc+libgcc/install" "$MAKE" DESTDIR=$TEMPTARGET install-gcc install-target-libgcc || exit 1
buildstep "gcc+libgcc/install" "$MAKE" DESTDIR="$TEMPTARGET" install-gcc install-target-libgcc || exit 1
fi
echo "XXX build libstdc++"
buildstep "libstdc++/build/${STAGE,,}" "$MAKE" -j "$MAKEJOBS" all-target-libstdc++-v3 || exit 1
echo "XXX install libstdc++"
buildstep "libstdc++/install/${STAGE,,}" "$MAKE" DESTDIR=$TEMPTARGET install-target-libstdc++-v3 || exit 1
buildstep "libstdc++/install/${STAGE,,}" "$MAKE" DESTDIR="$TEMPTARGET" install-target-libstdc++-v3 || exit 1
mkdir -p "$REALTARGET"
cp -a $TEMPTARGET/$PREFIX/* "$REALTARGET/"
cp -a "$TEMPTARGET"/"$PREFIX"/* "$REALTARGET/"
rm -rf "$TEMPTARGET"
popd