Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up scripts with shellcheck #77376

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
set -x
Expand Down Expand Up @@ -85,7 +85,7 @@ cd gcc-$GCC
# These patches probably only need to be updated in case the gcc version is
# updated.

patch -p0 < $PATCH_TOOLCHAIN
patch -p0 < "$PATCH_TOOLCHAIN"

./contrib/download_prerequisites

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ set -ex

ARCH=$1

TOP=$(pwd)
TOP="$(pwd)"

BUILDTOOLS=$TOP/buildtools
HAIKU=$TOP/haiku
BUILDTOOLS="$TOP/buildtools"
HAIKU="$TOP/haiku"
OUTPUT=/tools
SYSROOT=$OUTPUT/cross-tools-$ARCH/sysroot
SYSROOT="$OUTPUT/cross-tools-$ARCH/sysroot"
PACKAGE_ROOT=/system

hide_output() {
Expand All @@ -22,7 +22,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
set -x
Expand All @@ -31,35 +31,35 @@ exit 1
# First up, build a cross-compiler
git clone --depth=1 https://git.haiku-os.org/haiku
git clone --depth=1 https://git.haiku-os.org/buildtools
cd $BUILDTOOLS/jam
cd "$BUILDTOOLS/jam"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, don't you also need to change lines 7 and 9 for this to do anything?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pta2002, you marked this as resolved but didn't change the lines. If they don't need to be changed, can you explain why?

hide_output make
hide_output ./jam0 install
mkdir -p $OUTPUT
cd $OUTPUT
hide_output $HAIKU/configure --build-cross-tools $ARCH $TOP/buildtools
mkdir -p "$OUTPUT"
cd "$OUTPUT"
hide_output "$HAIKU/configure" --build-cross-tools "$ARCH" "$TOP/buildtools"

# Set up sysroot to redirect to /system
mkdir -p $SYSROOT/boot
mkdir -p $PACKAGE_ROOT
ln -s $PACKAGE_ROOT $SYSROOT/boot/system
mkdir -p "$SYSROOT/boot"
mkdir -p "$PACKAGE_ROOT"
ln -s "$PACKAGE_ROOT" "$SYSROOT/boot/system"

# Build needed packages and tools for the cross-compiler
hide_output jam -q haiku.hpkg haiku_devel.hpkg '<build>package'

# Set up our sysroot
cp $OUTPUT/objects/linux/lib/*.so /lib/x86_64-linux-gnu
cp $OUTPUT/objects/linux/x86_64/release/tools/package/package /bin/
find $SYSROOT/../bin/ -type f -exec ln -s {} /bin/ \;
find "$SYSROOT/../bin/" -type f -exec ln -s {} /bin/ \;

# Extract packages
package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/$ARCH/packaging/packages/haiku.hpkg
package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/$ARCH/packaging/packages/haiku_devel.hpkg
package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/"$ARCH"/packaging/packages/haiku.hpkg
package extract -C $PACKAGE_ROOT $OUTPUT/objects/haiku/"$ARCH"/packaging/packages/haiku_devel.hpkg
find $OUTPUT/download/ -name '*.hpkg' -exec package extract -C $PACKAGE_ROOT {} \;

# Fix libgcc_s so we can link to it
cd $PACKAGE_ROOT/develop/lib
ln -s ../../lib/libgcc_s.so libgcc_s.so

# Clean up
rm -rf $BUILDTOOLS $HAIKU $OUTPUT/Jamfile $OUTPUT/attributes $OUTPUT/build \
$OUTPUT/build_packages $OUTPUT/download $OUTPUT/objects
rm -rf "$BUILDTOOLS" "$HAIKU" "$OUTPUT"/Jamfile "$OUTPUT"/attributes "$OUTPUT"/build \
"$OUTPUT"/build_packages "$OUTPUT"/download "$OUTPUT"/objects
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ wget http://packages.haiku-os.org/haikuports/master/hpkg/llvm_libs-4.0.1-2-x86_6
package extract -C /system llvm-4.0.1-2-x86_64.hpkg
package extract -C /system llvm_libs-4.0.1-2-x86_64.hpkg

rm -f *.hpkg
rm -f -- *.hpkg
20 changes: 10 additions & 10 deletions src/ci/docker/host-x86_64/disabled/dist-x86_64-haiku/llvm-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@

case $1 in
--version) echo 4.0.1;;
--prefix) echo $SCRATCH/haiku-cross/sysroot/boot/system;;
--bindir) echo $SCRATCH/haiku-cross/sysroot/boot/system/bin;;
--includedir) echo $SCRATCH/haiku-cross/sysroot/boot/system/develop/headers;;
--libdir) echo $SCRATCH/haiku-/cross/sysroot/boot/system/develop/lib;;
--cmakedir) echo $SCRATCH/haiku-/cross/sysroot/boot/system/develop/lib/cmake/llvm;;
--cppflags) echo -I$SCRATCH/haiku-/cross/sysroot/boot/system/develop/headers \
--prefix) echo "$SCRATCH"/haiku-cross/sysroot/boot/system;;
--bindir) echo "$SCRATCH"/haiku-cross/sysroot/boot/system/bin;;
--includedir) echo "$SCRATCH"/haiku-cross/sysroot/boot/system/develop/headers;;
--libdir) echo "$SCRATCH"/haiku-/cross/sysroot/boot/system/develop/lib;;
--cmakedir) echo "$SCRATCH"/haiku-/cross/sysroot/boot/system/develop/lib/cmake/llvm;;
--cppflags) echo -I"$SCRATCH"/haiku-/cross/sysroot/boot/system/develop/headers \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS;;
--cflags) echo -I$SCRATCH/haiku-cross/sysroot/boot/system/develop/headers \
--cflags) echo -I"$SCRATCH"/haiku-cross/sysroot/boot/system/develop/headers \
-fPIC -Wall -W -Wno-unused-parameter -Wwrite-strings \
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wno-comment \
-Werror=date-time -ffunction-sections -fdata-sections -O3 -DNDEBUG \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS;;
--cxxflags) echo -I/$SCRATCH/haiku-cross/sysroot/boot/system/develop/headers \
--cxxflags) echo -I/"$SCRATCH"/haiku-cross/sysroot/boot/system/develop/headers \
-fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter \
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic \
-Wno-long-long -Wno-maybe-uninitialized -Wdelete-non-virtual-dtor \
-Wno-comment -Werror=date-time -std=c++11 -ffunction-sections \
-fdata-sections -O3 -DNDEBUG -fno-exceptions \
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS;;
--ldflags) echo -L$SCRATCH/haiku-cross/sysroot/boot/system/develop/lib ;;
--ldflags) echo -L"$SCRATCH"/haiku-cross/sysroot/boot/system/develop/lib ;;
--system-libs) echo ;;
--libs) echo -lLLVM-4.0;;
--libfiles) echo $SCRATCH/haiku-cross/sysroot/boot/system/develop/lib/libLLVM-4.0.so;;
--libfiles) echo "$SCRATCH"/haiku-cross/sysroot/boot/system/develop/lib/libLLVM-4.0.so;;
--components) echo aarch64 aarch64asmparser aarch64asmprinter aarch64codegen \
aarch64desc aarch64disassembler aarch64info aarch64utils all \
all-targets amdgpu amdgpuasmparser amdgpuasmprinter amdgpucodegen \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
rm /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
rm /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
rm /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
rm /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
rm /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-powerpc64-linux/shared.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
hide_output() {
set +x
on_err="
Expand All @@ -8,7 +9,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
set -x
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-powerpc64le-linux/shared.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
hide_output() {
set +x
on_err="
Expand All @@ -8,7 +9,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
set -x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
rm /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
set -ex

# Mirrored from https://github.com/crosstool-ng/crosstool-ng/archive/crosstool-ng-1.24.0.tar.gz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
rm /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
Expand Down
2 changes: 1 addition & 1 deletion src/ci/docker/host-x86_64/dist-various-1/build-rumprun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exit 1
trap "$on_err" ERR
bash -c "while true; do sleep 30; echo \$(date) - building ...; done" &
PING_LOOP_PID=$!
$@ &> /tmp/build.log
"$@" &> /tmp/build.log
trap - ERR
kill $PING_LOOP_PID
rm /tmp/build.log
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
set -ex

mkdir /usr/local/mips-linux-musl
Expand All @@ -10,5 +11,5 @@ FILE="OpenWrt-Toolchain-ar71xx-generic_gcc-5.3.0_musl-1.1.16.Linux-x86_64.tar.bz
curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mips-linux-musl --strip-components=2

for file in /usr/local/mips-linux-musl/bin/mips-openwrt-linux-*; do
ln -s $file /usr/local/bin/`basename $file`
ln -s "$file" /usr/local/bin/"$(basename "$file")"
done
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
set -ex

mkdir /usr/local/mipsel-linux-musl
Expand All @@ -10,5 +11,5 @@ FILE="OpenWrt-Toolchain-malta-le_gcc-5.3.0_musl-1.1.15.Linux-x86_64.tar.bz2"
curl -L "$URL/$FILE" | tar xjf - -C /usr/local/mipsel-linux-musl --strip-components=2

for file in /usr/local/mipsel-linux-musl/bin/mipsel-openwrt-linux-*; do
ln -s $file /usr/local/bin/`basename $file`
ln -s "$file" /usr/local/bin/"$(basename "$file")"
done
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ apt-get install -y --no-install-recommends \
# Based on the steps described at https://nuxi.nl/cloudabi/debian/
target=$1
for tool in ar nm objdump ranlib size; do
ln -s ../lib/llvm-5.0/bin/llvm-${tool} /usr/bin/${target}-${tool}
ln -s ../lib/llvm-5.0/bin/llvm-"${tool}" /usr/bin/"${target}-${tool}"
done
ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-cc
ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-c++
ln -s ../lib/llvm-5.0/bin/lld /usr/bin/${target}-ld
ln -s ../../${target} /usr/lib/llvm-5.0/${target}
ln -s ../lib/llvm-5.0/bin/clang /usr/bin/"${target}"-cc
ln -s ../lib/llvm-5.0/bin/clang /usr/bin/"${target}"-c++
ln -s ../lib/llvm-5.0/bin/lld /usr/bin/"${target}"-ld
ln -s ../../"${target}" /usr/lib/llvm-5.0/"${target}"

# Install the C++ runtime libraries from CloudABI Ports.
apt-key adv --batch --yes --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DA51B8531344B15
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ build() {
aarch64) tgt="zircon-qemu-arm64" ;;
esac

hide_output make -j$(getconf _NPROCESSORS_ONLN) $tgt
dst=/usr/local/${arch}-fuchsia
mkdir -p $dst
cp -a build-${tgt}/sysroot/include $dst/
cp -a build-${tgt}/sysroot/lib $dst/
hide_output make "-j$(getconf _NPROCESSORS_ONLN)" $tgt
dst="/usr/local/${arch}-fuchsia"
mkdir -p "$dst"
cp -a "build-${tgt}/sysroot/include" "$dst/"
cp -a "build-${tgt}/sysroot/lib" "$dst/"
}

# Build sysroot
Expand Down
44 changes: 22 additions & 22 deletions src/ci/docker/host-x86_64/dist-various-2/build-solaris-toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cd binutils
curl https://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS.tar.xz | tar xJf -
mkdir binutils-build
cd binutils-build
hide_output ../binutils-$BINUTILS/configure --target=$ARCH-sun-solaris2.10
hide_output ../binutils-$BINUTILS/configure --target="$ARCH"-sun-solaris2.10
hide_output make -j10
hide_output make install

Expand All @@ -27,21 +27,21 @@ rm -rf binutils
mkdir solaris
cd solaris

dpkg --add-architecture $APT_ARCH
dpkg --add-architecture "$APT_ARCH"
apt-get update
apt-get download $(apt-cache depends --recurse --no-replaces \
libc-dev:$APT_ARCH \
libm-dev:$APT_ARCH \
libpthread-dev:$APT_ARCH \
libresolv-dev:$APT_ARCH \
librt-dev:$APT_ARCH \
libsocket-dev:$APT_ARCH \
system-crt:$APT_ARCH \
system-header:$APT_ARCH \
| grep "^\w")

for deb in *$APT_ARCH.deb; do
dpkg -x $deb .
apt-get download "$(apt-cache depends --recurse --no-replaces \
libc-dev:"$APT_ARCH" \
libm-dev:"$APT_ARCH" \
libpthread-dev:"$APT_ARCH" \
libresolv-dev:"$APT_ARCH" \
librt-dev:"$APT_ARCH" \
libsocket-dev:"$APT_ARCH" \
system-crt:"$APT_ARCH" \
system-header:"$APT_ARCH" \
| grep "^\w")"

for deb in *"$APT_ARCH".deb; do
dpkg -x "$deb" .
done

# Remove Solaris 11 functions that are optionally used by libbacktrace.
Expand All @@ -54,13 +54,13 @@ patch -p0 << 'EOF'
-extern size_t strnlen(const char *, size_t);
EOF

mkdir /usr/local/$ARCH-sun-solaris2.10/usr
mv usr/include /usr/local/$ARCH-sun-solaris2.10/usr/include
mv usr/lib/$LIB_ARCH/* /usr/local/$ARCH-sun-solaris2.10/lib
mv lib/$LIB_ARCH/* /usr/local/$ARCH-sun-solaris2.10/lib
mkdir /usr/local/"$ARCH"-sun-solaris2.10/usr
mv usr/include /usr/local/"$ARCH"-sun-solaris2.10/usr/include
mv usr/lib/"$LIB_ARCH"/* /usr/local/"$ARCH"-sun-solaris2.10/lib
mv lib/"$LIB_ARCH"/* /usr/local/"$ARCH"-sun-solaris2.10/lib

ln -s usr/include /usr/local/$ARCH-sun-solaris2.10/sys-include
ln -s usr/include /usr/local/$ARCH-sun-solaris2.10/include
ln -s usr/include /usr/local/"$ARCH"-sun-solaris2.10/sys-include
ln -s usr/include /usr/local/"$ARCH"-sun-solaris2.10/include

cd ..
rm -rf solaris
Expand All @@ -76,7 +76,7 @@ mkdir ../gcc-build
cd ../gcc-build
hide_output ../gcc-$GCC/configure \
--enable-languages=c,c++ \
--target=$ARCH-sun-solaris2.10 \
--target="$ARCH"-sun-solaris2.10 \
--with-gnu-as \
--with-gnu-ld \
--disable-multilib \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ set -ex
# Originally from https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
curl https://ci-mirrors.rust-lang.org/rustc/clang%2Bllvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz | \
tar xJf -
export PATH=`pwd`/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin:$PATH
export PATH="$(pwd)/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin:$PATH"

git clone https://github.com/WebAssembly/wasi-libc

cd wasi-libc
git reset --hard 215adc8ac9f91eb055311acc72683fd2eb1ae15a
make -j$(nproc) INSTALL_DIR=/wasm32-wasi install
make -j"$(nproc)" INSTALL_DIR=/wasm32-wasi install

cd ..
rm -rf wasi-libc
Expand Down
Loading