From c3be031e07a7338ae80123eb4d1ac8c843f02beb Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 26 Jun 2015 17:40:25 +0200 Subject: [PATCH 1/6] lib/libpmodules.bash: - set PATH after sourcing lib.bash --- lib/libpmodules.bash | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libpmodules.bash b/lib/libpmodules.bash index 43c52c8..9440480 100644 --- a/lib/libpmodules.bash +++ b/lib/libpmodules.bash @@ -1,7 +1,5 @@ #!/bin/bash -PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin - # disable auto-echo feature of 'cd' unset CDPATH @@ -19,9 +17,15 @@ declare -rx BUILD_BASEDIR=$(abspath $SHLIBDIR/..) - +PATH=/usr/bin:/bin:/usr/sbin:/sbin declare -r OS=$(uname -s) +if [[ "${OS}" == "Darwin" ]]; then + # :FIXME: why do we need this? + [[ -d "/opt/X11/bin" ]] && PATH+=':/opt/X11/bin' +fi + + # number of parallel make jobs declare -i JOBS=3 From 364270b6c736471a3cbbb6a2de5c74e3ce7b4cd8 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 26 Jun 2015 17:43:29 +0200 Subject: [PATCH 2/6] scripts/Bootstrap/compile_pmodules.sh - cleanup $PMODULES_DIR before compiling --- scripts/Bootstrap/compile_pmodules.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/Bootstrap/compile_pmodules.sh b/scripts/Bootstrap/compile_pmodules.sh index 45f457c..0b5ad0a 100755 --- a/scripts/Bootstrap/compile_pmodules.sh +++ b/scripts/Bootstrap/compile_pmodules.sh @@ -8,6 +8,10 @@ source "${BOOTSTRAP_DIR}/Pmodules_version.conf" unset PMODULES_HOME source "/opt/psi/config/environment.bash" +if [[ -n ${PMODULES_DIR} ]] && [[ "${PMODULES_DIR}" != "/" ]] && [[ -d "${PMODULES_DIR}" ]]; then + rm -rf "${PMODULES_DIR}" +fi + ${BOOTSTRAP_DIR}/coreutils/build --bootstrap --disable-cleanup || { echo "compiling 'coreutils' failed!"; exit 1; } ${BOOTSTRAP_DIR}/gettext/build --bootstrap --disable-cleanup || { echo "compiling 'gettext' failed!"; exit 1; } ${BOOTSTRAP_DIR}/getopt/build --bootstrap --disable-cleanup || { echo "compiling 'getopt' failed!"; exit 1; } From 7ceec6e288873bb42e2b83dd16f1458e92938197 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 26 Jun 2015 17:44:41 +0200 Subject: [PATCH 3/6] scripts/Bootstrap/Pmodules/csh: - set correct exec_prefix - do not set MODULESHOME --- scripts/Bootstrap/Pmodules/csh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/Bootstrap/Pmodules/csh b/scripts/Bootstrap/Pmodules/csh index 52f3934..93c2d64 100644 --- a/scripts/Bootstrap/Pmodules/csh +++ b/scripts/Bootstrap/Pmodules/csh @@ -3,7 +3,7 @@ if ($?tcsh) then else set modules_shell="csh" endif -set exec_prefix='/usr/bin' +set exec_prefix = $PMODULES_HOME/bin' set prefix="" set postfix="" @@ -34,7 +34,6 @@ unset exec_prefix unset prefix unset postfix -setenv MODULESHOME /usr/share/Modules if (! $?MODULEPATH ) then setenv MODULEPATH `sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath` From fde9205f163ad3624bb851d0aa3e7eb58cf4f73e Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 26 Jun 2015 17:45:32 +0200 Subject: [PATCH 4/6] scripts/Bootstrap/Pmodules/environment.csh.in - fixes - adapted to new variable names --- scripts/Bootstrap/Pmodules/environment.csh.in | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/Bootstrap/Pmodules/environment.csh.in b/scripts/Bootstrap/Pmodules/environment.csh.in index 14037fb..937771c 100755 --- a/scripts/Bootstrap/Pmodules/environment.csh.in +++ b/scripts/Bootstrap/Pmodules/environment.csh.in @@ -1,17 +1,17 @@ #!/bin/tcsh -setenv PSI_PREFIX "/opt/psi" +setenv PMODULES_ROOT "/opt/psi" -if ( "$PMODULES_VERSION" == "" ) then - setenv PMODULES_VERSION "0.99.1" +if ( ! $?PMODULES_VERSION ) then + setenv PMODULES_VERSION "@PMODULES_VERSION@" endif -setenv PMODULES_HOME "$PSI_PREFIX/Tools/Pmodules/$PMODULES_VERSION" +setenv PMODULES_HOME "$PMODULES_ROOT/Tools/Pmodules/$PMODULES_VERSION" +setenv PMODULES_DIR "${PMODULES_HOME}" -setenv PSI_CONFIG_DIR "config" -setenv PSI_MODULES_ROOT 'modulefiles' -setenv PSI_TEMPLATES_DIR 'templates' +setenv PMODULES_CONFIG_DIR 'config' +setenv PMODULES_MODULEFILES_DIR 'modulefiles' +setenv PMODULES_TEMPLATES_DIR 'templates' -setenv PSI_DEFAULT_FAMILIES 'Tools Programming' - -setenv PSI_RELEASES ':unstable:stable:deprecated:' -setenv PSI_USED_RELEASES 'stable' +setenv PMODULES_DEFAULT_GROUPS 'Tools Programming' +setenv PMODULES_DEFINED_RELEASES ':unstable:stable:deprecated:' +setenv PMODULES_DEFAULT_RELEASES 'stable' From aba087f849e0ca7815b586e34a311189af288b86 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 26 Jun 2015 17:49:49 +0200 Subject: [PATCH 5/6] scripts/Bootstrap/Pmodules - do not read profiles - tcsh output added to 'export_env()' - supress errors from 'typeset' in 'save_env()' - use 'export_env()' to instead of 'echo' - add global declaration of PMODULES_DEFAULT_GROUPS and PMODULES_DEFAULT_RELEASES to 'pmodules_init()' - add 'tcsh' as supported shell --- scripts/Bootstrap/Pmodules/modulecmd.in | 49 ++++++++++++++++++------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/scripts/Bootstrap/Pmodules/modulecmd.in b/scripts/Bootstrap/Pmodules/modulecmd.in index 2b57862..f2b139e 100755 --- a/scripts/Bootstrap/Pmodules/modulecmd.in +++ b/scripts/Bootstrap/Pmodules/modulecmd.in @@ -1,4 +1,4 @@ -#!@PMODULES_HOME@/bin/bash +#!@PMODULES_HOME@/bin/bash --noprofile --norc # #set -o nounset @@ -31,21 +31,33 @@ shopt -s nullglob declare -a Groups='()' declare -A HierarchyDepths='()' -save_env() { - local s='' - while (( $# > 0 )); do - s+="$( typeset -p $1 );" - shift - done - echo export PMODULES_ENV=$( "${PMODULES_HOME}/bin/base64" --wrap=0 <<< "$s" ) -} - export_env() { local s='' + if [[ "${shell}" == "bash" ]]; then + while (( $# > 0 )); do + echo -n "export $1=\"${!1}\";" + shift + done + return + elif [[ "${shell}" == "tcsh" ]]; then + while (( $# > 0 )); do + echo "setenv $1 ${!1}" + shift + done + return + fi +} + +save_env() { + local s='' + local tmp while (( $# > 0 )); do - echo -n "export $1=${!1};" + tmp="$( typeset -p $1 2> /dev/null)" + [[ -n "${tmp}" ]] && s+="${tmp};" shift done + declare -g PMODULES_ENV=$( "${PMODULES_HOME}/bin/base64" --wrap=0 <<< "$s" ) + export_env PMODULES_ENV } trap 'save_env Groups HierarchyDepths UsedReleases PMODULES_DEFAULT_GROUPS PMODULES_DEFINED_RELEASES PMODULES_DEFAULT_RELEASES' EXIT @@ -1054,7 +1066,9 @@ subcommand_use() { fi shift done - echo "export PMODULES_USED_GROUPS=${PMODULES_USED_GROUPS}" + #echo "export PMODULES_USED_GROUPS=${PMODULES_USED_GROUPS}" + declare -g PMODULES_USED_GROUPS="${PMODULES_USED_GROUPS}" + export_env PMODULES_USED_GROUPS [[ ${#dirs_to_add[@]} == 0 ]] && return for dir in "${dirs_to_add[@]}"; do @@ -1112,7 +1126,9 @@ subcommand_unuse() { fi shift done - echo "export PMODULES_USED_GROUPS=${PMODULES_USED_GROUPS}" + #echo "export PMODULES_USED_GROUPS=${PMODULES_USED_GROUPS}" + declare -g PMODULES_USED_GROUPS="${PMODULES_USED_GROUPS}" + export_env PMODULES_USED_GROUPS [[ ${#dirs_to_remove[@]} == 0 ]] && return for dir in "${dirs_to_remove[@]}"; do subcommand_generic1 unuse "${dir}" @@ -1179,12 +1195,16 @@ subcommand_list() { } pmodules_init() { + declare -g PMODULES_DEFAULT_GROUPS='' + declare -g PMODULES_DEFAULT_RELEASES='' + source "${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}/environment.bash" declare -g LOADEDMODULES='' declare -g PMODULES_USED_GROUPS='' declare -g MODULEPATH='' declare -g _LMFILES_='' + for group in ${PMODULES_DEFAULT_GROUPS}; do append_path MODULEPATH "${PMODULES_ROOT}/${group}/${PMODULES_MODULEFILES_DIR}" append_path PMODULES_USED_GROUPS "${group}" @@ -1479,6 +1499,9 @@ case $1 in bash ) declare shell="$1" ;; + tcsh ) + declare shell="$1" + ;; * ) die 1 "${CMD}: unsupported shell -- $1" ;; From 65aad9aaf511da4931355a10e315fb6fea191f33 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 26 Jun 2015 17:50:24 +0200 Subject: [PATCH 6/6] scripts/Bootstrap/Pmodules_version.conf - set version to 0.99.4 --- scripts/Bootstrap/Pmodules_version.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Bootstrap/Pmodules_version.conf b/scripts/Bootstrap/Pmodules_version.conf index edff869..6b159d5 100644 --- a/scripts/Bootstrap/Pmodules_version.conf +++ b/scripts/Bootstrap/Pmodules_version.conf @@ -1,4 +1,4 @@ -declare -x PMODULES_VERSION=0.99.3 +declare -x PMODULES_VERSION=0.99.4 declare -x MODULES_VERSION=3.2.10 declare -a COMPILER_VERSIONS=( 'gcc/4.7.4' 'gcc/4.8.3' 'gcc/4.8.4' 'gcc/4.9.2' )