From 98c76cefdee289e477baac6960f9ef6fabad848c Mon Sep 17 00:00:00 2001 From: Michael Rodler Date: Wed, 1 Jun 2016 15:00:45 +0200 Subject: [PATCH] fixed weird indentation fails and added 'set -eu -o pipefail' at the top of the script --- bin/manage-tools | 98 ++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 50 deletions(-) diff --git a/bin/manage-tools b/bin/manage-tools index eb7d30a..07dc4c3 100755 --- a/bin/manage-tools +++ b/bin/manage-tools @@ -1,5 +1,6 @@ -#!/bin/bash -e -# set -evx +#!/bin/bash +set -eu -o pipefail +# set -x function usage() { @@ -43,66 +44,63 @@ function detect_distribution() function base_build_setup_ubuntu() { - 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) - if [ $(dpkg -l $PACKAGE_REQS | grep "^ii" | wc -l) -ne $PACKAGE_COUNT ] - then - if [ "$ALLOW_SUDO" -eq 1 ] - then - sudo apt-get -y install $PACKAGE_REQS - else - TOOL=SETUP tool_log "Please install the following packages: $PACKAGE_REQS" - fi - fi + 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) + if [ $(dpkg -l $PACKAGE_REQS | grep "^ii" | wc -l) -ne $PACKAGE_COUNT ] + then + if [ "$ALLOW_SUDO" -eq 1 ]; then + sudo apt-get -y install $PACKAGE_REQS + else + TOOL=SETUP tool_log "Please install the following packages: $PACKAGE_REQS" + fi + fi - if ! dpkg --print-foreign-architectures | grep -q i386 - then - if [ "$ALLOW_SUDO" -eq 1 ] - then - sudo dpkg --add-architecture i386 - sudo apt-get update - else - TOOL=SETUP tool_log "Certain tools need i386 libraries (enable with 'dpkg --add-architecture i386; apt-get update')." - fi - fi + if ! dpkg --print-foreign-architectures | grep -q i386 + then + if [ "$ALLOW_SUDO" -eq 1 ] + then + sudo dpkg --add-architecture i386 + sudo apt-get update + else + TOOL=SETUP tool_log "Certain tools need i386 libraries (enable with 'dpkg --add-architecture i386; apt-get update')." + fi + fi } function base_build_setup_arch() { - PACKAGE_REQS="curl wget python2 python3 git subversion unzip" - if [ "$ALLOW_SUDO" -eq 1 ]; then - sudo pacman -Syu --noconfirm $PACKAGE_REQS - sudo pacman -Syu --noconfirm base-devel || true - else - TOOL=SETUP tool_log "Please install the following packages: $PACKAGE_REQS" - fi + PACKAGE_REQS="curl wget python2 python3 git subversion unzip" + if [ "$ALLOW_SUDO" -eq 1 ]; then + sudo pacman -Syu --noconfirm $PACKAGE_REQS + sudo pacman -Syu --noconfirm base-devel || true + else + TOOL=SETUP tool_log "Please install the following packages: $PACKAGE_REQS" + fi - - if ! grep "^\[multilib\]$" /etc/pacman.conf >/dev/null; then - if [ "$ALLOW_SUDO" -eq 1 ] - then - sudo sh -c 'cat >> /etc/pacman.conf' </dev/null; then + if [ "$ALLOW_SUDO" -eq 1 ]; then + sudo sh -c 'cat >> /etc/pacman.conf' </dev/null \ - && ! sudo pacman -Qk gcc-multilib >/dev/null - then - sudo pacman -Syy --noconfirm - #sudo pacman -Syu --noconfirm multilib-devel - # unfortunately we cannot do --noconfirm if we might choose to replace - # a package such as gcc with gcc-multilib, therefore this workaround - printf "\ny\ny\ny\n" | sudo pacman -Syu multilib-devel - fi + if [ "$ALLOW_SUDO" -eq 1 ] \ + && grep "^\[multilib\]$" /etc/pacman.conf >/dev/null \ + && ! sudo pacman -Qk gcc-multilib >/dev/null + then + sudo pacman -Syy --noconfirm + #sudo pacman -Syu --noconfirm multilib-devel + # unfortunately we cannot do --noconfirm if we might choose to replace + # a package such as gcc with gcc-multilib, therefore this workaround + printf "\ny\ny\ny\n" | sudo pacman -Syu multilib-devel + fi }