|
| 1 | +#!/usr/bin/env bash |
| 2 | +# BASH3 Boilerplate |
| 3 | +# |
| 4 | +# download-all-prerequisites.sh |
| 5 | +# |
| 6 | +# - Download all packages required for building OpenCoarrays and its prerequisites |
| 7 | +# |
| 8 | +# Usage: LOG_LEVEL=7 B3B_USE_CASE=/opt/bash3boilerplate/src/use-case ./my-script.sh -f script_input.txt |
| 9 | +# |
| 10 | +# More info: |
| 11 | +# |
| 12 | +# - https://github.com/kvz/bash3boilerplate |
| 13 | +# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/ |
| 14 | +# |
| 15 | +# Version: 2.0.0 |
| 16 | +# |
| 17 | +# Authors: |
| 18 | +# |
| 19 | +# - Kevin van Zonneveld (http://kvz.io) |
| 20 | +# - Izaak Beekman (https://izaakbeekman.com/) |
| 21 | +# - Alexander Rathai ([email protected]) |
| 22 | +# - Dr. Damian Rouson (http://www.sourceryinstitute.org/) (documentation) |
| 23 | +# |
| 24 | +# Licensed under MIT |
| 25 | +# Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io) |
| 26 | + |
| 27 | +# The invocation of bootstrap.sh below performs the following tasks: |
| 28 | +# (1) Import several bash3boilerplate helper functions & default settings. |
| 29 | +# (2) Set several variables describing the current file and its usage page. |
| 30 | +# (3) Parse the usage information (default usage file name: current file's name with -usage appended). |
| 31 | +# (4) Parse the command line using the usage information. |
| 32 | + |
| 33 | + |
| 34 | +export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD%prerequisites*}}" |
| 35 | +export __usage=${OPENCOARRAYS_SRC_DIR}/prerequisites/download-all.sh-usage |
| 36 | +if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then |
| 37 | + echo "Please run this script inside the OpenCoarrays source \"prerequisites\" subdirectory" |
| 38 | + echo "or set OPENCOARRAYS_SRC_DIR to the top-level OpenCoarrays source directory path." |
| 39 | + exit 1 |
| 40 | +fi |
| 41 | +export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}" |
| 42 | +if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then |
| 43 | + echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path." |
| 44 | + exit 2 |
| 45 | +fi |
| 46 | +# shellcheck source=./use-case/bootstrap.sh |
| 47 | +source "${B3B_USE_CASE}/bootstrap.sh" "$@" |
| 48 | + |
| 49 | +# Set up a function to call when receiving an EXIT signal to do some cleanup. Remove if |
| 50 | +# not needed. Other signals can be trapped too, like SIGINT and SIGTERM. |
| 51 | +function cleanup_before_exit () { |
| 52 | + info "Cleaning up. Done" |
| 53 | +} |
| 54 | +trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, SIGTERM etc. |
| 55 | + |
| 56 | +### Validation (decide what's required for running your script and error out) |
| 57 | +##################################################################### |
| 58 | + |
| 59 | +export __flag_present=1 |
| 60 | + |
| 61 | +[ -z "${LOG_LEVEL:-}" ] && emergency "Cannot continue without LOG_LEVEL. " |
| 62 | + |
| 63 | +### Print bootstrapped magic variables to STDERR when LOG_LEVEL |
| 64 | +### is at the default value (6) or above. |
| 65 | +##################################################################### |
| 66 | +# shellcheck disable=SC2154 |
| 67 | +{ |
| 68 | +info "__file: ${__file}" |
| 69 | +info "__dir: ${__dir}" |
| 70 | +info "__base: ${__base}" |
| 71 | +info "__os: ${__os}" |
| 72 | +info "__usage: ${__usage}" |
| 73 | +info "LOG_LEVEL: ${LOG_LEVEL}" |
| 74 | + |
| 75 | +info "-d (--debug): ${arg_d} " |
| 76 | +info "-e (--verbose): ${arg_e} " |
| 77 | +info "-h (--help): ${arg_h} " |
| 78 | +} |
| 79 | + |
| 80 | +download_list=( "m4" "bison" "flex" "mpich" "cmake" ) |
| 81 | + |
| 82 | +for package_to_download in "${download_list[@]}" ; do |
| 83 | + if [[ "${arg_l}" == "${__flag_present}" ]]; then |
| 84 | + info "${package_to_download}" |
| 85 | + else |
| 86 | + ./install.sh --package ${package_to_download} --only-download |
| 87 | + fi |
| 88 | +done |
| 89 | + |
| 90 | +if [[ ! -z ${arg_b:-} ]]; then |
| 91 | + ./install.sh --package gcc --only-download --install-branch "${arg_b}" |
| 92 | +else # Download default version |
| 93 | + ./install.sh --package gcc --only-download |
| 94 | +fi |
| 95 | + |
| 96 | +pushd prerequisites/downloads/trunk |
| 97 | + |
| 98 | + source ../../build-functions/set_or_print_downloader.sh |
| 99 | + set_or_print_downloader |
| 100 | + |
| 101 | + source ../../build-functions/edit_GCC_download_prereqs_file_if_necessary.sh |
| 102 | + edit_GCC_download_prereqs_file_if_necessary |
| 103 | + |
| 104 | + ./contrib/download_prerequisites |
| 105 | + |
| 106 | +popd |
0 commit comments