address shellcheck issues

This commit is contained in:
a1batross 2024-07-11 20:36:39 +02:00
parent ab0f55c059
commit 2a7e215c8b

View File

@ -35,7 +35,7 @@ if ! command -v wget > /dev/null; then
exit 1
fi
if [ $(uname -m) == "e2k" ]; then
if [ "$(uname -m)" == "e2k" ]; then
echo "This script is for emulating Elbrus and you're already running on this architecture"
exit 1
fi
@ -47,7 +47,7 @@ echo "unpack image and install binfmt_misc rule\n"
read -p "Did you read and understood the message above? [Yn] " yn
case $yn in
[yY|""] ) echo "Continuing..."; break;;
[yY|""] ) echo "Continuing..."; ;;
[nN] ) echo "Exiting"; exit 0;;
[*] ) echo "Unrecognized answer"; exit 1;;
esac
@ -55,14 +55,14 @@ esac
set -x
git clone https://git.mentality.rip/OpenE2K/qemu-e2k -b $QEMU_BRANCH --depth=1 || exit 2
pushd qemu-e2k
./configure --target-list=e2k-linux-user --static $QEMU_BUILD_FLAGS
make -j$(nproc)
popd
pushd qemu-e2k || exit 2
./configure --target-list=e2k-linux-user --static $QEMU_BUILD_FLAGS || exit 2
make -j$(nproc) || exit 2
popd || exit 2
for i in ${MIRRORS[@]}; do
for i in "${MIRRORS[@]}"; do
echo -n "Probing mirror $i..."
if wget -q -O/dev/null $i; then
if wget -q -O/dev/null "$i"; then
SELECTED_MIRROR=$i
echo "OK"
@ -72,14 +72,14 @@ for i in ${MIRRORS[@]}; do
fi
done
if [ -z $SELECTED_MIRROR ]; then
if [ -z "$SELECTED_MIRROR" ]; then
echo "Can't find working mirror, exiting..."
exit 1
exit 2
fi
qemu_register_interpreter() {
echo "Setting $qemu as binfmt interpreter for $cpu"
qemu_generate_register | sudo tee /proc/sys/fs/binfmt_misc/register
qemu_generate_register | sudo tee /proc/sys/fs/binfmt_misc/register || exit 2
}
qemu_generate_register() {
@ -88,14 +88,14 @@ qemu_generate_register() {
echo ":qemu-$cpu:M::$magic:$mask:$qemu:$flags"
}
wget -Odocker.txz $SELECTED_MIRROR$IMAGE_PATH
wget -Odocker.txz "$SELECTED_MIRROR$IMAGE_PATH"
mkdir -p $CHROOT_DIR || exit 2
pushd $CHROOT_DIR
sudo tar -xJf ../docker.txz || exit 2
sudo cp ../qemu-e2k/build/qemu-e2k usr/bin
sudo cp ../qemu-e2k/build/qemu-e2k usr/bin || exit 2
# Change default mirror in case if ivk is unreachable (it's kinda stupid to block non-Russian IP addresses, isn't it?)
if [ $SELECTED_MIRROR != "http://elbrus.ivk.ru/pub" ]; then
if [ "$SELECTED_MIRROR" != "http://elbrus.ivk.ru/pub" ]; then
sed "s|http://elbrus.ivk.ru/pub|$SELECTED_MIRROR|g" etc/apt/sources.list.d/ivk.list | sudo tee etc/apt/sources.list.d/mirror.list
sudo mv etc/apt/sources.list.d/ivk.list etc/apt/sources.list.d/ivk.list.disabled
@ -109,7 +109,7 @@ for cpu in ${qemu_target_list} ; do
mask=$(eval echo \$${cpu}_mask)
qemu_register_interpreter
done
popd
popd || exit 2
set +x