From de2e1bf79c3fe2324a00af8ee34c93bb851798d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Mon, 26 Mar 2018 15:30:05 +0200 Subject: [PATCH] Proper error handling --- setup_env.sh | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/setup_env.sh b/setup_env.sh index 7f436b7..7c6bb50 100644 --- a/setup_env.sh +++ b/setup_env.sh @@ -4,39 +4,59 @@ function status_update { echo "### $1 ###" } +function fail { + echo "An error has occured. Exiting." + exit 1 +} + +function gitclone { + if [ -d "$2" ] ; then + if [ -d "$2/.git" ] ; then + git -C "$2" pull || fail + else + >&2 echo "Directory "$2" is present and not git. Aborting." + fail + fi + else + git clone "$1" "$2" || fail + fi +} + + base_dir="$(dirname "$(readlink -f "$0")")" cd "$base_dir" # First, clone Francesco's eh_frame_check status_update "Cloning eh_frame_check" -git clone https://github.com/francesco-zappa-nardelli/eh_frame_check/ +gitclone \ + https://github.com/francesco-zappa-nardelli/eh_frame_check/ eh_frame_check # Then, clone glibc status_update "Cloning glibc" -git clone git://sourceware.org/git/glibc.git glibc +gitclone git://sourceware.org/git/glibc.git glibc # Install a virtualenv with required pip packages status_update "Installing python virtualenv" -virtualenv -p python3 venv +virtualenv -p python3 venv || fail source venv/bin/activate -pip install -r requirements.txt +pip install -r requirements.txt || fail # Compiling glibc status_update "Compiling base glibc" ( mkdir -p glibc/build/install cd glibc/build - ../configure --prefix=install - make -) + ../configure --prefix=install || exit 1 + make || exit 1 +) || fail # Compiling testsuite status_update "Compiling glibc testsuite" status_update "Feel free to go and drink some coffee now. This will take some time." ( cd glibc/build - make check -) + make check || exit 1 +) || fail # Done! status_update "All set!"