Verified Commit 58e50243 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

dep_scripts: Separate dependency and profile execution modes

parent a7383164
Loading
Loading
Loading
Loading
+23 −10
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ SOURCE_DIR=""
INSTALL_DIR=""
PERFORM_TEST=

EXECUTION_MODE=

DEFAULT_PROFILE="default"
DEFAULT_VERSION="latest"
PROFILE_NAME=${DEFAULT_PROFILE}
@@ -47,11 +49,10 @@ declare -A PROFILE_CLONEDEPS_ARGS PROFILE_CLONEDEPS_PATCHES

usage_short() {
	echo "
usage: compile_dep.sh [-h]
                      [-l [PROFILE_NAME:[VERSION]]]
                      [-p PROFILE_NAME[:VERSION]]
                      [-d DEPENDENCY_NAME[[@PROFILE_NAME][:VERSION]]
                      [-j COMPILE_CORES]
usage: compile_dep.sh [ -p PROFILE_NAME[:PROFILE_VERSION] |
                        -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] ]
                      [ -l [PROFILE_NAME:[PROFILE_VERSION]] ]
                      [ -j COMPILE_CORES] [ -h ]
                      SOURCES_PATH INSTALL_PATH
	"
}
@@ -71,20 +72,21 @@ optional arguments:
    -h, --help  shows this help message and exits
    -l, --list-dependencies
                list dependencies available for building and installation
    -p, --profile PROFILE_NAME[:VERSION]
    -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
                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.8.0', 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][:VERSION]]
    -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 VERSION is unspecified, the
                'latest' version of the specified profile will be used.
                profile will be used. Similarly, if PROFILE_VERSION is
                unspecified, the 'latest' version of the specified profile will
                be used.
    -j, --compilecores COMPILE_CORES
                number of cores that are used to compile the dependencies
                defaults to number of available cores
@@ -92,6 +94,12 @@ optional arguments:
"
}

exec_mode_error() {
    echo "ERROR: --profile and --dependency options are mutually exclusive"
    usage_short
    exit 1
}

list_versions() {

    if [[ ! -d "${PROFILES_DIR}" ]]; then
@@ -274,6 +282,9 @@ 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
@@ -292,6 +303,8 @@ while [[ $# -gt 0 ]]; do
        ;;
    -d | --dependency)

        [ -n "${EXECUTION_MODE}" ] && exec_mode_error || EXECUTION_MODE='dependency'

        if [[ -z "$2" ]]; then
            echo "ERROR: Missing argument for -d/--dependency option"
            exit
+23 −10
Original line number Diff line number Diff line
@@ -32,6 +32,8 @@ COMMON_GIT_FLAGS="--quiet --single-branch -c advice.detachedHead=false"
PATCH_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PATCH_DIR="${PATCH_DIR}/patches"
DEPENDENCY=""

EXECUTION_MODE=
VERBOSE=false

DEFAULT_PROFILE="default"
@@ -289,10 +291,9 @@ wgetdeps() {

usage_short() {
    echo "
usage: dl_dep.sh [-h]
                 [-l [[PROFILE_NAME:]VERSION]]
                 [-p PROFILE_NAME[:VERSION]]
                 [-d DEPENDENCY_NAME[[@PROFILE_NAME][:VERSION]]
usage: dl_dep.sh [ -p PROFILE_NAME[:PROFILE_VERSION] |
                   -d DEPENDENCY_NAME[[@PROFILE_NAME][:PROFILE_VERSION]] ]
                 [ -l [[PROFILE_NAME:]PROFILE_VERSION] ] [ -h ]
                 DESTINATION_PATH
	"
}
@@ -309,26 +310,32 @@ positional arguments:

optional arguments:
        -h, --help              shows this help message and exits
        -l, --list-dependencies [[PROFILE_NAME:]VERSION]
        -l, --list-dependencies [[PROFILE_NAME:]PROFILE_VERSION]
                                list dependency configuration profiles available for download
        -p, --profile PROFILE_NAME[:VERSION]
        -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 
                                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.8.0', 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][:VERSION]]
        -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 VERSION is unspecified, the
                                'latest' version of the specified profile will be used.
                                profile will be used. Similarly, if PROFILE_VERSION is unspecified,
                                the 'latest' version of the specified profile will be used.
        -v, --verbose           Increase download verbosity
        "
}

exec_mode_error() {
    echo "ERROR: --profile and --dependency options are mutually exclusive"
    usage_short
    exit 1
}

# load default profile for now, might be overridden later
load_profile "${DEFAULT_PROFILE}" "${DEFAULT_VERSION}"

@@ -341,6 +348,9 @@ 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
@@ -360,6 +370,9 @@ while [[ $# -gt 0 ]]; do
        ;;

    -d | --dependency)

        [ -n "${EXECUTION_MODE}" ] && exec_mode_error || EXECUTION_MODE='dependency'

        if [[ -z "$2" ]]; then
            echo "ERROR: Missing argument for -d/--dependency option"
            exit 1