diff --git a/src/libpbuild.bash b/src/libpbuild.bash index 1901665..a89ff7b 100644 --- a/src/libpbuild.bash +++ b/src/libpbuild.bash @@ -27,115 +27,116 @@ pbcore::err(){ } pbcore::err_invalid_unpacker(){ - pbcore::err ${__PB_EC['CONFIG']} "Unsupported tool for unpacking -- '$1'" + pbcore::err "${__PB_EC['CONFIG']}" "Unsupported tool for unpacking -- '$1'" } pbcore::err_autotools_config_nexists(){ - pbcore::err ${__PB_EC['CONFIG']} "autotools configuration not available, aborting..." + pbcore::err "${__PB_EC['CONFIG']}" "autotools configuration not available, aborting..." } pbcore::err_cmake_config_nexists(){ - pbcore::err ${__PB_EC['CONFIG']} "CMake configuration not available, aborting..." + pbcore::err "${__PB_EC['CONFIG']}" "CMake configuration not available, aborting..." } pbcore::err_setting_relstage(){ - pbcore::err ${__PB_EC['CONFIG']} \ + pbcore::err "${__PB_EC['CONFIG']}" \ "release cannot be set to '${1}'" \ - "since the dependency '${2}' is '${3}!" + "since the dependency '${2}' is '${3}'!" } pbcore::err_func_not_defined(){ - pbcore::err ${__PB_EC['CONFIG']} "function '${1}' is not defined!" + pbcore::err "${__PB_EC['CONFIG']}" "function '${1}' is not defined!" } pbcore::err_sub_package_name_missing(){ - pbcore::err ${__PB_EC['CONFIG']} "Name of sub-package missing in" \ + pbcore::err "${__PB_EC['CONFIG']}" "Name of sub-package missing in" \ $'\n'"==="$'\n'"${1}"$'\n'"==="$'\n' } + pbcore::err_sub_package_version_missing(){ - pbcore::err ${__PB_EC['CONFIG']} "Version of sub-package not specified in" \ + pbcore::err "${__PB_EC['CONFIG']}" "Version of sub-package not specified in" \ $'\n'"==="$'\n'"${1}"$'\n'"==="$'\n' } pbcore::err_invalid_value(){ - pbcore::err ${__PB_EC['CONFIG']} "Invalid value '$1' for '$2'!" + pbcore::err "${__PB_EC['CONFIG']}" "Invalid value '$1' for '$2'!" } pbcore::err_group_dependency(){ - pbcore::err ${__PB_EC['CONFIG']} "Issue with group dependencies:" \ - "required environemnt variables for '$1' are not set!" + pbcore::err "${__PB_EC['CONFIG']}" "Issue with group dependencies:" \ + "required environment variables for '$1' are not set!" } pbcore::err_invalid_group_name(){ - pbcore::err ${__PB_EC['CONFIG']} "The group name '$1' is not allowed." \ + pbcore::err "${__PB_EC['CONFIG']}" "The group name '$1' is not allowed." \ "Note: hierarchical group names are case-sensitive!" } pbcore::err_file_not_found(){ - pbcore::err ${__PB_EC['NEXISTS']} "file '${1}' not found!" + pbcore::err "${__PB_EC['NEXISTS']}" "file '${1}' not found!" } pbcore::err_binary_nexists(){ - pbcore::err ${__PB_EC['NEXISTS']} "binary '${1}' does not exist or is not executable!" + pbcore::err "${__PB_EC['NEXISTS']}" "binary '${1}' does not exist or is not executable!" } pbcore::err_modulefile_nexists(){ - pbcore::err ${__PB_EC['NEXISTS']} "modulefile '${1}' does not exist!" + pbcore::err "${__PB_EC['NEXISTS']}" "modulefile '${1}' does not exist!" } pbcore::err_module_nexists(){ - pbcore::err ${__PB_EC['NEXISTS']} "module '${1}' does not exist!" + pbcore::err "${__PB_EC['NEXISTS']}" "module '${1}' does not exist!" } pbcore::err_configure_failed(){ - pbcore::err ${__PB_EC['CMD']} "configure failed" + pbcore::err "${__PB_EC['CMD']}" "configure failed" } pbcore::err_cmake_failed(){ - pbcore::err ${__PB_EC['CMD']} "CMake failed" + pbcore::err "${__PB_EC['CMD']}" "CMake failed" } pbcore::err_compilation_failed(){ - pbcore::err ${__PB_EC['CMD']} "compilation failed" + pbcore::err "${__PB_EC['CMD']}" "compilation failed" } pbcore::err_installation_failed(){ - pbcore::err ${__PB_EC['CMD']} "installation failed" + pbcore::err "${__PB_EC['CMD']}" "installation failed" } pbcore::err_download(){ - pbcore::err ${__PB_EC['CMD']} "downloading source file '${1}' failed!" + pbcore::err "${__PB_EC['CMD']}" "downloading source file '${1}' failed!" } pbcore::err_unpack(){ - pbcore::err ${__PB_EC['CMD']} "unpacking file '${1}' failed!" + pbcore::err "${__PB_EC['CMD']}" "unpacking file '${1}' failed!" } pbcore::err_hashsum(){ - pbcore::err ${__PB_EC['CMD']} "SHA256 hash mismatch for file '${1}'!" + pbcore::err "${__PB_EC['CMD']}" "SHA256 hash mismatch for file '${1}'!" } pbcore::err_patching(){ - pbcore::err ${__PB_EC['CMD']} "applying patch '${1}' failed!" + pbcore::err "${__PB_EC['CMD']}" "applying patch '${1}' failed!" } pbcore::err_loading_module(){ - pbcore::err ${__PB_EC['CMD']} "loading module '${1}' failed!" + pbcore::err "${__PB_EC['CMD']}" "loading module '${1}' failed!" } pbcore::err_chdir(){ - pbcore::err ${__PB_EC['CMD']} "Changing to directory '${1}' failed!" + pbcore::err "${__PB_EC['CMD']}" "Changing to directory '${1}' failed!" } pbcore::err_aborting(){ - pbcore::err ${__PB_EC['CMD']} "function '${1}' return with error. Aborting!" + pbcore::err "${__PB_EC['CMD']}" "function '${1}' return with error. Aborting!" } pbcore::err_building_subpkg(){ - pbcore::err ${__PB_EC['CMD']} "Building sub-package '${1}' failed!" + pbcore::err "${__PB_EC['CMD']}" "Building sub-package '${1}' failed!" } # :FIXME: maybe we should output file name, function name and line number pbcore::err_internal(){ - pbcore::err ${__PB_EC['INTERNAL']} "oops: internal error!" + pbcore::err "${__PB_EC['INTERNAL']}" "oops: internal error!" } #****************************************************************************** @@ -252,7 +253,7 @@ readonly -f pbuild::use_flag ## first directory will be stripped. ## 7z: 7z doesn't support stripping directories. The corresponding ## argument will be ignored. -## none: none just copyies the source file to the given target directory. +## none: none just copies the source file to the given target directory. ## ## Arguments: ## $1 - the source file @@ -360,7 +361,8 @@ pbuild::prep() { fi if [[ -n "${ModuleConfig[patch_file:$i]}" ]]; then - local -- patch_file=$(envsubst <<<"${ModuleConfig[patch_file:$i]}") + local -- patch_file='' + patch_file=$(envsubst <<<"${ModuleConfig[patch_file:$i]}") local -- patch_strip="${ModuleConfig[patch_strip:$i]:-${PATCH_STRIP_DEFAULT}}" [[ "${patch_strip}" =~ ^[0-9]+$ ]] || \ pbcore::err_invalid_value "${patch_strip}" 'patch_strip' @@ -386,9 +388,9 @@ pbuild::prep() { } ## -## pbuild::prep_pip3 - create a Python virtual environemnt +## pbuild::prep_pip3 - create a Python virtual environment ## -## Create a Python virtual environemnt in the installation directory of +## Create a Python virtual environment in the installation directory of ## the module. ## ## Arguments: @@ -450,7 +452,6 @@ pbuild::configure() { ;; esac local -a config_args=() - local -a config_args=() if [[ -n "${ModuleConfig['configure_args']}" ]]; then readarray -t config_args <<< "${ModuleConfig['configure_args']}" fi @@ -495,13 +496,13 @@ pbuild::compile() { local -- tmp_v="$V" local -- restore='no' local -- tmp_verbose='' - if [[ -v VERBOSE ]]; then - tmp_verbose="${VERBOSE}" - restore='yes' - fi if (( Options['verbose'] > 0 )); then - declare -g V=1 - declare -g VERBOSE=1 + if [[ -v VERBOSE ]]; then + tmp_verbose="${VERBOSE}" + restore='yes' + fi + declare -gx V=1 + declare -gx VERBOSE=1 else unset V fi @@ -509,9 +510,13 @@ pbuild::compile() { local -i num_jobs="${Options['num_jobs']}" make -j${num_jobs} -e || pbcore::err_compilation_failed declare -gx V="${tmp_v}" - if [[ "${restore}" == 'yes' ]]; then - VERBOSE="${tmp_verbose}" - fi + if (( Options['verbose'] > 0 )); then + if [[ "${restore}" == 'yes' ]]; then + VERBOSE="${tmp_verbose}" + else + unset VERBOSE + fi + fi } ## @@ -699,7 +704,9 @@ pbcore::unpack() { local -r unpacker="$5" if ! pbuild::unpack "${fname}" "${target_dir}" "${strip}" "${unpacker}"; then - if [[ -n "${src_dir}" && "${src_dir}" != "${BUILDBLOCK_DIR}" ]]; then + if [[ -n "${src_dir}" \ + && "${src_dir}" != "${BUILDBLOCK_DIR}" \ + && "${src_dir}" != "${BUILDBLOCK_DIR}/files" ]]; then rm -f "${fname}" fi pbcore::err_unpack "${fname}" @@ -822,7 +829,7 @@ pbcore::load_overlays(){ [[ -n ${ModuleConfig['use_overlays']} ]] || return 0 local -a use_overlays=() - readarray -t use_overlays <<< "${config['use_overlays']}" + readarray -t use_overlays <<< "${ModuleConfig['use_overlays']}" pbcore::info "using overlays ${use_overlays[*]}" eval "$( modulecmd bash use "${use_overlays[@]}" )" @@ -862,7 +869,8 @@ pbcore::load_dependencies() { fi pbcore::info "Loading module: ${m}" - local output="$(modulecmd bash load "${m}")"; + local output='' + output="$(modulecmd bash load "${m}")"; eval "${output}" pbcore::is_loaded "$m" || pbcore::err_loading_module "${m}" done @@ -943,7 +951,7 @@ pbcore::set_mod_dir_and_prefix() { esac mod_dir+="${mod_name}" ModuleConfig['modulefile_dir']="${mod_dir}" - echo "${prefix}" + PREFIX="${prefix}" } ## @@ -1124,7 +1132,8 @@ pbcore::set_relstages() { local version="${config_file##*/}" version="${version/.config-}" local name="${ModuleConfig['name']}/${version}" - local relstage=$(awk '/relstage:/ {print $2}' "${config_file}") + local relstage='' + relstage=$(awk '/relstage:/ {print $2}' "${config_file}") case ${relstage} in unstable ) echo " module-tag u ${name}" \ @@ -1152,7 +1161,7 @@ pbcore::set_relstages() { ## was specified. ## ## Arguments: -## noone +## none ## pbcore::cleanup_modulefiles(){ [[ "${Options['is_subpkg']}" == 'yes' ]] && return 0 @@ -1160,7 +1169,7 @@ pbcore::cleanup_modulefiles(){ local -r ol_name="${ModuleConfig['overlay']}" local -r ol_modulefiles_root="${OverlayInfo[${ol_name}:modulefiles_root]}" local -r modulefile_dir="${ModuleConfig['modulefile_dir']}" - local -r mod_version="${ModuleConfig['mod_version']}" + local -r mod_version="${ModuleConfig['version']}" local -- ol='' for ol in "${Overlays[@]}"; do @@ -1299,16 +1308,16 @@ pbcore::remove_file() { ## none ## pbcore::remove_module() { - local -e modulefile_dir="${ModuleConfig['modulefile_dir']}" + local -r modulefile_dir="${ModuleConfig['modulefile_dir']}" if [[ -n "${PREFIX}" && -d "${PREFIX}" && "${PREFIX}" != '/' ]]; then pbcore::info "removing all files in '${PREFIX}' ..." rm -rf "${PREFIX}" fi - pbcore::remove_file "${modulefile_dir}/${rm_cfg['version']}" - pbcore::remove_file "${modulefile_dir}/.release-${rm_cfg['version']}" - pbcore::remove_file "${modulefile_dir}/.config-${rm_cfg['version']}" - pbcore::remove_file "${modulefile_dir}/.deps-${rm_cfg['version']}" + pbcore::remove_file "${modulefile_dir}/${ModuleConfig['version']}" + pbcore::remove_file "${modulefile_dir}/.release-${ModuleConfig['version']}" + pbcore::remove_file "${modulefile_dir}/.config-${ModuleConfig['version']}" + pbcore::remove_file "${modulefile_dir}/.deps-${ModuleConfig['version']}" rmdir -p "${modulefile_dir}" 2>/dev/null || : } @@ -1369,7 +1378,7 @@ pbcore::build_sub_packages(){ * ) cfg::err_invalid_key \ 'ModuleConfig' \ - "in requested sub-package '${i}" \ + "in requested sub-package '${i}'" \ "${key}" ;; esac @@ -1400,9 +1409,8 @@ pbcore::build_sub_packages(){ ## TBW ## pbcore::build(){ - declare -ng ModuleConfig="$1" - declare -ng Options="$2" - shift 2 + declare -ng Options="$1" + shift 1 local -a with_modules=( "$@" ) ModuleConfig['namevers']="${ModuleConfig['name']}/${ModuleConfig['version']}" @@ -1438,7 +1446,7 @@ pbcore::build(){ source "${BUILD_SCRIPT}" if [[ "${Options['is_subpkg']}" != 'yes' ]]; then - PREFIX=$(pbcore::set_mod_dir_and_prefix) + pbcore::set_mod_dir_and_prefix else PREFIX="${Options['prefix']}" # sub-packages don't have a modulefile! diff --git a/src/libpmodules.bash b/src/libpmodules.bash index 3300594..567275e 100644 --- a/src/libpmodules.bash +++ b/src/libpmodules.bash @@ -7,12 +7,10 @@ set -o nounset shopt -s extglob shopt -s nullglob -(( BASH_VERSINFO[0] >= 5 && BASH_VERSINFO[1] >= 3 )) || \ - { - printf "%s\n" "Bash 5.3+ required" 1>&2 - exit 255 - } - +if (( BASH_VERSINFO[0] < 5 || (BASH_VERSINFO[0] == 5 && BASH_VERSINFO[1] < 3) )); then + echo "Bash 5.3+ is required." 1>&2 + exit 255 +fi declare -r __MODULEFILES_DIR__='modulefiles' declare -g PMODULES_DISTFILESDIR PMODULES_TMPDIR diff --git a/src/libstd.bash b/src/libstd.bash index d5468d6..f045a15 100644 --- a/src/libstd.bash +++ b/src/libstd.bash @@ -813,7 +813,12 @@ yml::get_keys(){ local -- __gk_str __gk_str="$(yq -N "${__gk_key}" <<<"${__gk_text}")" || \ yml::die_parsing "${__gk_text}" - if [[ -z "${__gk_str}" || "${__gk_str}" == 'null' || "${__gk_str}" == 'false' ]]; then + if [[ -z "${__gk_str}" \ + || "${__gk_str}" == 'null' \ + || "${__gk_str}" == 'false' \ + || "${__gk_str}" == '{}' \ + || "${__gk_str}" == '[]' \ + ]]; then __gk_keys=() return 0 fi diff --git a/src/modbuild.in b/src/modbuild.in index a6f6f92..c380fa6 100644 --- a/src/modbuild.in +++ b/src/modbuild.in @@ -55,7 +55,7 @@ source "${prefix}/lib/libstd.bash" || { unset mydir ## -## Exit script on errror. +## Exit script on error. ## ## Arguments: ## $1 - exit code @@ -79,14 +79,14 @@ __PB_EC['CMD']=4 __PB_EC['INTERNAL']=255 [[ -v PMODULES_HOME ]] && \ - std::die ${__PB_EC['CMD']} \ + std::die "${__PB_EC['CMD']}" \ "%s " \ "This version of modbuild cannot be used with the modulecmd from Pmodules!" source "${prefix}/lib/libpmodules.bash" || \ - std::die ${__PB_EC['INTERNAL']} "Oops: cannot source library -- '$_'" + std::die "${__PB_EC['INTERNAL']}" "Oops: cannot source library -- '$_'" source "${prefix}/lib/libpbuild.bash" || \ - std::die ${__PB_EC['INTERNAL']} "Oops: cannot source library -- '$_'" + std::die "${__PB_EC['INTERNAL']}" "Oops: cannot source library -- '$_'" unset prefix # these variables must be exported for envsubst(1) @@ -253,17 +253,17 @@ args::info_version(){ } args::err_missing_value(){ - std::die ${__PB_EC['ARGS']} "Option '%s': missing value" "$1" + std::die "${__PB_EC['ARGS']}" "Option '%s': missing value" "$1" } args::err_invalid_value(){ - std::die ${__PB_EC['ARGS']} "Option '%s': invalid value '%s'" "$1" "$2" + std::die "${__PB_EC['ARGS']}" "Option '%s': invalid value '%s'" "$1" "$2" } args::err_invalid_option(){ - std::die ${__PB_EC['ARGS']} "Option '%s': invalid" "$1" + std::die "${__PB_EC['ARGS']}" "Option '%s': invalid" "$1" } args::err_buildscript_missing(){ - std::die ${__PB_EC['ARGS']} "Build script argument missing!" + std::die "${__PB_EC['ARGS']}" "Build script argument missing!" } args::parse() { @@ -462,7 +462,7 @@ args::parse() { # set system if not set on the cmd-line opt_system="${opt_system:-$(std::get_os_release)}" - if (( ${BuildOpts['num_jobs']} == 0 )); then + if (( BuildOpts['num_jobs'] == 0 )); then BuildOpts['num_jobs']=$(std::get_num_cores) (( BuildOpts['num_jobs'] > 10 )) && BuildOpts['num_jobs']=10 || : fi @@ -590,87 +590,62 @@ declare -A hierarchical_groups=( ['hdf5_serial']='compiler hdf5_serial' ) +cfg::err(){ + local -- name="${ModuleConfig['name']}/" + name+="${ModuleConfig['version']:-${ModuleConfig['version_pattern']}}" + std::die "$1" "%s " "${name}:" "${@:2}" +} + cfg::err_missing_group_dependencies(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ - "Error: missing group dependency for module in group '${__cfg['group']}' -" \ - "$2" + cfg::err "${__PB_EC['CONFIG']}" \ + "Error: missing group dependency for module in group '${ModuleConfig['group']}' -" \ + "$1" } cfg::err_invalid_group_dependency(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ - "Error: invalid group dependency for module in group '${__cfg['group']}' -" \ - "$2" + cfg::err "${__PB_EC['CONFIG']}" \ + "Error: invalid group dependency for module in group '${ModuleConfig['group']}' -" \ + "$1" } cfg::err_invalid_variants_block(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ - "Error: invalid type of variants block: must be '!!seq' but is - '$2'!" + cfg::err "${__PB_EC['CONFIG']}" \ + "Error: invalid type of variants block: must be '!!seq' but is - " \ + "$1" } cfg::err_invalid_value(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ - "Error: invalid value for key '$3' in $2 - '$4'" + cfg::err "${__PB_EC['CONFIG']}" \ + "Error: invalid value for key '$2' in $1 - $3" } cfg::err_invalid_key(){ - local -n __cfg="$1" - local -r str="$2" - shift 2 - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ - "Error: invalid key(s) in ${str} -" "$@" + cfg::err "${__PB_EC['CONFIG']}" \ + "Error: invalid key(s) in ${1} -" "${@:2}" } cfg::err_wrong_module_type(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ - "Module type is '$2' but was called as - '$3'!" + cfg::err "${__PB_EC['CONFIG']}" \ + "Module type is '$1' but was called as - $2!" } cfg::err_invalid_module_type(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ - "Invalid module type - '$2'" + cfg::err "${__PB_EC['CONFIG']}" \ + "Invalid module type - $1" } cfg::err_undef_group(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CMD']} "%s " \ - "${name}:" \ + cfg::err "${__PB_EC['CONFIG']}" \ "Error: group must be defined before group dependencies!" } cfg::err_group_not_hierarchical(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ - "Error: group dependencies defined for non-hierarchical group '${__cfg['group']}'!" + cfg::err "${__PB_EC['CONFIG']}" \ + "Error: group dependencies defined for non-hierarchical group '${ModuleConfig['group']}'!" } cfg::err_ctrl_char_in_version_key(){ - local -n __cfg="$1" - local -r name="${__cfg['name']}/${__cfg['version']:-${__cfg['version_pattern']}}" - std::die ${__PB_EC['CONFIG']} "%s " \ - "${name}:" \ + cfg::err "${__PB_EC['CONFIG']}" \ "Control characters in version keys are forbidden!" } @@ -681,21 +656,19 @@ cfg::err_ctrl_char_in_version_key(){ ## module configuration structure. ## ## Arguments: -## $1 - reference to dictionary with module configuration +## none ## ## Used global variables: ## opt_with_dict ## cfg::parse_group_deps(){ - local -n _cfg="$1" - local -r _input_yml="${_cfg['group_deps:yaml']}" + local -r _input_yml="${ModuleConfig['group_deps:yaml']}" - local -- mod_group="${_cfg['group']}" + local -- mod_group="${ModuleConfig['group']}" - [[ -n "${mod_group}" ]] || \ - cfg::err_undef_group '_cfg' + [[ -n "${mod_group}" ]] || cfg::err_undef_group [[ -v hierarchical_groups[${mod_group,,}] ]] || \ - cfg::err_group_not_hierarchical '_cfg' + cfg::err_group_not_hierarchical # get specified group dependencies local -- group='' local -a groups=() @@ -703,12 +676,12 @@ cfg::parse_group_deps(){ for group in "${groups[@]}"; do # is ${group} a hierarchical group name? [[ -v hierarchical_groups[${group,,}] ]] || \ - cfg::err_invalid_group_dependency '_cfg' "${group}" + cfg::err_invalid_group_dependency "${group}" # is this in the list of required group dependencies? std::array::contains "${group,,}" \ ${hierarchical_groups[${mod_group,,}]} || \ - cfg::err_invalid_group_dependency '_cfg' "${group}" + cfg::err_invalid_group_dependency "${group}" local -- key local -a keys=() local -a with_modules=() @@ -737,12 +710,12 @@ cfg::parse_group_deps(){ fi local -- str printf -v str "%s\n" "${with_modules[@]}" - _cfg[group_deps:${group,,}]="${str:0:-1}" + ModuleConfig[group_deps:${group,,}]="${str:0:-1}" done # are all required hierarchical dependencies defined? for group in ${hierarchical_groups[${mod_group,,}]}; do - [[ -n "${_cfg[group_deps:${group,,}]}" ]] || \ - cfg::err_missing_group_dependencies '_cfg' "${group}" + [[ -n "${ModuleConfig[group_deps:${group,,}]}" ]] || \ + cfg::err_missing_group_dependencies "${group}" done } @@ -753,12 +726,10 @@ cfg::parse_group_deps(){ ## Arguments: ## $1 - [in] reference to YAML formatted string ## $2 - [in] key of variant configuration -## $3 - [out] reference to Bash dictionary ## cfg::get_config(){ local -n yml_input="$1" local -- cfg_key="$2" - local -n cfg="$3" local -- key='' local -- value='' @@ -780,10 +751,10 @@ cfg::get_config(){ yml_input \ "${cfg_key}.build_functions.${key}" || \ yml::die_parsing "${yml_input}" - cfg[target_funcs:${key}]="${value}" + ModuleConfig[target_funcs:${key}]="${value}" ;; * ) - cfg::err_invalid_key 'cfg' 'build_functions' "${key}" + cfg::err_invalid_key 'build_functions' "${key}" ;; esac done @@ -810,13 +781,12 @@ cfg::get_config(){ first_match ) : ;; * ) cfg::err_invalid_value \ - 'cfg' \ 'config section' \ "${key}" \ "${value}" ;; esac - cfg[${key,,}]="${value}" + ModuleConfig[${key,,}]="${value}" ;; compile_in_sourcetree ) yml::get_value \ @@ -825,14 +795,13 @@ cfg::get_config(){ "${cfg_key}.${key}" '!!bool' case ${value,,} in true ) - cfg[${key,,}]='yes' + ModuleConfig[${key,,}]='yes' ;; false ) - cfg[${key,,}]='no' + ModuleConfig[${key,,}]='no' ;; * ) cfg::err_invalid_value \ - 'cfg' \ 'config section' \ "${key}" \ "${value}" @@ -846,11 +815,10 @@ cfg::get_config(){ "${cfg_key}.${key}" '!!str' case ${value,,} in auto | cmake | autotools ) - cfg[${key,,}]="${value,,}" + ModuleConfig[${key,,}]="${value,,}" ;; * ) cfg::err_invalid_value \ - 'cfg' \ 'config section' \ "${key}" \ "${value}" @@ -863,21 +831,21 @@ cfg::get_config(){ value \ yml_input \ "${cfg_key}.${key}" '!!str' - cfg[${key,,}]="${value}" + ModuleConfig[${key,,}]="${value}" ;; overlay ) yml::get_value \ value \ yml_input \ "${cfg_key}.${key}" '!!str' - cfg[${key,,}]="${value}" + ModuleConfig[${key,,}]="${value}" ;; group_deps ) yml::get_value \ value \ yml_input \ "${cfg_key}.${key}" '!!map' - cfg['group_deps:yaml']="${value}" + ModuleConfig['group_deps:yaml']="${value}" ;; use_flags ) yml::get_seq \ @@ -887,7 +855,7 @@ cfg::get_config(){ yml::die_parsing "${yml_input}" local -a tmp=() readarray -t tmp <<<"${value}" - cfg[${key,,}]=" ${tmp[*]} " + ModuleConfig[${key,,}]=" ${tmp[*]} " ;; relstage ) yml::get_value \ @@ -896,14 +864,13 @@ cfg::get_config(){ "${cfg_key}.${key}" '!!str' case ${value,,} in unstable | stable | deprecated ) - cfg[${key,,}]="${value,,}" + ModuleConfig[${key,,}]="${value,,}" ;; remove | removed ) - cfg[${key,,}]='remove' + ModuleConfig[${key,,}]='remove' ;; * ) cfg::err_invalid_value \ - 'cfg' \ 'config section' \ "${key}" \ "${value}" @@ -915,21 +882,21 @@ cfg::get_config(){ value \ yml_input \ "${cfg_key}.${key}" '!!seq' - cfg[${key,,}]="${value}" + ModuleConfig[${key,,}]="${value}" ;; urls | sources ) yml::get_value \ value \ yml_input \ "${cfg_key}.${key}" '!!seq' - cfg::parse_urls 'set' "${value}" cfg + cfg::parse_urls 'set' "${value}" ;; urls+ | sources+ ) yml::get_value \ value \ yml_input \ "${cfg_key}.${key}" '!!seq' - cfg::parse_urls 'add' "${value}" cfg + cfg::parse_urls 'add' "${value}" ;; build_requires | configure_args | docfiles | patch_files \ | runtime_deps | systems | use_overlays | variant ) @@ -938,7 +905,7 @@ cfg::get_config(){ yml_input \ "${cfg_key}.${key}" || \ yml::die_parsing "${yml_input}" - cfg[${key,,}]="${value}" + ModuleConfig[${key,,}]="${value}" ;; kernels ) yml::get_seq \ @@ -952,12 +919,11 @@ cfg::get_config(){ for item in "${items[@]}"; do [[ -v KernelNames[${item}] ]] || \ cfg::err_invalid_value \ - 'cfg' \ 'config section' \ 'kernel' \ "${item}" done - cfg[${key,,}]="${value}" + ModuleConfig[${key,,}]="${value}" ;; target_cpus ) yml::get_seq \ @@ -971,12 +937,11 @@ cfg::get_config(){ for item in "${items[@]}"; do [[ -v TargetCPUs[${item}] ]] || \ cfg::err_invalid_value \ - 'cfg' \ 'config section' \ 'CPU' \ "${item}" done - cfg[${key,,}]="${value}" + ModuleConfig[${key,,}]="${value}" ;; 'configure_args+' | 'docfiles+' | 'patch_files+' ) yml::get_seq \ @@ -985,28 +950,27 @@ cfg::get_config(){ "${cfg_key}.${key}" || \ yml::die_parsing "${yml_input}" key="${key:0:-1}" - if [[ -z "${cfg[${key,,}]}" ]]; then - cfg[${key,,}]="${value}" + if [[ -z "${ModuleConfig[${key,,}]}" ]]; then + ModuleConfig[${key,,}]="${value}" else - cfg[${key,,}]+=$'\n'"${value}" + ModuleConfig[${key,,}]+=$'\n'"${value}" fi ;; * ) - cfg::err_invalid_key 'cfg' 'config section' "${key}" + cfg::err_invalid_key 'config section' "${key}" ;; esac done } cfg::check_config(){ - local -n __cc_cfg="$1" - local -- __cc_ol="${__cc_cfg['overlay']}" - [[ -v OverlayInfo[${__cc_ol}:install_root] ]] || \ + local -- ol_name="${ModuleConfig['overlay']}" + [[ -v OverlayInfo[${ol_name}:install_root] ]] || \ std::die 2 "%s" \ - "Overlay doesn't exist - ${__cc_ol}" + "Overlay doesn't exist - ${ol_name}" - [[ -n "${__cc_cfg['group_deps:yaml']}" ]] && cfg::parse_group_deps __cc_cfg + [[ -n "${ModuleConfig['group_deps:yaml']}" ]] && cfg::parse_group_deps } ## @@ -1015,16 +979,14 @@ cfg::check_config(){ ## Arguments: ## $1 - mode: set or add ## $2 - sources/urls in YAML format -## $3 - reference to a dictionary holding the configuration ## cfg::parse_urls(){ local -r mode="$1" local -- yaml="$2" - local -n _cfg="$3" local -i i=0 len=0 n=0 yml::get_seq_length len yaml . - [[ "${mode}" == 'add' ]] && n=${_cfg['num_sources']} + [[ "${mode}" == 'add' ]] && n=${ModuleConfig['num_sources']} for ((i=0; i 0 )); then +if (( BuildOpts['verbose'] > 0 )); then exec > >(tee -a "${logfile}") else exec > >(cat >> "${logfile}")