diff --git a/scripts/compile_dep.sh b/scripts/compile_dep.sh index 577b80e7b57b48992338dc5e17565d10f7054fef..3b11e880f00ebcd5b20cdedc5c506bc822c9e307 100755 --- a/scripts/compile_dep.sh +++ b/scripts/compile_dep.sh @@ -50,8 +50,7 @@ declare -A PROFILE_CLONEDEPS_ARGS PROFILE_CLONEDEPS_PATCHES usage_short() { echo " usage: compile_dep.sh -h | - -p PROFILE_NAME[:PROFILE_VERSION] | - -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] | + -p DEPENDENCY_NAME[[@PROFILE_NAME:][PROFILE_VERSION]] | -l [PROFILE_NAME:[PROFILE_VERSION]] | -h [ -P PROFILES_DIR ] [ -j COMPILE_CORES] [ -n ] @@ -74,24 +73,15 @@ optional arguments: -h, --help Shows this help message and exits -l, --list-dependencies [[PROFILE_NAME:]PROFILE_VERSION] List dependencies available for building and installation - -p, --profile PROFILE_NAME[:PROFILE_VERSION] - Allows installing a pre-defined set of dependencies as defined - in \${PROFILES_DIR}/PROFILE_NAME.specs. This is useful to - deploy specific library versions and/or configurations, - using a recognizable name. Optionally, PROFILE_NAME may include - a specific version for the profile, e.g. 'mogon2:latest' or - 'ngio:0.9.1', which will download the dependencies defined for - that specific version. If unspecified, the 'default:latest' profile - will be used, which should include all the possible dependencies. - -d, --dependency DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] + -p, --profile DEPENDENCY_NAME[[@PROFILE_NAME:][PROFILE_VERSION]] Build and install a specific dependency, ignoring any --profile option provided. If PROFILE_NAME is unspecified, the 'default' profile will be used. Similarly, if PROFILE_VERSION is unspecified, the 'latest' version of the specified profile will be used. -j, --compilecores COMPILE_CORES - Set the number of cores that will be used to compile the - dependencies. If unspecified, defaults to the number of + Set the number of cores that will be used to compile the + dependencies. If unspecified, defaults to the number of available cores. -t, --test Perform libraries tests. -P, --profiles-dir PROFILES_DIR @@ -373,30 +363,10 @@ while [[ $# -gt 0 ]]; do case ${key} in -p | --profile) - [ -n "${EXECUTION_MODE}" ] && exec_mode_error || EXECUTION_MODE='profile' - - if [[ -z "$2" ]]; then - echo "ERROR: Missing argument for -p/--profile option" - exit 1 - fi - - if [[ "$2" =~ ^(.*):(.*)$ ]]; then - PROFILE_NAME="${BASH_REMATCH[1]}" - PROFILE_VERSION="${BASH_REMATCH[2]}" - else - PROFILE_NAME="$2" - PROFILE_VERSION="${DEFAULT_VERSION}" - fi - - shift # past argument - shift # past value - ;; - -d | --dependency) - [ -n "${EXECUTION_MODE}" ] && exec_mode_error || EXECUTION_MODE='dependency' if [[ -z "$2" ]]; then - echo "ERROR: Missing argument for -d/--dependency option" + echo "ERROR: Missing argument for -p/--profile option" exit fi @@ -417,6 +387,16 @@ while [[ $# -gt 0 ]]; do PROFILE_VERSION="${BASH_REMATCH[3]}" fi + # e.g. default:latest + elif [[ "$2" =~ ^(.*):(.*)$ ]]; then + if [[ -n "${BASH_REMATCH[1]}" ]]; then + PROFILE_NAME="${BASH_REMATCH[1]}" + fi + + if [[ -n "${BASH_REMATCH[2]}" ]]; then + PROFILE_VERSION="${BASH_REMATCH[2]}" + fi + # e.g. mercury@mogon1 elif [[ "$2" =~ ^(.*)@(.*)$ ]]; then if [[ -n "${BASH_REMATCH[1]}" ]]; then @@ -431,11 +411,6 @@ while [[ $# -gt 0 ]]; do DEPENDENCY="$2" fi - if [[ ! -n "${DEPENDENCY}" ]]; then - echo "ERROR: Missing dependency name." - exit 1 - fi - shift # past argument shift # past value ;; diff --git a/scripts/dl_dep.sh b/scripts/dl_dep.sh index 98ece483021493f6ad70ec3abb8386f4887deea2..efef420ca526636d728a721989d6e8a1ab189c79 100755 --- a/scripts/dl_dep.sh +++ b/scripts/dl_dep.sh @@ -81,7 +81,7 @@ list_versions() { profile="$(basename ${filename%%.specs})" versions[$id]+="${profile} " - done < <(find -L "${PROFILES_DIR}" -type f -name "*.specs" -print0 | sort -z) + done < <(find -L "${PROFILES_DIR}" -type f -name "*.specs" -print0 | sort -z) echo -e "Available versions and configuration profiles:\n" @@ -307,8 +307,7 @@ wgetdeps() { usage_short() { echo " -usage: dl_dep.sh -p PROFILE_NAME[:PROFILE_VERSION] | - -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] | +usage: dl_dep.sh -p DEPENDENCY_NAME[[@PROFILE_NAME:][PROFILE_VERSION]] | -l [[PROFILE_NAME:]PROFILE_VERSION] | -h [ -P PROFILES_DIR ] [ -n ] @@ -330,16 +329,7 @@ optional arguments: -h, --help Shows this help message and exits -l, --list-dependencies [[PROFILE_NAME:]PROFILE_VERSION] List dependency configuration profiles available for download - -p, --profile PROFILE_NAME[:PROFILE_VERSION] - Allows downloading a pre-defined set of dependencies as defined - in \${PROFILES_DIR}/PROFILE_NAME.specs. This is useful to - deploy specific library versions and/or configurations, - using a recognizable name. Optionally, PROFILE_NAME may include - a specific version for the profile, e.g. 'mogon2:latest' or - 'ngio:0.9.1', which will download the dependencies defined for - that specific version. If unspecified, the 'default:latest' profile - will be used, which should include all the possible dependencies. - -d, --dependency DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] + -p, --profile DEPENDENCY_NAME[[@PROFILE_NAME:][PROFILE_VERSION]] Build and install a specific dependency, ignoring any --profile option provided. If PROFILE_NAME is unspecified, the 'default' profile will be used. Similarly, if PROFILE_VERSION is unspecified, @@ -368,31 +358,10 @@ while [[ $# -gt 0 ]]; do case ${key} in -p | --profile) - [ -n "${EXECUTION_MODE}" ] && exec_mode_error || EXECUTION_MODE='profile' - - if [[ -z "$2" ]]; then - echo "ERROR: Missing argument for -p/--profile option" - exit 1 - fi - - if [[ "$2" =~ ^(.*):(.*)$ ]]; then - PROFILE_NAME="${BASH_REMATCH[1]}" - PROFILE_VERSION="${BASH_REMATCH[2]}" - else - PROFILE_NAME="$2" - PROFILE_VERSION="${DEFAULT_VERSION}" - fi - - shift # past argument - shift # past value - ;; - - -d | --dependency) - [ -n "${EXECUTION_MODE}" ] && exec_mode_error || EXECUTION_MODE='dependency' if [[ -z "$2" ]]; then - echo "ERROR: Missing argument for -d/--dependency option" + echo "ERROR: Missing argument for -p/--profile option" exit 1 fi @@ -410,6 +379,16 @@ while [[ $# -gt 0 ]]; do PROFILE_VERSION="${BASH_REMATCH[3]}" fi + # e.g. default:latest + elif [[ "$2" =~ ^(.*):(.*)$ ]]; then + if [[ -n "${BASH_REMATCH[1]}" ]]; then + PROFILE_NAME="${BASH_REMATCH[1]}" + fi + + if [[ -n "${BASH_REMATCH[2]}" ]]; then + PROFILE_VERSION="${BASH_REMATCH[2]}" + fi + # e.g. mercury@mogon1 elif [[ "$2" =~ ^(.*)@(.*)$ ]]; then if [[ -n "${BASH_REMATCH[1]}" ]]; then @@ -424,11 +403,6 @@ while [[ $# -gt 0 ]]; do DEPENDENCY="$2" fi - if [[ ! -n "${DEPENDENCY}" ]]; then - echo "ERROR: Missing dependency name." - exit 1 - fi - shift # past argument shift # past value ;; diff --git a/scripts/gkfs_dep.sh b/scripts/gkfs_dep.sh index 891aff50e5e284bd0ebd7204d21e53310776b68b..6977ba39459859f7bd0bdd5b282db5d5b7636a79 100755 --- a/scripts/gkfs_dep.sh +++ b/scripts/gkfs_dep.sh @@ -32,8 +32,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" usage_short() { echo " usage: compile_dep.sh -h | - -p PROFILE_NAME[:PROFILE_VERSION] | - -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] | + -p DEPENDENCY_NAME[[@PROFILE_NAME:][PROFILE_VERSION]] | -l [PROFILE_NAME:[PROFILE_VERSION]] | -h [ -P PROFILES_DIR ] [ -j COMPILE_CORES] [ -n ] [ -v ] @@ -56,7 +55,7 @@ optional arguments: -h, --help Shows this help message and exits -l, --list-dependencies [[PROFILE_NAME:]PROFILE_VERSION] List dependencies available for building and installation - -p, --profile PROFILE_NAME[:PROFILE_VERSION] + -p, --dependency DEPENDENCY_NAME[[@PROFILE_NAME:][PROFILE_VERSION]] Allows installing a pre-defined set of dependencies as defined in \${PROFILES_DIR}/PROFILE_NAME.specs. This is useful to deploy specific library versions and/or configurations, @@ -65,7 +64,6 @@ optional arguments: 'ngio:0.9.1', which will download the dependencies defined for that specific version. If unspecified, the 'default:latest' profile will be used, which should include all the possible dependencies. - -d, --dependency DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] Build and install a specific dependency, ignoring any --profile option provided. If PROFILE_NAME is unspecified, the 'default' profile will be used. Similarly, if PROFILE_VERSION is @@ -100,11 +98,6 @@ while [[ $# -gt 0 ]]; do shift # past argument shift # past value ;; - -d | --dependency) - DEPENDENCY="$2" - shift # past argument - shift # past value - ;; -j | --compilecores) COMPILE_ARGS="$COMPILE_ARGS -j $2" shift # past argument @@ -156,12 +149,7 @@ fi SOURCE_DIR="$(readlink -mn "${1}")" INSTALL_DIR="$(readlink -mn "${2}")" # build arguments -if [[ -n $DEPENDENCY ]]; then - PROFILE_STR="-d $DEPENDENCY" - if [[ -n $PROFILE ]]; then - PROFILE_STR="$PROFILE_STR@$PROFILE" - fi -elif [[ -n $PROFILE ]]; then +if [[ -n $PROFILE ]]; then PROFILE_STR="-p $PROFILE" fi if [[ -n $PROFILE_STR ]]; then @@ -182,4 +170,4 @@ echo -e "\n\n##############################" echo "# Compiling dependencies ... #" echo "##############################" [[ "$VERBOSE" == true ]] && echo "# COMPILE_CMD: $COMPILE_CMD" -$COMPILE_CMD || exit 1 \ No newline at end of file +$COMPILE_CMD || exit 1 diff --git a/tests/scripts/compile_dep.sh/test.bats b/tests/scripts/compile_dep.sh/test.bats index 244aff1366a19f01995a684c4c689fc511b721d9..2d8b8187ef57de135f39c7b2dfc3be8dede6a08d 100644 --- a/tests/scripts/compile_dep.sh/test.bats +++ b/tests/scripts/compile_dep.sh/test.bats @@ -14,7 +14,7 @@ setup() { # make sure that the script is able to find the profiles cd ${GIT_ROOTDIR}/scripts - + # make executables in scripts/ visible to PATH PATH="${GIT_ROOTDIR}/scripts:$PATH" } @@ -43,87 +43,28 @@ teardown() { done < "$expected_output" } -@test "[compile_dep.sh] Check --profile and --dependency option at the same time" { - run -1 compile_dep.sh -p foobar -d barbaz - assert_output --partial "ERROR: --profile and --dependency options are mutually exclusive" -} - -@test "[compile_dep.sh] Check --profile option without argument" { - run -1 compile_dep.sh -p - assert_output --partial "ERROR: Missing argument for -p/--profile option" -} - @test "[compile_dep.sh] Check invalid --profile option without SOURCES_PATH or INSTALL_PATH" { run -1 compile_dep.sh -p foo - assert_output --partial "ERROR: Positional arguments missing." + assert_output --partial "ERROR: Positional arguments missing." } @test "[compile_dep.sh] Check invalid --profile option without SOURCES_PATH" { run -1 compile_dep.sh -p foo bar - assert_output --partial "ERROR: Positional arguments missing." -} - -@test "[compile_dep.sh] Check invalid --profile option" { - run -1 compile_dep.sh -p foo bar baz - assert_output --partial "Profile 'foo:latest' does not exist." -} - -@test "[compile_dep.sh] Check valid --profile option, no PROFILE_VERSION" { - - profile_names=($(compile_dep.sh -l latest | perl -lne "print for /^\* (\w+):.*$/")) - - for pn in "${profile_names[@]}"; do - - expected_output=${SCRIPT_TESTDIR}/latest/${pn}.out - - assert_exist $expected_output - - run compile_dep.sh -n -p "${pn}" foo bar - - while IFS= read -r line - do - assert_output --partial "$line" - done < "$expected_output" - done - -} - -@test "[compile_dep.sh] Check valid --profile option, with PROFILE_VERSION" { - - profile_versions=($(compile_dep.sh -l | perl -lne "print for /^\s{2}(.*?):$/")) - - for pv in "${profile_versions[@]}"; do - profile_names=($(compile_dep.sh -l ${pv} | perl -lne "print for /^\* (\w+):.*$/")) - - for pn in "${profile_names[@]}"; do - - expected_output=${SCRIPT_TESTDIR}/${pv}/${pn}.out - - assert_exist $expected_output - - run compile_dep.sh -n -p "${pn}:${pv}" foo bar - - while IFS= read -r line - do - assert_output --partial "$line" - done < "$expected_output" - done - - done + assert_output --partial "ERROR: Positional arguments missing." } -@test "[compile_dep.sh] Check unknown --dependency option" { +@test "[compile_dep.sh] Check unknown --profile option" { profile_name=default profile_version=latest - run -1 compile_dep.sh -n -d foobar bar baz + run -1 compile_dep.sh -n -p foobar bar baz assert_output --partial "Dependency 'foobar' not found in '$profile_name:$profile_version'" } -@test "[compile_dep.sh] Check valid --dependency option, no PROFILE_NAME or PROFILE_VERSION" { +@test "[compile_dep.sh] Check valid --profile option, no PROFILE_NAME or PROFILE_VERSION" { dependency_names=($(compile_dep.sh -l default:latest | perl -lne "print for /^\s{4}(\w+(?::\w+)*):.*$/")) @@ -131,7 +72,7 @@ teardown() { source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo) install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar) - run compile_dep.sh -n -d "${dep}" ${source_path} ${install_path} + run compile_dep.sh -n -p "${dep}" ${source_path} ${install_path} assert_output --regexp \ "CORES = [0-9]+ \(default\) @@ -149,7 +90,7 @@ Done" done } -@test "[compile_dep.sh] Check valid --dependency option, PROFILE_NAME only" { +@test "[compile_dep.sh] Check valid --profile option, PROFILE_NAME only" { profile_names=($(compile_dep.sh -l latest | perl -lne "print for /^\* (\w+):.*$/")) @@ -161,7 +102,7 @@ Done" source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo) install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar) - run compile_dep.sh -n -d "${dep}@${pn}" ${source_path} ${install_path} + run compile_dep.sh -n -p "${dep}@${pn}" ${source_path} ${install_path} assert_output --regexp \ "CORES = [0-9]+ \(default\) @@ -180,7 +121,7 @@ Done" done } -@test "[compile_dep.sh] Check valid --dependency option, PROFILE_NAME and PROFILE_VERSION" { +@test "[compile_dep.sh] Check valid --profile option, PROFILE_NAME and PROFILE_VERSION" { profile_versions=($(compile_dep.sh -l | perl -lne "print for /^\s{2}(.*?):$/")) @@ -196,7 +137,7 @@ Done" source_path=$(readlink -f ${BATS_TEST_TMPDIR}/foo) install_path=$(readlink -f ${BATS_TEST_TMPDIR}/bar) - run compile_dep.sh -n -d "${dep}@${pn}" ${source_path} ${install_path} + run compile_dep.sh -n -p "${dep}@${pn}" ${source_path} ${install_path} assert_output --regexp \ "CORES = [0-9]+ \(default\) diff --git a/tests/scripts/dl_dep.sh/test.bats b/tests/scripts/dl_dep.sh/test.bats index 51b27ba3a67ceb8e4bf5ae356c3fd6f5e48ba5f9..c3212e49e99fe92ccaacaadb7811203bdb67f111 100644 --- a/tests/scripts/dl_dep.sh/test.bats +++ b/tests/scripts/dl_dep.sh/test.bats @@ -14,7 +14,7 @@ setup() { # make sure that the script is able to find the profiles cd ${GIT_ROOTDIR}/scripts - + # make executables in scripts/ visible to PATH PATH="${GIT_ROOTDIR}/scripts:$PATH" } @@ -29,7 +29,7 @@ teardown() { assert_output --partial "usage: dl_dep.sh" } -@test "[dl_dep.sh] Check no --profile or --dependency options" { +@test "[dl_dep.sh] Check no --profile options" { expected_output=${SCRIPT_TESTDIR}/latest/default.out @@ -43,11 +43,6 @@ teardown() { done < "$expected_output" } -@test "[dl_dep.sh] Check --profile and --dependency option at the same time" { - run -1 dl_dep.sh -p foobar -d barbaz - assert_output --partial "ERROR: --profile and --dependency options are mutually exclusive" -} - @test "[dl_dep.sh] Check --profile option without argument" { run -1 dl_dep.sh -p assert_output --partial "ERROR: Missing argument for -p/--profile option" @@ -55,86 +50,33 @@ teardown() { @test "[dl_dep.sh] Check invalid --profile option without DESTINATION_PATH" { run -1 dl_dep.sh -p foobar - assert_output --partial "ERROR: Positional arguments missing." + assert_output --partial "ERROR: Positional arguments missing." } @test "[dl_dep.sh] Check valid --profile option without DESTINATION_PATH" { run dl_dep.sh -p default - assert_output --partial "ERROR: Positional arguments missing." + assert_output --partial "ERROR: Positional arguments missing." } -@test "[dl_dep.sh] Check valid --profile option, no PROFILE_VERSION" { - - profile_names=($(dl_dep.sh -l latest | perl -lne "print for /^\* (\w+):.*$/")) - - for pn in "${profile_names[@]}"; do - - expected_output=${SCRIPT_TESTDIR}/latest/${pn}.out - - assert_exist $expected_output - - run dl_dep.sh -n -p "${pn}" "${BATS_TEST_TMPDIR}" - - while IFS= read -r line - do - assert_output --partial "$line" - done < "$expected_output" - done -} - -@test "[dl_dep.sh] Check valid --profile option, with PROFILE_VERSION" { - - profile_versions=($(dl_dep.sh -l | perl -lne "print for /^\s{2}(.*?):$/")) - - for pv in "${profile_versions[@]}"; do - profile_names=($(dl_dep.sh -l ${pv} | perl -lne "print for /^\* (\w+):.*$/")) - - for pn in "${profile_names[@]}"; do - - expected_output=${SCRIPT_TESTDIR}/${pv}/${pn}.out - - assert_exist $expected_output - - run dl_dep.sh -n -p "${pn}:${pv}" "${BATS_TEST_TMPDIR}" - - while IFS= read -r line - do - assert_output --partial "$line" - done < "$expected_output" - done - - done -} - -@test "[dl_dep.sh] Check unknown --dependency option" { +@test "[dl_dep.sh] Check unknown --profile option" { profile_name=default profile_version=latest - run -1 dl_dep.sh -n -d foobar "${BATS_TEST_TMPDIR}" + run -1 dl_dep.sh -n -p foobar "${BATS_TEST_TMPDIR}" assert_output "ERROR: 'foobar' not found in '$profile_name:$profile_version'" } -@test "[dl_dep.sh] Check invalid --dependency option without DESTINATION_PATH" { - run -1 dl_dep.sh -d foobar - assert_output --partial "ERROR: Positional arguments missing." -} - -@test "[dl_dep.sh] Check valid --dependency option without DESTINATION_PATH" { - run dl_dep.sh -d mercury - assert_output --partial "ERROR: Positional arguments missing." -} - -@test "[dl_dep.sh] Check valid --dependency option, no PROFILE_NAME or PROFILE_VERSION" { +@test "[dl_dep.sh] Check valid --profile option, no PROFILE_NAME or PROFILE_VERSION" { dependency_names=($(dl_dep.sh -l default:latest | perl -lne "print for /^\s{4}(\w+(?::\w+)*):.*$/")) for dep in "${dependency_names[@]}"; do destination_path=$(readlink -f ${BATS_TEST_TMPDIR}) - run dl_dep.sh -n -d "${dep}" "${BATS_TEST_TMPDIR}" + run dl_dep.sh -n -p "${dep}" "${BATS_TEST_TMPDIR}" assert_output --regexp \ "Destination path is set to \"${destination_path}\" @@ -147,7 +89,7 @@ Done" done } -@test "[dl_dep.sh] Check valid --dependency option, PROFILE_NAME only" { +@test "[dl_dep.sh] Check valid --profile option, PROFILE_NAME only" { profile_names=($(dl_dep.sh -l latest | perl -lne "print for /^\* (\w+):.*$/")) @@ -158,7 +100,7 @@ Done" for dep in "${dependency_names[@]}"; do destination_path=$(readlink -f ${BATS_TEST_TMPDIR}) - run dl_dep.sh -n -d "${dep}@${pn}" "${BATS_TEST_TMPDIR}" + run dl_dep.sh -n -p "${dep}@${pn}" "${BATS_TEST_TMPDIR}" assert_output --regexp \ "Destination path is set to \"${destination_path}\" @@ -172,7 +114,7 @@ Done" done } -@test "[dl_dep.sh] Check valid --dependency option, PROFILE_NAME and PROFILE_VERSION" { +@test "[dl_dep.sh] Check valid --profile option, PROFILE_NAME and PROFILE_VERSION" { profile_versions=($(dl_dep.sh -l | perl -lne "print for /^\s{2}(.*?):$/")) @@ -186,7 +128,7 @@ Done" for dep in "${dependency_names[@]}"; do destination_path=$(readlink -f ${BATS_TEST_TMPDIR}) - run dl_dep.sh -n -d "${dep}@${pn}:${pv}" "${BATS_TEST_TMPDIR}" + run dl_dep.sh -n -p "${dep}@${pn}:${pv}" "${BATS_TEST_TMPDIR}" assert_output --regexp \ "Destination path is set to \"${destination_path}\"