fixed weird indentation fails and added 'set -eu -o pipefail' at the top of the script

This commit is contained in:
Michael Rodler 2016-06-01 15:00:45 +02:00
parent 6dd094a8a9
commit 98c76cefde

View file

@ -1,5 +1,6 @@
#!/bin/bash -e #!/bin/bash
# set -evx set -eu -o pipefail
# set -x
function usage() function usage()
{ {
@ -43,66 +44,63 @@ function detect_distribution()
function base_build_setup_ubuntu() function base_build_setup_ubuntu()
{ {
PACKAGE_REQS="build-essential libtool g++ gcc linuxtexinfo curl wget automake autoconf python-dev git subversion unzip" PACKAGE_REQS="build-essential libtool g++ gcc linuxtexinfo curl wget automake autoconf python-dev git subversion unzip"
PACKAGE_COUNT=$(echo $PACKAGE_REQS | tr ' ' '\n' | wc -l) PACKAGE_COUNT=$(echo $PACKAGE_REQS | tr ' ' '\n' | wc -l)
if [ $(dpkg -l $PACKAGE_REQS | grep "^ii" | wc -l) -ne $PACKAGE_COUNT ] if [ $(dpkg -l $PACKAGE_REQS | grep "^ii" | wc -l) -ne $PACKAGE_COUNT ]
then then
if [ "$ALLOW_SUDO" -eq 1 ] if [ "$ALLOW_SUDO" -eq 1 ]; then
then sudo apt-get -y install $PACKAGE_REQS
sudo apt-get -y install $PACKAGE_REQS else
else TOOL=SETUP tool_log "Please install the following packages: $PACKAGE_REQS"
TOOL=SETUP tool_log "Please install the following packages: $PACKAGE_REQS" fi
fi fi
fi
if ! dpkg --print-foreign-architectures | grep -q i386 if ! dpkg --print-foreign-architectures | grep -q i386
then then
if [ "$ALLOW_SUDO" -eq 1 ] if [ "$ALLOW_SUDO" -eq 1 ]
then then
sudo dpkg --add-architecture i386 sudo dpkg --add-architecture i386
sudo apt-get update sudo apt-get update
else else
TOOL=SETUP tool_log "Certain tools need i386 libraries (enable with 'dpkg --add-architecture i386; apt-get update')." TOOL=SETUP tool_log "Certain tools need i386 libraries (enable with 'dpkg --add-architecture i386; apt-get update')."
fi fi
fi fi
} }
function base_build_setup_arch() function base_build_setup_arch()
{ {
PACKAGE_REQS="curl wget python2 python3 git subversion unzip" PACKAGE_REQS="curl wget python2 python3 git subversion unzip"
if [ "$ALLOW_SUDO" -eq 1 ]; then if [ "$ALLOW_SUDO" -eq 1 ]; then
sudo pacman -Syu --noconfirm $PACKAGE_REQS sudo pacman -Syu --noconfirm $PACKAGE_REQS
sudo pacman -Syu --noconfirm base-devel || true sudo pacman -Syu --noconfirm base-devel || true
else else
TOOL=SETUP tool_log "Please install the following packages: $PACKAGE_REQS" TOOL=SETUP tool_log "Please install the following packages: $PACKAGE_REQS"
fi fi
if ! grep "^\[multilib\]$" /etc/pacman.conf >/dev/null; then
if ! grep "^\[multilib\]$" /etc/pacman.conf >/dev/null; then if [ "$ALLOW_SUDO" -eq 1 ]; then
if [ "$ALLOW_SUDO" -eq 1 ] sudo sh -c 'cat >> /etc/pacman.conf' <<EOF
then
sudo sh -c 'cat >> /etc/pacman.conf' <<EOF
[multilib] [multilib]
Include = /etc/pacman.d/mirrorlist Include = /etc/pacman.d/mirrorlist
EOF EOF
else else
TOOL=SETUP tool_log "Certain tools need i386 libraries (enable multilib in /etc/pacman.conf')." TOOL=SETUP tool_log "Certain tools need i386 libraries (enable multilib in /etc/pacman.conf')."
return return
fi fi
fi fi
if [ "$ALLOW_SUDO" -eq 1 ] \ if [ "$ALLOW_SUDO" -eq 1 ] \
&& grep "^\[multilib\]$" /etc/pacman.conf >/dev/null \ && grep "^\[multilib\]$" /etc/pacman.conf >/dev/null \
&& ! sudo pacman -Qk gcc-multilib >/dev/null && ! sudo pacman -Qk gcc-multilib >/dev/null
then then
sudo pacman -Syy --noconfirm sudo pacman -Syy --noconfirm
#sudo pacman -Syu --noconfirm multilib-devel #sudo pacman -Syu --noconfirm multilib-devel
# unfortunately we cannot do --noconfirm if we might choose to replace # unfortunately we cannot do --noconfirm if we might choose to replace
# a package such as gcc with gcc-multilib, therefore this workaround # a package such as gcc with gcc-multilib, therefore this workaround
printf "\ny\ny\ny\n" | sudo pacman -Syu multilib-devel printf "\ny\ny\ny\n" | sudo pacman -Syu multilib-devel
fi fi
} }