summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2018-02-17 09:57:35 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2018-02-17 09:57:35 +0100
commitf196c39e26f58a561f5c127cba0734f488612c5c (patch)
tree045da57395e4e1b4f71379c7fe78d3f18baa2684
parentafcf6e9a9d006a2697c92b1069af97708a281a36 (diff)
downloadbootstrap32-f196c39e26f58a561f5c127cba0734f488612c5c.tar.xz
fixed all shellcheck bugs
-rwxr-xr-xbuild_cross.sh1
-rwxr-xr-xbuild_stage1.sh1
-rwxr-xr-xbuild_stage1_package.sh25
-rwxr-xr-xcompute_dependencies.sh28
-rwxr-xr-xcreate_ca-certificates-utils_shim.sh2
-rwxr-xr-xcreate_cdrom.sh5
-rwxr-xr-xcreate_gcc-lib_shim.sh2
-rwxr-xr-xcreate_glibc_shim.sh16
-rwxr-xr-xcreate_hdd.sh9
-rwxr-xr-xinstall_host.sh1
-rwxr-xr-xprepare_stage1_repo.sh1
11 files changed, 61 insertions, 30 deletions
diff --git a/build_cross.sh b/build_cross.sh
index 790dbb8..e573e3e 100755
--- a/build_cross.sh
+++ b/build_cross.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# Prepare the cross-compiler for the destination platform, in our
diff --git a/build_stage1.sh b/build_stage1.sh
index 098054f..2f9606a 100755
--- a/build_stage1.sh
+++ b/build_stage1.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# build all packages for stage 1 using the cross-compiler
diff --git a/build_stage1_package.sh b/build_stage1_package.sh
index 18ca632..53cfae9 100755
--- a/build_stage1_package.sh
+++ b/build_stage1_package.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# builds and installs one package for stage 1
@@ -19,7 +20,7 @@ export PATH="$XTOOLS_ARCH/bin:${PATH}"
. "$SCRIPT_DIR/$TARGET_CPU-stage1/template/DESCR"
-if test $(pacman --config "$STAGE1_CHROOT/etc/pacman.conf" -r "$STAGE1_CHROOT" -Q | cut -f 1 -d ' ' | grep -c "^${PACKAGE}$") = 0 -o $(find $STAGE1_PACKAGES/$PACKAGE-*pkg.tar.xz 2>/dev/null | grep -v shim | wc -l) = 0; then
+if test "$(pacman --config "$STAGE1_CHROOT/etc/pacman.conf" -r "$STAGE1_CHROOT" -Q | cut -f 1 -d ' ' | grep -c "^${PACKAGE}$")" = 0 -o "$(find "$STAGE1_PACKAGES" -regex ".*/$PACKAGE-.*pkg\\.tar\\.xz" | grep -cv shim)" = 0; then
echo "Building package $PACKAGE."
cd $STAGE1_BUILD || exit 1
@@ -27,16 +28,16 @@ if test $(pacman --config "$STAGE1_CHROOT/etc/pacman.conf" -r "$STAGE1_CHROOT" -
# clean up old build
sudo rm -rf "$PACKAGE"
- rm -f $STAGE1_PACKAGES/$PACKAGE-*pkg.tar.xz
+ rm -f "$STAGE1_PACKAGES/$PACKAGE"-*pkg.tar.xz
# check out the package build information from the upstream git rep
# using asp (or from the AUR using yaourt)
PACKAGE_DIR="$SCRIPT_DIR/$TARGET_CPU-stage1/$PACKAGE"
PACKAGE_CONF="$PACKAGE_DIR/DESCR"
- if test -f $PACKAGE_CONF; then
- if test $(grep -c FETCH_METHOD $PACKAGE_CONF) = 1; then
- FETCH_METHOD=$(grep FETCH_METHOD $PACKAGE_CONF | cut -f 2 -d = | tr -d '"')
+ if test -f "$PACKAGE_CONF"; then
+ if test "$(grep -c FETCH_METHOD "$PACKAGE_CONF")" = 1; then
+ FETCH_METHOD=$(grep FETCH_METHOD "$PACKAGE_CONF" | cut -f 2 -d = | tr -d '"')
fi
fi
case $FETCH_METHOD in
@@ -48,10 +49,10 @@ if test $(pacman --config "$STAGE1_CHROOT/etc/pacman.conf" -r "$STAGE1_CHROOT" -
;;
"packages32")
# (we assume, we only take core packages)
- cp -a $ARCHLINUX32_PACKAGES/core/$PACKAGE .
+ cp -a "$ARCHLINUX32_PACKAGES/core/$PACKAGE" .
;;
*)
- print "ERROR: unknown FETCH_METHOD '$FETCH_METHOD'.." >2
+ print "ERROR: unknown FETCH_METHOD '$FETCH_METHOD'.." >&2
exit 1
esac
@@ -70,7 +71,7 @@ if test $(pacman --config "$STAGE1_CHROOT/etc/pacman.conf" -r "$STAGE1_CHROOT" -
# copy all other files from Archlinux32, if they exist
# (we assume, we only take core packages during stage1)
if test -f "$DIFF_PKGBUILD"; then
- find $ARCHLINUX32_PACKAGES/core/$PACKAGE/* ! -name PKGBUILD \
+ find "$ARCHLINUX32_PACKAGES/core/$PACKAGE"/* ! -name PKGBUILD \
-exec cp {} . \;
fi
@@ -82,8 +83,8 @@ if test $(pacman --config "$STAGE1_CHROOT/etc/pacman.conf" -r "$STAGE1_CHROOT" -
fi
# copy all files into the build area (but the package DESCR file)
- if test -d $PACKAGE_DIR; then
- find $PACKAGE_DIR/* ! -name DESCR \
+ if test -d "$PACKAGE_DIR"; then
+ find "$PACKAGE_DIR"/* ! -name DESCR \
-exec cp {} . \;
fi
@@ -130,9 +131,9 @@ if test $(pacman --config "$STAGE1_CHROOT/etc/pacman.conf" -r "$STAGE1_CHROOT" -
if test "$SYSROOT_INSTALL" = 1; then
cd "$XTOOLS_ARCH/$TARGET_CPU-unknown-linux-gnu/sysroot" || exit 1
- sudo bsdtar xf $STAGE1_CHROOT/packages/$TARGET_CPU/$PACKAGE-*.pkg.tar.xz
+ sudo bsdtar xf "$STAGE1_CHROOT/packages/$TARGET_CPU/$PACKAGE"-*.pkg.tar.xz
if test "x$ADDITIONAL_INSTALL_PACKAGE" != "x"; then
- sudo bsdtar xf $STAGE1_CHROOT/packages/$TARGET_CPU/$ADDITIONAL_INSTALL_PACKAGE-*.pkg.tar.xz
+ sudo bsdtar xf "$STAGE1_CHROOT/packages/$TARGET_CPU/$ADDITIONAL_INSTALL_PACKAGE"-*.pkg.tar.xz
fi
cd "$STAGE1_BUILD/$PACKAGE" || exit 1
fi
diff --git a/compute_dependencies.sh b/compute_dependencies.sh
index b9a5fd6..5d52145 100755
--- a/compute_dependencies.sh
+++ b/compute_dependencies.sh
@@ -1,5 +1,6 @@
#!/bin/bash
+# shellcheck source=./default.conf
. "./default.conf"
# Compute dependencies and make-dependencies to build packages in stage1,
@@ -21,7 +22,11 @@ ALL_PACKAGES=$(cat ${tmp_dir}/dependencies | sort | uniq)
export CARCH='x86_64'
-for package in $ALL_PACKAGES; do
+get_dependencies( )
+{
+ package=$1
+ mode=$2
+
asp show $package >${tmp_dir}/$package.PKGBUILD
# temporary hotfix for FS#57524
if test "$(head -n1 ${tmp_dir}/$package.PKGBUILD | grep -c '^\$Id\$$' )" == 1; then
@@ -34,18 +39,29 @@ for package in $ALL_PACKAGES; do
ADD_PACKAGE=$(echo $_tmp | rev | cut -f 1 -d ' ' | rev)
# TODO: we should map sub packages to packages everywhere
echo "WARN: seen a redirect from $SUB_PACKAGE to $ADD_PACKAGE" >&2
- continue
+ return
fi
- depends=$(. ${tmp_dir}/$package.PKGBUILD; echo "${depends[@]}")
- makedepends=$(. ${tmp_dir}/$package.PKGBUILD; echo "${makedepends[@]}")
+ _depends=$(. ${tmp_dir}/$package.PKGBUILD; echo "${depends[@]}")
+ for subpackage in "${_depends[@]}"; do
+ get_dependencies "$subpackage" "$mode"
+ done
+ depends+=( "${_depends[@]}" )
+ #makedepends=$(. ${tmp_dir}/$package.PKGBUILD; echo "${makedepends[@]}")
# TODO handle version constraints
#checkdepends=$(. ${tmp_dir}/$package.PKGBUILD; echo "${checkdepends[@]}")
#echo $package
#printf "\tdepends: $depends\n"
#printf "\tmakedepends: $makedepends\n"
#printf "\tcheckdepends: $checkdepends\n"
-# echo "${depends[@]}"
- echo "${makedepends[@]}"
+ #echo "${depends[@]}"
+ #echo "${makedepends[@]}"
+}
+
+for package in $ALL_PACKAGES; do
+ unset depends
+ declare -a depends
+ get_dependencies "$package" "depends"
+ echo "$package" "${depends[@]}"
done
# ./compute_dependencies.sh | tr -s ' ' '\n' | sort | uniq > depends
diff --git a/create_ca-certificates-utils_shim.sh b/create_ca-certificates-utils_shim.sh
index 7f5e8bf..01f75c5 100755
--- a/create_ca-certificates-utils_shim.sh
+++ b/create_ca-certificates-utils_shim.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# the ca-certificates-utils-shim shim
@@ -28,6 +29,7 @@ arch = any
EOF
cd pkg/ca-certificates-utils-shim || exit 1
+ # shellcheck disable=SC2035
tar cJvf - .PKGINFO * | xz > ../../ca-certificates-utils-shim-20170307-1-any.pkg.tar.xz
cd ../.. || exit 1
diff --git a/create_cdrom.sh b/create_cdrom.sh
index 79164b1..d2330bb 100755
--- a/create_cdrom.sh
+++ b/create_cdrom.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# builds a small ISO image for installing a stage 1 system:
@@ -11,7 +12,7 @@ sudo rm -rf $STAGE1_ISOLINUX
mkdir $STAGE1_ISOLINUX
sudo cp -a $STAGE1_CHROOT/* $STAGE1_ISOLINUX/.
sudo chown -R cross:cross $STAGE1_ISOLINUX/.
-cd $STAGE1_ISOLINUX
+cd $STAGE1_ISOLINUX || exit 1
# simple ISOlinux menu, with options for fast choosing a root device
mkdir boot/isolinux
@@ -59,5 +60,5 @@ sudo cp /usr/lib/syslinux/bios/isolinux.bin boot/isolinux/.
sudo genisoimage -J -r -o ../arch486.iso -b boot/isolinux/isolinux.bin \
-c boot/isolinux/boot.cat -input-charset UTF-8 -no-emul-boot \
-boot-load-size 4 -boot-info-table -joliet-long .
-cd ..
+cd .. || exit 1
diff --git a/create_gcc-lib_shim.sh b/create_gcc-lib_shim.sh
index a741809..70e4d9c 100755
--- a/create_gcc-lib_shim.sh
+++ b/create_gcc-lib_shim.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# the gcc-lib shim
@@ -35,6 +36,7 @@ arch = $TARGET_CPU
EOF
cd pkg/gcc-libs-shim || exit 1
+ # shellcheck disable=SC2035
tar cJvf - .PKGINFO * | xz > ../../gcc-libs-shim-7.2.0-1-$TARGET_CPU.pkg.tar.xz
cd ../.. || exit 1
diff --git a/create_glibc_shim.sh b/create_glibc_shim.sh
index d91104b..ac0c7d9 100755
--- a/create_glibc_shim.sh
+++ b/create_glibc_shim.sh
@@ -1,18 +1,21 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# the glibc-shim shim
if test ! -f $STAGE1_CHROOT/packages/$TARGET_CPU/glibc-shim-2.26-1-$TARGET_CPU.pkg.tar.xz; then
- cd $STAGE1_BUILD
+ cd $STAGE1_BUILD || exit 1
sudo rm -rf glibc-shim
mkdir glibc-shim
- cd glibc-shim
+ cd glibc-shim || exit 1
mkdir -p pkg/glibc-shim/usr/include
cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/include/* pkg/glibc-shim/usr/include
- sudo rm -rf pkg/glibc-shim/usr/include/{linux,misc,mtd,rdma,scsi,sound,video,xen,asm,asm-generic}
+ for dir in linux misc mtd rdma scsi sound video xen asm asm-generic; do
+ sudo rm -rf pkg/glibc-shim/usr/include/$dir
+ done
mkdir -p pkg/glibc-shim/etc
cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/etc/rpc pkg/glibc-shim/etc/.
mkdir -p pkg/glibc-shim/usr/bin
@@ -52,7 +55,7 @@ if test ! -f $STAGE1_CHROOT/packages/$TARGET_CPU/glibc-shim-2.26-1-$TARGET_CPU.p
cp -a $XTOOLS_ARCH/$TARGET_ARCH/sysroot/usr/share/locale pkg/glibc-shim/usr/share/.
BUILDDATE=$(date '+%s')
- size=`du -sk --apparent-size pkg/`
+ size=$(du -sk --apparent-size pkg/)
size="$(( ${size%%[^0-9]*} * 1024 ))"
cat > pkg/glibc-shim/.PKGINFO <<EOF
pkgname = glibc
@@ -64,9 +67,10 @@ size = $size
arch = $TARGET_CPU
EOF
- cd pkg/glibc-shim
+ cd pkg/glibc-shim || exit 1
+ # shellcheck disable=SC2035
tar cJvf - .PKGINFO * | xz > ../../glibc-shim-2.26-1-$TARGET_CPU.pkg.tar.xz
- cd ../..
+ cd ../.. || exit 1
cp -v ./*.pkg.tar.xz $STAGE1_CHROOT/packages/$TARGET_CPU/.
rm -rf $STAGE1_CHROOT/var/cache/pacman/pkg/*
diff --git a/create_hdd.sh b/create_hdd.sh
index d1d735c..3170a64 100755
--- a/create_hdd.sh
+++ b/create_hdd.sh
@@ -1,11 +1,12 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# builds a hard disk image for a stage 1 system:
# no ramdisk, no modules, no fancy startup, just a shell script
-cd $CROSS_HOME
+cd $CROSS_HOME || exit 1
umount mnt
rm -rf mnt
@@ -27,7 +28,7 @@ mkdir mnt
sudo mount /dev/loop2p1 mnt
sudo cp -a i486-root/* mnt/.
sudo chown -R cross:cross mnt/.
-cd mnt
+cd mnt || exit 1
# A simple ISOlinux boot loader booting from first partition, starting
# uinit wich start /etc/init/boot
@@ -78,7 +79,7 @@ ssh-keygen -b 521 -t ecdsa -f etc/ssh/ssh_host_ecdsa_key -N ''
ssh-keygen -b 2048 -t ed25519 -f etc/ssh/ssh_host_ed25519_key -N ''
chmod 0400 etc/ssh/ssh_host_*_key
mkdir root/.ssh
-cp $HOME/.ssh/id_rsa.pub root/.ssh/authorized_keys
+cp "$HOME/.ssh/id_rsa.pub" root/.ssh/authorized_keys
# add some test programs to test the C and C++ compiler
@@ -113,7 +114,7 @@ sudo chmod 0775 etc/init/boot
# umount and clean up partitions and loopback devices
-cd ..
+cd .. || exit 1
sudo umount mnt
sudo partx -v --delete /dev/loop2
sudo losetup -d /dev/loop2
diff --git a/install_host.sh b/install_host.sh
index c2a9c54..aaade23 100755
--- a/install_host.sh
+++ b/install_host.sh
@@ -2,6 +2,7 @@
# Install necessary tools
+# shellcheck source=./default.conf
. "./default.conf"
# development stuff
diff --git a/prepare_stage1_repo.sh b/prepare_stage1_repo.sh
index d3cf684..91a0021 100755
--- a/prepare_stage1_repo.sh
+++ b/prepare_stage1_repo.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+# shellcheck source=./default.conf
. "./default.conf"
# prepare the i486-chroot for stage 1