From ca2da5b90eeebe6cddd17aa25fbcb83a5567a822 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 7 Dec 2021 13:25:51 +0100 Subject: [PATCH] user configurable overlay configuration files The following overlay configuration files are read: 1. The file defined in the environment variable PMODULES_OVERLAY_CONF if set. 2. ${HOME}/.Pmodules/overlays.conf 3. ${PMODULES_ROOT}/config/overlays.conf --- Pmodules/modbuild.in | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Pmodules/modbuild.in b/Pmodules/modbuild.in index a9dd620..95a9e40 100755 --- a/Pmodules/modbuild.in +++ b/Pmodules/modbuild.in @@ -413,18 +413,30 @@ declare -r OVERLAY_CONF="${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}/overlays.conf" # Return overlay name *and* directory for an overlay given # by name *or* directory. Search in the config file ${OVERLAY_CONF}. # +# Arguments +# $1: name or directory of overlay +# get_overlay_name_and_dir() { local "$1" # upvar for overlay name local "$2" # upvar for overlay directory - if [[ -r "${OVERLAY_CONF}" ]]; then + local config_files=() + if [[ -v PMODULES_OVERLAY_CONF ]]; then + config_files+=("${PMODULES_OVERLAY_CONF}") + fi + config_files+=("${HOME}/.Pmodules/overlay.conf") + config_files+=("${OVERLAY_CONF}") + for config_file in "${config_files[@]}"; do + [[ -r "${OVERLAY_CONF}" ]] || continue local toks=() while read -a toks; do + [[ -n "${toks[0]}" ]] || continue + [[ ! "${toks[0]}" =~ \#* ]] || continue if [[ ${toks[0]} == $3 ]] || [[ ${toks[1]} == $3 ]]; then std::upvar $1 "${toks[0]}" std::upvar $2 "${toks[1]}" return 0 fi - done < "${OVERLAY_CONF}" + done < "${config_file}" fi return 1 }