Merge branch 'master' of gitorious.psi.ch:scicomp/psi-modules-buildenvironment
This commit is contained in:
commit
f80ee16cd4
74 files changed
+3905
-119
No files matched your search
Executable
+57
@@ -0,0 +1,57 @@
|
||||
#!/bin/bash
|
||||
#set -o functrace
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
TCL_DIR="${PSI_PREFIX}/Tools/Pmodules/0.99.0"
|
||||
|
||||
PATH="${TCL_DIR}/bin:${PATH}"
|
||||
|
||||
function em.configure() {
|
||||
case ${OS} in
|
||||
Linux )
|
||||
declare -x LIBS="-lz -lpthread"
|
||||
;;
|
||||
Darwin )
|
||||
declare -x LIBS="-lz -framework CoreFoundation"
|
||||
;;
|
||||
esac
|
||||
CPPFLAGS="-DUSE_INTERP_ERRORLINE" "${MODULE_SRCDIR}"/configure \
|
||||
--prefix="${PREFIX}" \
|
||||
--exec-prefix="${PREFIX}" \
|
||||
--with-module-path="${PSI_PREFIX}/${PSI_MODULES_ROOT}" \
|
||||
--with-tcl="${TCL_DIR}/lib" \
|
||||
--without-x \
|
||||
--disable-versioning \
|
||||
|| exit 1
|
||||
}
|
||||
|
||||
function em.post_install() {
|
||||
rm -v ${PREFIX}/Modules/bin/add.modules
|
||||
rm -v ${PREFIX}/Modules/bin/mkroot
|
||||
rm -rfv ${PREFIX}/Modules/modulefiles
|
||||
mv -v ${PREFIX}/Modules/share/man/man1/module.1 ${PREFIX}/share/man/man1
|
||||
mv -v ${PREFIX}/Modules/share/man/man4/modulefile.4 ${PREFIX}/share/man/man4
|
||||
rmdir ${PREFIX}/Modules/bin
|
||||
rmdir ${PREFIX}/Modules/share/man/man1
|
||||
rmdir ${PREFIX}/Modules/share/man/man4
|
||||
rmdir ${PREFIX}/Modules/share/man
|
||||
rmdir ${PREFIX}/Modules/share
|
||||
rmdir ${PREFIX}/Modules
|
||||
}
|
||||
|
||||
# fake module command
|
||||
module() {
|
||||
:
|
||||
}
|
||||
|
||||
# use system gcc to compile
|
||||
declare -rx CC=gcc
|
||||
|
||||
em.add_to_family 'Tools'
|
||||
em.make_all
|
||||
|
||||
# Local Variables:
|
||||
# mode: sh
|
||||
# sh-basic-offset: 8
|
||||
# tab-width: 8
|
||||
# End:
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../Programming/Tcl.build
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ${BASH_VERSINFO:-0} -lt 3 ]; then
|
||||
echo "BASH version ${BASH_VERSION} ist not supported! You need at least version 3..."
|
||||
return
|
||||
fi
|
||||
|
||||
if [ "${LOADEDMODULES:-}" = "" ]; then
|
||||
declare -x LOADEDMODULES=
|
||||
fi
|
||||
|
||||
if [[ -r "${PSI_BASH_COMPLETION}" ]]; then
|
||||
source "${PSI_BASH_COMPLETION}"
|
||||
fi
|
||||
|
||||
module() {
|
||||
local -r modulecmd="${PMODULES_HOME}/bin/modulecmd"
|
||||
|
||||
local -a args=()
|
||||
local -a switches=()
|
||||
local -a sub_switches=()
|
||||
local subcommand=''
|
||||
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-u|--userlvl )
|
||||
switches+=( $1 $2 )
|
||||
shift 2
|
||||
;;
|
||||
-* )
|
||||
switches+=( $1 )
|
||||
shift
|
||||
;;
|
||||
[a-z]* )
|
||||
subcommand=$1
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
while (( $# > 0 ));do
|
||||
case $1 in
|
||||
-* )
|
||||
sub_switches+=( $1 )
|
||||
;;
|
||||
[a-zA-Z]* )
|
||||
args+=( $1 )
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
if [[ ${subcommand} == '' ]]; then
|
||||
subcommand='help'
|
||||
fi
|
||||
if (( ${#args} == 0 )); then
|
||||
args+=( '' )
|
||||
fi
|
||||
for arg in "${args[@]}"; do
|
||||
eval $( "${modulecmd}" bash ${switches[@]} "${subcommand}" "${sub_switches[@]}" "${arg}" )
|
||||
done
|
||||
}
|
||||
export -f module
|
||||
|
||||
# Local Variables:
|
||||
# mode: sh
|
||||
# sh-basic-offset: 8
|
||||
# tab-width: 8
|
||||
# End:
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../System/bash.build
|
||||
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# Bash commandline completion (bash 3.0 and above) for Modules 3.2.10
|
||||
#
|
||||
_module_avail() {
|
||||
"${MODULESHOME}"/bin/modulecmd bash -t avail 2>&1 | sed '
|
||||
/:$/d;
|
||||
/:ERROR:/d;
|
||||
s#^\(.*\)/\(.\+\)(default)#\1\n\1\/\2#;
|
||||
s#/(default)##g;
|
||||
s#/*$##g;'
|
||||
}
|
||||
|
||||
_module_not_yet_loaded() {
|
||||
comm -23 <(_module_avail|sort) <(tr : '\n' <<<${LOADEDMODULES}|sort)
|
||||
}
|
||||
|
||||
_module_long_arg_list() {
|
||||
local cur="$1" i
|
||||
|
||||
if [[ ${COMP_WORDS[COMP_CWORD-2]} == sw* ]]
|
||||
then
|
||||
COMPREPLY=( $(compgen -W "$(_module_not_yet_loaded)" -- "$cur") )
|
||||
return
|
||||
fi
|
||||
for ((i = COMP_CWORD - 1; i > 0; i--))
|
||||
do case ${COMP_WORDS[$i]} in
|
||||
add|load)
|
||||
COMPREPLY=( $(compgen -W "$(_module_not_yet_loaded)" -- "$cur") )
|
||||
break;;
|
||||
rm|remove|unload|switch|swap)
|
||||
COMPREPLY=( $(IFS=: compgen -W "${LOADEDMODULES}" -- "$cur") )
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
_module() {
|
||||
local cur="$2" prev="$3" cmds opts
|
||||
|
||||
COMPREPLY=()
|
||||
|
||||
cmds="add apropos avail clear dependencies display help\
|
||||
initadd initclear initlist initprepend initrm initswitch\
|
||||
keyword list load purge refresh rm search show swap switch sync\
|
||||
unload unuse update use whatis"
|
||||
|
||||
opts="-c -f -h -i -l -s -t -u -v -H -V\
|
||||
--create --force --help --human --icase\
|
||||
--long --silent --terse --userlvl --verbose --version"
|
||||
|
||||
case "$prev" in
|
||||
add|load) COMPREPLY=( $(compgen -W "$(_module_not_yet_loaded)" -- "$cur") );;
|
||||
rm|remove|unload|switch|swap)
|
||||
COMPREPLY=( $(IFS=: compgen -W "${LOADEDMODULES}" -- "$cur") );;
|
||||
unuse) COMPREPLY=( $(IFS=: compgen -W "${MODULEPATH}" -- "$cur") );;
|
||||
use|*-a*) ;; # let readline handle the completion
|
||||
-u|--userlvl) COMPREPLY=( $(compgen -W "novice expert advanced" -- "$cur") );;
|
||||
display|help|show|whatis)
|
||||
COMPREPLY=( $(compgen -W "$(_module_avail)" -- "$cur") );;
|
||||
*) if test $COMP_CWORD -gt 2
|
||||
then
|
||||
_module_long_arg_list "$cur"
|
||||
else
|
||||
case "$cur" in
|
||||
# The mappings below are optional abbreviations for convenience
|
||||
ls) COMPREPLY="list";; # map ls -> list
|
||||
r*) COMPREPLY="rm";; # also covers 'remove'
|
||||
sw*) COMPREPLY="switch";;
|
||||
|
||||
-*) COMPREPLY=( $(compgen -W "$opts" -- "$cur") );;
|
||||
*) COMPREPLY=( $(compgen -W "$cmds" -- "$cur") );;
|
||||
esac
|
||||
fi;;
|
||||
esac
|
||||
}
|
||||
complete -o default -F _module module
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
declare -r BASE_DIR=$(cd "$(dirname $0)/../.." && pwd)
|
||||
declare -r BOOTSTRAP_DIR="${BASE_DIR}/scripts/Bootstrap"
|
||||
|
||||
${BOOTSTRAP_DIR}/build_pmodules.sh
|
||||
${BOOTSTRAP_DIR}/install_pmodules.sh
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare -r BASE_DIR=$(cd "$(dirname $0)/../.." && pwd)
|
||||
declare -r BOOTSTRAP_DIR="${BASE_DIR}/scripts/Bootstrap"
|
||||
|
||||
source "/opt/psi/config/environment.bash"
|
||||
source "${BASE_DIR}/config/pmodules_version.conf"
|
||||
|
||||
${BOOTSTRAP_DIR}/gettext.build --bootstrap
|
||||
${BOOTSTRAP_DIR}/getopt.build --bootstrap
|
||||
${BOOTSTRAP_DIR}/dialog.build --bootstrap
|
||||
${BOOTSTRAP_DIR}/bash.build --bootstrap
|
||||
${BOOTSTRAP_DIR}/Tcl.build --bootstrap
|
||||
|
||||
# we have to remove the init directory - otherwise the next build will fail...
|
||||
rm -rf "${PMODULES_HOME}/init"
|
||||
${BOOTSTRAP_DIR}/Modules.build --bootstrap
|
||||
mv -v "${PMODULES_HOME}/bin/modulecmd" "${PMODULES_HOME}/bin/modulecmd.tcl"
|
||||
Executable
+346
@@ -0,0 +1,346 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Hardcoded path to dialog software
|
||||
LOCAL_DIALOGHOME=Tools/dialog/1.2.1
|
||||
DIALOG_CMD=$PSI_PREFIX/$LOCAL_DIALOGHOME/bin/dialog
|
||||
|
||||
declare -a modlist # module info
|
||||
declare -A selected # module info indices selected
|
||||
declare -a depcnt # dependency reference counter by module info index
|
||||
declare -A uidmap # unique module id to module info index
|
||||
declare -A modmap # map module names to module info indices for modlist
|
||||
declare -A fdmap # module name to family definition mapping
|
||||
declare -A fmmap # module name to family member mapping
|
||||
declare -a relmap # module info index to release mapping
|
||||
declare tempfile # temporary dialog results
|
||||
|
||||
function set_difference() { # $1 \ $2
|
||||
local -a operand1=($1)
|
||||
local -a operand2=($2)
|
||||
local -A members
|
||||
local -i elem
|
||||
for elem in "${operand1[@]}"; do
|
||||
members[$elem]=1
|
||||
done
|
||||
for elem in "${operand2[@]}"; do
|
||||
unset members[$elem]
|
||||
done
|
||||
echo ${!members[@]}
|
||||
}
|
||||
|
||||
function set_merge() { # $1 U $2 (where $1 and $2 are disjoint)
|
||||
if [[ -z "$1" ]]; then
|
||||
echo "$2"
|
||||
elif [[ -z "$2" ]]; then
|
||||
echo "$1"
|
||||
else
|
||||
echo "$1 $2"
|
||||
fi
|
||||
}
|
||||
|
||||
function set_union() { # $1 U $2 (sorted)
|
||||
local -a operand1=($1)
|
||||
local -a operand2=($2)
|
||||
local -A members
|
||||
local -i elem
|
||||
for elem in ${operand1[@]} ${operand2[@]}; do
|
||||
members[$elem]=1
|
||||
done
|
||||
{ IFS=$'\n'; echo "${!members[*]}"; } | sort -n
|
||||
}
|
||||
|
||||
# unique id for a module
|
||||
function unique_id() { # $1: module info index
|
||||
local -a minfo=( ${modlist[$1]} )
|
||||
if (( ${#minfo[@]} < 4 )); then
|
||||
echo ${minfo[0]}
|
||||
else
|
||||
echo "${minfo[@]:3} ${minfo[0]}"
|
||||
fi
|
||||
}
|
||||
|
||||
function mod_path() { # $1: module info index
|
||||
local -i i
|
||||
local -a m=(${modlist[$1]})
|
||||
local res="$PSI_PREFIX/${fmmap[${m[0]%%/*}]}/${m[0]}"
|
||||
for (( i=${#m[@]}; i>3; i-- )); do
|
||||
res+="/${m[i-1]}"
|
||||
done
|
||||
echo "$res"
|
||||
}
|
||||
|
||||
function calc_deps() { # $1: module info index
|
||||
local dpath="$(mod_path $1)/.dependencies"
|
||||
[[ ! -r "$dpath" ]] && return
|
||||
local -a d=( $(< "$dpath") ) # dependencies as versioned module names
|
||||
local -A p # map family to versioned module name
|
||||
local -A did # map dependency (versioned module name) to unique module id
|
||||
local -a deps # set of module info indices
|
||||
local m n f
|
||||
for m in ${d[@]}; do
|
||||
n=${m%%/*}
|
||||
f=${fdmap[$n]}
|
||||
[[ -n "$f" ]] && { p[$f]=$m; }
|
||||
f=${fmmap[$n]}
|
||||
if [[ -z "$f" ]]; then
|
||||
did[$m]=$m
|
||||
else
|
||||
n=${p[$f]}
|
||||
if [[ -z "$n" ]]; then
|
||||
did[$m]=$m
|
||||
else
|
||||
did[$m]="${did[$n]} $m"
|
||||
fi
|
||||
fi
|
||||
deps+=( ${uidmap["${did[$m]}"]} )
|
||||
done
|
||||
echo "${deps[@]}"
|
||||
}
|
||||
|
||||
function update_deps() { # $1: 1-add dependency, -1-remove dependency $2: set of module info indices
|
||||
[[ -z "$2" ]] && return
|
||||
local -a q=($2) # work queue
|
||||
local deps="" # set of dependencies
|
||||
local -i m
|
||||
while (( ${#q[@]} > 0 )); do
|
||||
m=${q[-1]}
|
||||
unset q[-1]
|
||||
d="$(calc_deps $m)"
|
||||
[[ -z "$d" ]] && continue
|
||||
d="$(set_difference "$d" "$deps")"
|
||||
[[ -z "$d" ]] && continue
|
||||
q+=($d)
|
||||
deps="$(set_merge "$d" "$deps")"
|
||||
done
|
||||
for m in $deps; do
|
||||
let depcnt[m]+=$1
|
||||
done
|
||||
}
|
||||
|
||||
function find_modules() {
|
||||
# construct modlist/modmap/uidmap/depcnt/fmmap/relmap arrays from module search output
|
||||
local -a mc # module info components
|
||||
local -i i=0
|
||||
local current=""
|
||||
local name m
|
||||
while read m; do
|
||||
mc=($m)
|
||||
[[ "${mc[2]}" == "Legacy" ]] && continue # filter out legacy stuff
|
||||
name=${mc[0]%%/*}
|
||||
if [[ "$current" != "$name" ]]; then
|
||||
modmap[$name]="$i"
|
||||
current=$name
|
||||
else
|
||||
modmap[$name]+=" $i"
|
||||
fi
|
||||
modlist[i]=$m
|
||||
uidmap[$(unique_id $i)]=$i
|
||||
depcnt[i]=0
|
||||
[[ -z ${fmmap[$name]} ]] && { fmmap[$name]=${mc[2]}; }
|
||||
relmap[i]=${mc[1]}
|
||||
i+=1
|
||||
done
|
||||
}
|
||||
|
||||
function find_families() {
|
||||
# construct fdmap
|
||||
local -a t # tcl file components
|
||||
local l s n
|
||||
while read l; do
|
||||
s=${l%%:*}
|
||||
s=${s%/*}
|
||||
n=${s##*/}
|
||||
if [[ -z "${fdmap[$n]}" ]]; then
|
||||
t=( ${l##*:} )
|
||||
fdmap[$n]=${t[-1]//\"}
|
||||
fi
|
||||
done < <(grep -R set-family "${PSI_PREFIX}/${PSI_MODULES_ROOT}")
|
||||
}
|
||||
|
||||
function select_uid() { # $1: module uid
|
||||
local -a uidc=($1) # uid components
|
||||
local name=${uidc[-1]%%/*} # module name
|
||||
local midx=${uidmap["$1"]} # module info index
|
||||
[[ -z "$midx" ]] && return
|
||||
selected[$name]="$(set_union "${selected[$name]}" "$midx")"
|
||||
update_deps 1 "$midx"
|
||||
}
|
||||
|
||||
function preselect() { # "$1": prefix for preselected modules
|
||||
# module paths must not contain white space
|
||||
[[ -z "$1" ]] && return
|
||||
local -a mpc # module path components
|
||||
local -i i
|
||||
local uid
|
||||
pushd "$1/$PSI_MODULES_ROOT" > /dev/null || exit 1;
|
||||
trap "popd" EXIT
|
||||
|
||||
for m in $(find . -follow -type f); do
|
||||
uid=""
|
||||
mpc=( ${m//\// } )
|
||||
for ((i=2; i<${#mpc[@]}-2; i+=2)); do
|
||||
uid+="${mpc[i]}/${mpc[i+1]} "
|
||||
done
|
||||
uid+="${mpc[-2]}/${mpc[-1]}"
|
||||
PSI_PREFIX="$1" select_uid "$uid"
|
||||
done
|
||||
|
||||
popd
|
||||
trap - EXIT
|
||||
}
|
||||
|
||||
function is_dependency() { # $1: module name
|
||||
local -a map=(${modmap[$1]})
|
||||
local -i m
|
||||
for ((m=0; m<${#map[@]}; m++)); do
|
||||
(( ${depcnt[${map[m]}]} > 0 )) && return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
function dialog_1() {
|
||||
local -a input
|
||||
local marker
|
||||
local m
|
||||
for m in $(IFS=$'\n'; echo "${!modmap[*]}" | sort); do
|
||||
marker=""
|
||||
[[ -n ${selected[$m]} ]] && { marker+="*"; }
|
||||
is_dependency $m && { marker+="+"; }
|
||||
input+=($m "$marker$m")
|
||||
done
|
||||
|
||||
$DIALOG_CMD --ok-label 'Select' \
|
||||
--extra-button --extra-label 'Exit' \
|
||||
--no-tags \
|
||||
--menu Modules 50 80 50 "${input[@]}" 2>$tempfile
|
||||
return $?
|
||||
}
|
||||
|
||||
function module_id() { # $@: module info components
|
||||
echo "$1 ${@:4}"
|
||||
}
|
||||
|
||||
function module_release() { # $@: module info components
|
||||
echo "$2"
|
||||
}
|
||||
|
||||
function dialog_2() { # $1: module name
|
||||
local -a map=(${modmap[$1]})
|
||||
local -a sel=(${selected[$1]})
|
||||
local -i j # mapping index
|
||||
local -i k=0 # selection index
|
||||
local -a input
|
||||
local marker minfo rel m s
|
||||
for (( j=0; j!=${#map[@]}; j++ )); do
|
||||
minfo=${modlist[${map[j]}]}
|
||||
m="$(module_id $minfo)"
|
||||
rel=" ($(module_release $minfo))"
|
||||
[[ $rel = " (stable)" ]] && { rel=""; }
|
||||
[[ "${map[j]}" = "${sel[k]}" ]] && { s="on"; k+=1; } || { s="off"; }
|
||||
(( ${depcnt[${map[j]}]} > 0 )) && { marker="+"; l+=1; } || { marker=""; }
|
||||
input+=( ${map[j]} "$marker$m$rel" $s )
|
||||
done
|
||||
|
||||
$DIALOG_CMD --extra-button --extra-label 'Clear' --no-tags --checklist Versions 80 90 80 "${input[@]}" 2>$tempfile
|
||||
return $?
|
||||
}
|
||||
|
||||
# final dialog output
|
||||
function module_out() { # $1: module info index
|
||||
local -a args=(${modlist[$1]})
|
||||
echo "${args[@]}"
|
||||
}
|
||||
|
||||
# "$1": prefix for preselected modules
|
||||
function module_picker() {
|
||||
find_families
|
||||
find_modules
|
||||
preselect "$1"
|
||||
|
||||
tempfile=$(mktemp ${TMPDIR:-/tmp}/msyncXXXXXX) || {
|
||||
echo "Unable to create temporary file!"
|
||||
exit 1
|
||||
}
|
||||
trap "rm -f $tempfile" EXIT
|
||||
|
||||
local -i level=1
|
||||
local -i operation=0 # 0: OK, 1: Cancel
|
||||
local oldsel
|
||||
local sel
|
||||
local m
|
||||
while (( level != 0 )); do
|
||||
case $level in
|
||||
1)
|
||||
dialog_1
|
||||
res=$?
|
||||
case $res in
|
||||
0) #OK
|
||||
sel=$(< $tempfile)
|
||||
level=2
|
||||
;;
|
||||
1) #Cancel
|
||||
operation=1
|
||||
level=0
|
||||
;;
|
||||
3|255) #ESC/Exit = Commit
|
||||
for m in ${selected[@]}; do
|
||||
depcnt[m]=1
|
||||
done
|
||||
for ((m=0; m<${#depcnt[@]}; m++)); do
|
||||
(( ${depcnt[m]} > 0 )) && module_out $m >&2
|
||||
done
|
||||
level=0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown return value from dialog_1: $res"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
2)
|
||||
dialog_2 $sel
|
||||
res=$?
|
||||
case $res in
|
||||
0) #OK
|
||||
oldsel=${selected[$sel]} # old selection
|
||||
selected[$sel]=$(< $tempfile) # new selection
|
||||
update_deps -1 "$(set_difference "$oldsel" "${selected[$sel]}")" # remove dependencies
|
||||
update_deps 1 "$(set_difference "${selected[$sel]}" "$oldsel")" # add dependencies
|
||||
level=1
|
||||
;;
|
||||
1|255) #ESC/Cancel
|
||||
level=1
|
||||
;;
|
||||
3) #Clear
|
||||
oldsel=${selected[$sel]} # old selection
|
||||
selected[$sel]="" # new selection
|
||||
update_deps -1 "$oldsel" # remove dependencies
|
||||
level=1
|
||||
;;
|
||||
*)
|
||||
echo "Unknown return value from dialog_2: $res"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Unknown level: $level"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
rm -f $tempfile
|
||||
trap - EXIT
|
||||
|
||||
return $operation
|
||||
}
|
||||
|
||||
# if DIALOG_LIB is NOT set, call module picker
|
||||
[[ ${DIALOG_LIB:+"is_lib"} == "is_lib" ]] || {
|
||||
if [[ -x ${PSI_PREFIX}/${PSI_CONFIG_DIR}/modulecmd.bash ]]; then
|
||||
module_picker "$1" < <(${PSI_PREFIX}/${PSI_CONFIG_DIR}/modulecmd.bash bash search --no-header -a 2>&1)
|
||||
else
|
||||
echo "ERROR: module environment configuration: ${PSI_PREFIX}/${PSI_CONFIG_DIR}/modulecmd.bash is not an executable!"
|
||||
fi
|
||||
}
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../Tools/dialog.build
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../System/getopt.build
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
../Tools/gettext.build
|
||||
Executable
+153
@@ -0,0 +1,153 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
function usage() {
|
||||
PROG=$(basename $0)
|
||||
echo "Usage: $PROG --dir=<directory> [--user=<user>]"
|
||||
echo " Initializes a local module environment in <directory>"
|
||||
echo " for user <user>. <directory> must not exist yet."
|
||||
echo " The <user> parameter must only be present if"
|
||||
echo " $PROG is executed as root."
|
||||
}
|
||||
|
||||
declare force='no'
|
||||
|
||||
while (($# > 0)); do
|
||||
if [[ "${1#--dir}" != "$1" ]]; then
|
||||
option="${1#--dir}"
|
||||
option="${option#=}"
|
||||
[[ -z "$option" ]] && { shift; option="$1"; }
|
||||
ENV_DIR="$option"
|
||||
elif [[ "${1#--user}" != "$1" ]]; then
|
||||
option="${1#--user}"
|
||||
option="${option#=}"
|
||||
[[ -z "$option" ]] && { shift; option="$1"; }
|
||||
ENV_USER="$option"
|
||||
else
|
||||
echo "Error: Unknown option: $1"
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
[[ -z "$ENV_DIR" ]] && {
|
||||
echo "Error: --dir parameter is required!"
|
||||
usage
|
||||
exit 1
|
||||
}
|
||||
|
||||
if (( EUID == 0 )); then
|
||||
[[ -z "$ENV_USER" ]] && {
|
||||
echo "Error: --user parameter is required!"
|
||||
usage
|
||||
exit 1
|
||||
}
|
||||
USER_ID=$(id -u "$ENV_USER")
|
||||
(( $? == 0 )) || {
|
||||
echo "Error: Unable to retrieve user id of user '$ENV_USER'"
|
||||
exit 1
|
||||
}
|
||||
else
|
||||
[[ -z "$ENV_USER" ]] || {
|
||||
echo "Error: --user option is only allowed if running as root!"
|
||||
usage
|
||||
exit 1
|
||||
}
|
||||
USER_ID=$EUID
|
||||
fi
|
||||
|
||||
if [[ -d "$ENV_DIR" ]] && [[ ${force} == no ]]; then
|
||||
echo "Warning: $ENV_DIR already exists."
|
||||
read -p "Do you really want to re-run the initialization? (y/N) " ans
|
||||
case ${ans} in
|
||||
y|Y )
|
||||
:
|
||||
;;
|
||||
* )
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "Attempting to create a local module environment from a partial copy of the environment at '$PSI_PREFIX'"
|
||||
|
||||
[[ -d "$PSI_PREFIX" ]] &&
|
||||
[[ -d "$PSI_PREFIX/$PSI_CONFIG_DIR" ]] &&
|
||||
[[ -d "$PSI_PREFIX/$PSI_MODULES_ROOT" ]] &&
|
||||
[[ -d "$MODULESHOME" ]] || {
|
||||
echo "Error: the module environment '$PSI_PREFIX' has not been initialized properly!"
|
||||
echo "Maybe it is not a module environment, not accessible, or the init script at"
|
||||
echo "'$PSI_PREFIX/config/profile.bash' has not been sourced."
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Creating directory $ENV_DIR..."
|
||||
mkdir -p "$ENV_DIR" || {
|
||||
echo "Error: cannot create directory $ENV_DIR!"
|
||||
exit 1
|
||||
}
|
||||
pushd "$ENV_DIR" || {
|
||||
echo "Error: Cannot change to directory $ENV_DIR"
|
||||
rmdir "$ENV_DIR"
|
||||
exit
|
||||
}
|
||||
ENV_DIR=$(pwd -P)
|
||||
popd
|
||||
trap "rm -rf $ENV_DIR" EXIT
|
||||
|
||||
(( EUID == 0 )) && {
|
||||
echo "Changing owner of directory $ENV_DIR to $ENV_USER..."
|
||||
chown $USER_ID "$ENV_DIR"
|
||||
su $ENV_USER || {
|
||||
echo "Error: cannot change user to $ENV_USER!"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
(( EUID == USER_ID )) || {
|
||||
echo "Error: attempt to run as user with id $USER_ID failed!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
cd "$ENV_DIR" || {
|
||||
echo "Error: failed to change working directory to $ENV_DIR!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Copy configuration..."
|
||||
rsync --recursive --links --perms --delete ${PSI_PREFIX}/${PSI_CONFIG_DIR}/ ${PSI_CONFIG_DIR}/ || {
|
||||
echo "Error: copy operation failed!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Copy module software..."
|
||||
LOCAL_MODHOME=${MODULESHOME#$PSI_PREFIX/}
|
||||
mkdir -p ${LOCAL_MODHOME} || {
|
||||
echo "Error: creating directory for modules software failed!"
|
||||
exit 1
|
||||
}
|
||||
rsync --recursive --links --perms --delete ${MODULESHOME}/ ${LOCAL_MODHOME}/ || {
|
||||
echo "Error: copying modules software failed!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Create directory $PSI_MODULES_ROOT..."
|
||||
mkdir -p $PSI_MODULES_ROOT || {
|
||||
echo "Error: cannot create directory $PSI_MODULES_ROOT!"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# echo "Using sudo to set the link $PSI_PREFIX to $ENV_DIR..."
|
||||
# sudo bash -c "rm -f $PSI_PREFIX && ln -s $ENV_DIR $PSI_PREFIX" || {
|
||||
# echo "WARNING: The link $PSI_PREFIX could not be set to $ENV_DIR!"
|
||||
# echo "Please set this link manually as root:"
|
||||
# echo " ln -s $ENV_DIR $PSI_PREFIX"
|
||||
# }
|
||||
|
||||
echo "Local module environment created at $ENV_DIR."
|
||||
echo "To use this environment, execute"
|
||||
echo " ln -s $ENV_DIR /opt/psi as root (delete the /opt/psi link if it already exists)"
|
||||
echo " source $ENV_DIR/$PSI_CONFIG_DIR/profile.bash"
|
||||
|
||||
trap - EXIT
|
||||
Executable
+26
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare -r BASE_DIR=$(cd "$(dirname $0)/../.." && pwd)
|
||||
declare -r BOOTSTRAP_DIR="${BASE_DIR}/scripts/Bootstrap"
|
||||
|
||||
source "/opt/psi/config/environment.bash"
|
||||
source "${BASE_DIR}/config/pmodules_version.conf"
|
||||
|
||||
sed_cmd="s:@PMODULES_HOME@:${PMODULES_HOME}:g;"
|
||||
sed_cmd+="s:@PMODULES_VERSION@:${PMODULES_VERSION}:g;"
|
||||
sed_cmd+="s:@MODULES_VERSION@:${MODULES_VERSION}:g"
|
||||
sed "${sed_cmd}" "${BOOTSTRAP_DIR}/modulecmd.bash" > "${BOOTSTRAP_DIR}/modulecmd"
|
||||
|
||||
install -d -m 0755 "${PMODULES_HOME}/etc"
|
||||
|
||||
install -m 0755 "${BOOTSTRAP_DIR}/modulecmd" "${PMODULES_HOME}/bin"
|
||||
install -m 0755 "${BOOTSTRAP_DIR}/init_local_env.bash" "${PMODULES_HOME}/bin"
|
||||
install -m 0755 "${BOOTSTRAP_DIR}/modsync.bash" "${PMODULES_HOME}/bin"
|
||||
install -m 0755 "${BOOTSTRAP_DIR}/dialog.bash" "${PMODULES_HOME}/bin"
|
||||
|
||||
install -m 0644 "${BOOTSTRAP_DIR}/modulerc" "${PMODULES_HOME}/etc"
|
||||
|
||||
install -m 0644 "${BOOTSTRAP_DIR}/bash" "${PMODULES_HOME}/init"
|
||||
install -m 0644 "${BOOTSTRAP_DIR}/bash_completion" "${PMODULES_HOME}/init"
|
||||
|
||||
install -m 0644 "${BOOTSTRAP_DIR}/libmodules.tcl" "${PMODULES_HOME}/lib"
|
||||
@@ -0,0 +1,329 @@
|
||||
#
|
||||
# :TODO:
|
||||
# switch/swap
|
||||
# unload modules if parent removed
|
||||
#
|
||||
|
||||
if {[info exists env(PSI_DEBUG)] && $env(PSI_DEBUG)} {
|
||||
proc debug {msg} {
|
||||
set level [expr [info level] -2]
|
||||
set r [catch {info level ${level}} e]
|
||||
if {$r} {
|
||||
set caller ""
|
||||
} else {
|
||||
set caller [lindex [split [info level [expr [info level] - 3]]] 0]
|
||||
}
|
||||
puts -nonewline stderr "${caller}: "
|
||||
puts stderr ${msg}
|
||||
}
|
||||
} else {
|
||||
proc debug {msg} {}
|
||||
}
|
||||
|
||||
proc set-family { family } {
|
||||
global env
|
||||
global name
|
||||
global version
|
||||
global implementation
|
||||
|
||||
debug $family
|
||||
set Implementation [file join {*}${implementation}]
|
||||
|
||||
set FAMILY [string toupper $family]
|
||||
regsub -- "-" ${FAMILY} "_" FAMILY
|
||||
setenv ${FAMILY} $name
|
||||
setenv ${FAMILY}_VERSION $version
|
||||
|
||||
set ::${family} ${name}
|
||||
set ::${family}_version ${version}
|
||||
|
||||
lassign [split ${::family} .] caller_family caller_release
|
||||
if { "${caller_release}" != "" } {
|
||||
set caller_release ".${caller_release}"
|
||||
}
|
||||
debug "caller family: ${caller_family}, release: ${caller_release}"
|
||||
|
||||
if { [module-info mode load] } {
|
||||
debug "mode is load"
|
||||
append-path MODULEPATH ${::MODULE_ROOT_PATH}/${family}/${Implementation}
|
||||
append-path PSI_LOADEDFAMILIES ${family}
|
||||
debug "mode=load: new MODULEPATH=$env(MODULEPATH)"
|
||||
debug "mode=load: new PSI_LOADEDFAMILIES=$env(PSI_LOADEDFAMILIES)"
|
||||
} elseif { [module-info mode remove] } {
|
||||
# remove orphan modules
|
||||
debug "remove orphan modules"
|
||||
set FAMILY [string toupper $family]
|
||||
if { [info exists env(PSI_ACTIVE_MODULES_${FAMILY})] } {
|
||||
set modules [split $env(PSI_ACTIVE_MODULES_${FAMILY}) ":"]
|
||||
foreach m ${modules} {
|
||||
if { ${m} == "--APPMARKER--" } {
|
||||
continue
|
||||
}
|
||||
debug "unloading module: $m"
|
||||
module unload ${m}
|
||||
}
|
||||
}
|
||||
remove-path MODULEPATH ${::MODULE_ROOT_PATH}/${family}/${Implementation}
|
||||
remove-path PSI_LOADEDFAMILIES ${family}
|
||||
debug "mode=remove: $env(MODULEPATH)"
|
||||
debug "mode=remove: $env(PSI_LOADEDFAMILIES)"
|
||||
}
|
||||
if { [module-info mode switch2] } {
|
||||
debug "mode=switch2"
|
||||
append-path MODULEPATH ${::MODULE_ROOT_PATH}/${family}/[module-info name]
|
||||
append-path PSI_LOADEDFAMILIES ${family}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
proc update_active_modules { family name version } {
|
||||
if { ${family} == "--APPMARKER--" } {
|
||||
return
|
||||
}
|
||||
set FAMILY [string toupper $family]
|
||||
append-path PSI_ACTIVE_MODULES_${FAMILY} "$name/$version"
|
||||
remove-path PSI_ACTIVE_MODULES_${FAMILY} "--APPMARKER--"
|
||||
}
|
||||
|
||||
proc is-avail { m } {
|
||||
debug "${m}"
|
||||
set output [catch { exec "$::env(MODULESHOME)/bin/modulecmd" bash avail "${m}" } msg]
|
||||
if { ${output} != "" } {
|
||||
return yes
|
||||
} else {
|
||||
return no
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# load dependencies, but do *not* unload dependencies
|
||||
#
|
||||
proc load_dependencies { fname } {
|
||||
if { ! [ file exists ${fname} ] } {
|
||||
return
|
||||
}
|
||||
if { ! [module-info mode load] } {
|
||||
return
|
||||
}
|
||||
debug "load dependencies from: ${fname}"
|
||||
# Slurp up the data file
|
||||
set fp [open ${fname} r]
|
||||
set file_data [read ${fp}]
|
||||
close ${fp}
|
||||
set data [split ${file_data} "\n"]
|
||||
foreach line ${data} {
|
||||
debug "MODULEPATH=$::env(MODULEPATH)"
|
||||
set module_name [string trim $line]
|
||||
if { ${module_name} == "#" || ${module_name} == "" } {
|
||||
continue
|
||||
}
|
||||
if { [is-loaded ${module_name}] } {
|
||||
debug "module already loaded: ${module_name}"
|
||||
continue
|
||||
}
|
||||
debug "module avail: ${module_name}"
|
||||
if { ! [is-avail "${module_name}"] } {
|
||||
debug "module not in current MODULEPATH: ${module_name}"
|
||||
set search_output [exec $::env(PSI_PREFIX)/config/init/extensions/search.bash "${module_name}"]
|
||||
module use $::env(PSI_PREFIX)/modulefiles/[lindex ${search_output} 2]
|
||||
}
|
||||
debug "module load: ${module_name}"
|
||||
module load ${module_name}
|
||||
}
|
||||
}
|
||||
|
||||
proc lreverse_n { list n } {
|
||||
set res {}
|
||||
set i [expr [llength $list] - $n]
|
||||
while {$i >= 0} {
|
||||
lappend res {*}[lrange $list $i [expr $i+$n-1]]
|
||||
incr i -$n
|
||||
}
|
||||
set res
|
||||
}
|
||||
|
||||
|
||||
|
||||
#
|
||||
# set standard environment variables
|
||||
#
|
||||
proc set_std_environment { PREFIX name version } {
|
||||
#
|
||||
# Hack for supporting legacy modules
|
||||
if { "${::family}" == "Legacy" } {
|
||||
debug "this is a legacy module..."
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
set NAME [string toupper $name]
|
||||
regsub -- "-" ${NAME} "_" NAME
|
||||
|
||||
if { ! [info exist ::dont-setenv] } {
|
||||
set ::dont-setenv {}
|
||||
}
|
||||
|
||||
if { ${version} != "" } {
|
||||
if { [lsearch ${::dont-setenv} "${NAME}_VERSION"] == -1 } {
|
||||
setenv ${NAME}_VERSION $version
|
||||
}
|
||||
}
|
||||
|
||||
if { [file isdirectory "$PREFIX"] } {
|
||||
if { [lsearch ${::dont-setenv} "${NAME}_PREFIX"] == -1 } {
|
||||
setenv ${NAME}_PREFIX $PREFIX
|
||||
}
|
||||
if { [lsearch ${::dont-setenv} "${NAME}_DIR"] == -1 } {
|
||||
setenv ${NAME}_DIR $PREFIX
|
||||
}
|
||||
if { [lsearch ${::dont-setenv} "${NAME}_HOME"] == -1 } {
|
||||
setenv ${NAME}_HOME $PREFIX
|
||||
}
|
||||
}
|
||||
|
||||
if { [file isdirectory "$PREFIX/bin"] } {
|
||||
if { [lsearch ${::dont-setenv} "PATH"] == -1 } {
|
||||
prepend-path PATH $PREFIX/bin
|
||||
}
|
||||
}
|
||||
|
||||
if { [file isdirectory "$PREFIX/sbin"] } {
|
||||
if { [lsearch ${::dont-setenv} "PATH"] == -1 } {
|
||||
prepend-path PATH $PREFIX/sbin
|
||||
}
|
||||
}
|
||||
|
||||
if { [file isdirectory "$PREFIX/share/man"] } {
|
||||
if { [lsearch ${::dont-setenv} "MANPATH"] == -1 } {
|
||||
prepend-path MANPATH $PREFIX/share/man
|
||||
}
|
||||
}
|
||||
|
||||
# set various environment variables - as long as they are not blacklisted
|
||||
debug "prepend to include paths"
|
||||
if { [file isdirectory "$PREFIX/include"] } {
|
||||
if { [lsearch ${::dont-setenv} "C_INCLUDE_PATH"] == -1 } {
|
||||
prepend-path C_INCLUDE_PATH $PREFIX/include
|
||||
}
|
||||
if { [lsearch ${::dont-setenv} "CPLUS_INCLUDE_PATH"] == -1 } {
|
||||
prepend-path CPLUS_INCLUDE_PATH $PREFIX/include
|
||||
}
|
||||
if { [lsearch ${::dont-setenv} "${NAME}_INCLUDE_DIR"] == -1 } {
|
||||
setenv ${NAME}_INCLUDE_DIR $PREFIX/include
|
||||
}
|
||||
}
|
||||
|
||||
debug "prepend to library paths"
|
||||
if { [file isdirectory "$PREFIX/lib"] } {
|
||||
if { [lsearch ${::dont-setenv} "LIBRARY_PATH"] == -1 } {
|
||||
prepend-path LIBRARY_PATH $PREFIX/lib
|
||||
}
|
||||
if { [lsearch ${::dont-setenv} "LD_LIBRARY_PATH"] == -1 } {
|
||||
prepend-path LD_LIBRARY_PATH $PREFIX/lib
|
||||
}
|
||||
if { [lsearch ${::dont-setenv} "${NAME}_LIBRARY_DIR"] == -1 } {
|
||||
setenv ${NAME}_LIBRARY_DIR $PREFIX/lib
|
||||
}
|
||||
}
|
||||
|
||||
debug "prepend to library paths (64bit)"
|
||||
if { [file isdirectory "$PREFIX/lib64"] } {
|
||||
if { [lsearch ${::dont-setenv} "LIBRARY_PATH"] == -1 } {
|
||||
prepend-path LIBRARY_PATH $PREFIX/lib64
|
||||
}
|
||||
if { [lsearch ${::dont-setenv} "LD_LIBRARY_PATH"] == -1 } {
|
||||
prepend-path LD_LIBRARY_PATH $PREFIX/lib64
|
||||
}
|
||||
if { [lsearch ${::dont-setenv} "${NAME}_LIBRARY_DIR"] == -1 } {
|
||||
setenv ${NAME}_LIBRARY_DIR $PREFIX/lib64
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#
|
||||
# What's the game plan here?
|
||||
# Determine from path of module to be loaded:
|
||||
# - name,
|
||||
# - version
|
||||
# - installation PREFIX
|
||||
#
|
||||
set current_modulefile [file split $ModulesCurrentModulefile]
|
||||
set psi_prefix [file split $env(PSI_PREFIX)]
|
||||
|
||||
# return, if module is not in $env(PSI_PREFIX)
|
||||
set module_prefix [file join {*}[lrange ${current_modulefile} 0 [llength ${psi_prefix}]-1]]
|
||||
if { $env(PSI_PREFIX) != ${module_prefix} } {
|
||||
debug "stop sourcing: $env(PSI_PREFIX) != ${module_prefix}"
|
||||
return
|
||||
}
|
||||
|
||||
set MODULE_ROOT_PATH $env(PSI_PREFIX)/$env(PSI_MODULES_ROOT)
|
||||
set module_root_path [file split ${MODULE_ROOT_PATH}]
|
||||
set len [llength $module_root_path]
|
||||
|
||||
set name [lindex $current_modulefile end-1]
|
||||
set version [lindex $current_modulefile end]
|
||||
set family [lrange $current_modulefile $len $len]
|
||||
set implementation [lrange $current_modulefile [expr $len + 1] end]
|
||||
|
||||
set prefix "$psi_prefix [regsub "(.unstable|.deprecated)" $family ""] [lreverse_n [lrange $current_modulefile $len end] 2]"
|
||||
set PREFIX [file join {*}$prefix]
|
||||
|
||||
debug "PREFIX=$PREFIX"
|
||||
debug "family of module $name: $family"
|
||||
|
||||
#
|
||||
# we cannot load another module with the same name
|
||||
#
|
||||
conflict $name
|
||||
|
||||
if { [module-info mode load] } {
|
||||
debug "${name}/${version}: loading ... "
|
||||
if { [ string match "*.deprecated" ${family} ] == 1 } {
|
||||
puts stderr "${name}/${version}: this module is deprecated!"
|
||||
}
|
||||
|
||||
for {set i [expr [llength ${prefix}] - 1]} {$i >= ${len}} {incr i -2} {
|
||||
set info_file [lrange ${prefix} 0 $i]
|
||||
lappend info_file ".info"
|
||||
set fname [file join {*}${info_file}]
|
||||
if { [ file exists "${fname}" ] } {
|
||||
set fp [open "${fname}" r]
|
||||
set info_data [read $fp]
|
||||
close $fp
|
||||
puts stderr ${info_data}
|
||||
}
|
||||
}
|
||||
load_dependencies "${PREFIX}/.dependencies"
|
||||
}
|
||||
|
||||
set_std_environment ${PREFIX} ${name} ${version}
|
||||
update_active_modules ${family} ${name} ${version}
|
||||
|
||||
proc ModulesHelp { } {
|
||||
if { [info exists ::whatis] } {
|
||||
puts stderr "${::whatis}"
|
||||
}
|
||||
if { [info exists ::version] } {
|
||||
puts stderr "Version: ${::version}"
|
||||
}
|
||||
if { [info exists ::url] } {
|
||||
puts stderr "Homepage: ${::url}"
|
||||
}
|
||||
if { [info exists ::license] } {
|
||||
puts stderr "License: ${::license}"
|
||||
}
|
||||
if { [info exists ::maintainer] } {
|
||||
puts stderr "Maintainer: ${::maintainer}"
|
||||
}
|
||||
if { [info exists ::help] } {
|
||||
puts stderr "${::help}\n"
|
||||
}
|
||||
}
|
||||
|
||||
if { [info exists ::whatis] } {
|
||||
module-whatis "$whatis"
|
||||
}
|
||||
Executable
+236
@@ -0,0 +1,236 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
declare -r DEFAULT_SRC="/afs/psi.ch/sys/psi.@sys"
|
||||
declare -r DEFAULT_DST="/opt/psi.local"
|
||||
|
||||
function usage() {
|
||||
echo "
|
||||
$0 [--from=<source>] [--to=<destination>] [--dryrun] [--delete]
|
||||
--from source module installation (default: $DEFAULT_SRC)
|
||||
|
||||
--to destination module installation (default: $DEFAULT_DST)
|
||||
|
||||
--dryrun just tell what would be copied and deleted
|
||||
|
||||
--delete as an additional task, delete modules that are present
|
||||
at the destination but not at the source installation
|
||||
(destination cleanup)" >&2
|
||||
}
|
||||
|
||||
function die() {
|
||||
echo "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# check if directory $1 is a valid prefix
|
||||
function is_module_prefix() {
|
||||
if [[ -d "$1" ]] &&
|
||||
[[ -d "$1/$PSI_CONFIG_DIR" ]] &&
|
||||
[[ -d "$1/$PSI_MODULES_ROOT" ]]
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# set the source and destination module installations
|
||||
function get_options() {
|
||||
local src_dir="$DEFAULT_SRC"
|
||||
local dst_dir="$DEFAULT_DST"
|
||||
local dryrun=false
|
||||
local delete=false
|
||||
local option
|
||||
|
||||
while (($# > 0)); do
|
||||
if [[ "${1#--from}" != "$1" ]]; then
|
||||
option="${1#--from}"
|
||||
option="${option#=}"
|
||||
[[ -z "$option" ]] && { shift; option="$1"; }
|
||||
src_dir="$option"
|
||||
elif [[ "${1#--to}" != "$1" ]]; then
|
||||
option="${1#--to}"
|
||||
option="${option#=}"
|
||||
[[ -z "$option" ]] && { shift; option="$1"; }
|
||||
dst_dir="$option"
|
||||
elif [[ -z "${1#--dryrun}" ]]; then
|
||||
dryrun=true
|
||||
elif [[ -z "${1#--delete}" ]]; then
|
||||
delete=true
|
||||
else
|
||||
usage > /dev/fd/2
|
||||
die "Unknown option: $1"
|
||||
fi
|
||||
shift
|
||||
done
|
||||
|
||||
is_module_prefix "$src_dir" || { die "<$src_dir> is not a Pmodules installation"; }
|
||||
is_module_prefix "$dst_dir" || { die "<$dst_dir> is not a Pmodules installation"; }
|
||||
src_dir=$( cd "$src_dir"; pwd -P )
|
||||
dst_dir=$( cd "$dst_dir"; pwd -P )
|
||||
[[ "$src_dir" == "$dst_dir" ]] && { die "same source and destination installations"; }
|
||||
local modbin=$( cd "$PMODULES_HOME"; pwd -P )
|
||||
local prefix=$( cd "$PSI_PREFIX"; pwd -P )
|
||||
modbin=${modbin#"$prefix/"}/bin/modulecmd
|
||||
local -r file_type_src=$( file -b "$src_dir/$modbin" 2>&1 || echo err1 )
|
||||
local -r file_type_dst=$( file -b "$dst_dir/$modbin" 2>&1 || echo err2 )
|
||||
[[ ! "${file_type_src}" == "${file_type_dst}" ]] || {
|
||||
die "The file signatures in the source and destination installation do not match!"
|
||||
}
|
||||
echo "$src_dir" "$dst_dir" "$dryrun" "$delete"
|
||||
}
|
||||
|
||||
# Derive the relative module installation path
|
||||
# from the relative module file path
|
||||
# $1 relative module file path
|
||||
function get_modpath() {
|
||||
local -a comp=( ${1//\// } ) # split rel.path into components
|
||||
local -a path # result path
|
||||
local -i i
|
||||
for ((i=0; i<${#comp[@]}; i++)); do
|
||||
case $i in
|
||||
0) path=( ${comp[0]%.*} );;
|
||||
*) path+=( "${comp[$((-i-1))]}/${comp[$((-i))]}" ); i+=1;;
|
||||
esac
|
||||
done
|
||||
echo "${path[*]}"
|
||||
}
|
||||
|
||||
# Derive the relative module release file path
|
||||
# from the relative module file path
|
||||
# $1 relative module file path
|
||||
function get_release_path() {
|
||||
echo "$(dirname "$1")/.release-$(basename "$1")"
|
||||
}
|
||||
|
||||
# $1 dryrun=(true|false)
|
||||
# $2 relative module file path of destination module to be deleted
|
||||
# $3 destination prefix
|
||||
function delete_module() {
|
||||
if [[ "$1" != "false" ]]; then
|
||||
echo "(dryrun) delete: $2 at $3" 1>&2
|
||||
return 0
|
||||
fi
|
||||
local modpath=$( get_modpath "$2" )
|
||||
[[ -z "$modpath" ]] && {
|
||||
die "Unable to retrieve module file and installation paths";
|
||||
}
|
||||
echo "rm -v \"$3/$PSI_MODULES_ROOT/$2\""
|
||||
echo "rm -v \"$3/$PSI_MODULES_ROOT/$( get_release_path $2 )\""
|
||||
echo "rmdir -vp \"$( dirname "$3/$PSI_MODULES_ROOT/$2" )\""
|
||||
echo "rm -vrf \"$3/$modpath\""
|
||||
echo "rmdir -vp \"$( dirname "$3/$modpath" )\""
|
||||
echo "deleted: $2" 1>&2
|
||||
}
|
||||
|
||||
# $1 dryrun=(true|false)
|
||||
# $2 relative module file path of source module to be copied to the destination
|
||||
# $3 source prefix
|
||||
# $4 destination prefix
|
||||
function copy_module() {
|
||||
if [[ "$1" != "false" ]]; then
|
||||
echo "(dryrun) copy: $2 from $3 to $4" 1>&2
|
||||
return 0
|
||||
fi
|
||||
local modpath=$( get_modpath "$2" )
|
||||
[[ -z "$modpath" ]] && { die "Unable to retrieve module file and installation paths"; }
|
||||
install -d $( dirname "$3/$PSI_MODULES_ROOT/$2" )
|
||||
(
|
||||
cd $3
|
||||
rsync --links --perms --relative --verbose "$PSI_MODULES_ROOT/$2" "$4"
|
||||
rsync --links --perms --relative --verbose "$PSI_MODULES_ROOT/$( get_release_path "$2" )" "$4"
|
||||
rsync --recursive --links --perms --relative --verbose "$modpath" "$4"
|
||||
)
|
||||
echo "copied: $2" 1>&2
|
||||
}
|
||||
|
||||
# syncronize modules from source to
|
||||
# destination module installations
|
||||
# --from=<source> default: /afs/psi.ch/sys/psi.@sys
|
||||
# --to=<destination> default: /opt/psi.local
|
||||
function sync_modules() {
|
||||
local -a options=( $(get_options "$@") )
|
||||
[[ -z "$options" ]] && exit 1
|
||||
local src_dir="${options[0]}"
|
||||
local dst_dir="${options[1]}"
|
||||
local dryrun="${options[2]}"
|
||||
local delete="${options[3]}"
|
||||
unset options
|
||||
|
||||
local profile_script="$src_dir/$PSI_CONFIG_DIR/profile.bash"
|
||||
[[ -r "$profile_script" ]] || {
|
||||
die "Unable to find profile script of installation $profile_script";
|
||||
}
|
||||
local search_script="$src_dir/Tools/Pmodules/${PMODULES_VERSION}/bin/modulecmd"
|
||||
[[ -x "$search_script" ]] || {
|
||||
die "Unable to find search script of installation $search_script";
|
||||
}
|
||||
local dialog_script="$src_dir/Tools/Pmodules/${PMODULES_VERSION}/bin/dialog.bash"
|
||||
[[ -r "$dialog_script" ]] || {
|
||||
die "Unable to find dialog script of installation $dialog_script";
|
||||
}
|
||||
|
||||
. "$profile_script" # set variables for the source installation
|
||||
|
||||
DIALOG_LIB=1 # use dialog script as a library
|
||||
. "$dialog_script" # dialog functions
|
||||
|
||||
local -a selected_modules
|
||||
|
||||
# Redefine module_out to append modules to the selected_modules variable
|
||||
function module_out() {
|
||||
local -a args=(${modlist[$1]})
|
||||
local path=""
|
||||
IFS=/
|
||||
[[ -n "${args[3]}" ]] && path="/${args[*]:3}"
|
||||
unset IFS
|
||||
selected_modules+=( "${args[2]}$path/${args[0]}" )
|
||||
}
|
||||
|
||||
module_picker "$dst_dir" < <("$search_script" bash search --no-header -a 2>&1)
|
||||
|
||||
local -a destination_modules=( $(cd "$dst_dir/$PSI_MODULES_ROOT"; find -L . -type f | while read f; do echo ${f#./}; done) )
|
||||
|
||||
# redefine set difference, the version in dialog.bash only handles integers
|
||||
function set_difference() { # $1 \ $2
|
||||
local -a operand1=($1)
|
||||
local -a operand2=($2)
|
||||
local -A members
|
||||
local elem
|
||||
for elem in "${operand1[@]}"; do
|
||||
members[$elem]=1
|
||||
done
|
||||
for elem in "${operand2[@]}"; do
|
||||
unset members[$elem]
|
||||
done
|
||||
echo ${!members[@]}
|
||||
}
|
||||
|
||||
[[ "$delete" == "true" ]] && {
|
||||
local -a modules_delete=( $(set_difference "${destination_modules[*]}" "${selected_modules[*]}") )
|
||||
for m in "${modules_delete[@]}"; do
|
||||
delete_module "$dryrun" "$m" "$dst_dir"
|
||||
done
|
||||
unset modules_delete
|
||||
}
|
||||
|
||||
|
||||
local -a modules_copy=( $(set_difference "${selected_modules[*]}" "${destination_modules[*]}") )
|
||||
[[ -z $modules_copy ]] || {
|
||||
if [[ "$dryrun" != "false" ]]; then
|
||||
echo "(dryrun) update: $dst_dir/$PSI_CONFIG_DIR from $src_dir/$PSI_CONFIG_DIR" 1>&2
|
||||
else
|
||||
(
|
||||
local -a extraoption="$( [[ "$delete" == "true" ]] && echo --delete )"
|
||||
cd "$src_dir"
|
||||
rsync --recursive --links --perms --relative $extraoption --verbose --exclude .git "$PSI_CONFIG_DIR" "$dst_dir"
|
||||
echo "updated: $PSI_CONFIG_DIR from $src_dir" 1>&2
|
||||
)
|
||||
fi
|
||||
for m in "${modules_copy[@]}"; do
|
||||
copy_module "$dryrun" "$m" "$src_dir" "$dst_dir"
|
||||
done
|
||||
}
|
||||
unset modules_copy
|
||||
}
|
||||
|
||||
sync_modules "$@"
|
||||
File diff suppressed because it is too large.
Load diff
Executable
+1140
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,8 @@
|
||||
#%Module1.0
|
||||
|
||||
setenv PSI_LIBMODULES "$env(PSI_PREFIX)/$env(PSI_CONFIG_DIR)/libmodules.tcl"
|
||||
|
||||
if { ! [info exists env(PSI_LIBMODULES) ] } {
|
||||
puts stderr "Module cannot be loaded, because the shell environment is not setup correctly."
|
||||
exit 42
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source $(dirname $0)/../lib/libem.bash
|
||||
source $(dirname $0)/../../lib/libem.bash
|
||||
|
||||
function em.pre_configure() {
|
||||
./autogen.sh
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
cat <<EOF > "${MODULE_SRCDIR}/make.inc"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
cat <<EOF > "${MODULE_SRCDIR}/make.inc"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
cat <<EOF > "${MODULE_SRCDIR}/make.inc"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
cat <<EOF > "${MODULE_SRCDIR}/SuiteSparse_config/SuiteSparse_config.mk"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.pre_configure() {
|
||||
./autogen.sh
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.pre_configure() {
|
||||
:
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
(cd "${MODULE_SRCDIR}" && ./autogen.sh)
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
case ${OS} in
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}/bootstrap" --prefix="${PREFIX}"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
em.add_to_family 'Programming'
|
||||
em.set_runtime_dependencies ""
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -3,7 +3,7 @@
|
||||
# Lua cannot be build in a seperate directory!
|
||||
#
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
cd "${MODULE_SRCDIR}"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
:
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
:
|
||||
}
|
||||
|
||||
function em.build() {
|
||||
case ${OS} in
|
||||
Linux )
|
||||
declare -x LDFLAGS="-lintl -liconv"
|
||||
;;
|
||||
Darwin )
|
||||
declare -x LDFLAGS="-lintl -liconv -framework CoreFoundation"
|
||||
;;
|
||||
esac
|
||||
|
||||
cd "${MODULE_SRCDIR}"
|
||||
make -e
|
||||
}
|
||||
|
||||
function em.install() {
|
||||
cd "${MODULE_SRCDIR}"
|
||||
declare -x DESTDIR="${PREFIX}"
|
||||
declare -x prefix=''
|
||||
make -e install
|
||||
}
|
||||
|
||||
function em.cleanup_build() {
|
||||
cd "${MODULE_SRCDIR}"
|
||||
make -e realclean
|
||||
}
|
||||
|
||||
em.add_to_family 'Tools'
|
||||
em.make_all
|
||||
|
||||
# Local Variables:
|
||||
# mode: sh
|
||||
# sh-basic-offset: 8
|
||||
# tab-width: 8
|
||||
# End:
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
TCL_VERSION='8.6.3'
|
||||
TCL_DIR="${PSI_PREFIX}/Programming/Tcl/${TCL_VERSION}"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
module use 'Libraries'
|
||||
|
||||
Executable
+24
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
--prefix="${PREFIX}" \
|
||||
--disable-java \
|
||||
--disable-threads \
|
||||
--disable-shared \
|
||||
--enable-relocatable \
|
||||
--disable-openmp \
|
||||
--disable-acl \
|
||||
--disable-curses \
|
||||
--with-included-gettext \
|
||||
--without-libiconv-prefix \
|
||||
--without-libintl-prefix \
|
||||
--with-included-libxml \
|
||||
|| exit 1
|
||||
}
|
||||
|
||||
em.add_to_family 'Tools'
|
||||
em.set_build_dependencies "${COMPILER}"
|
||||
em.make_all
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$(dirname $0)/../lib/libem.bash"
|
||||
source "$(dirname $0)/../../lib/libem.bash"
|
||||
|
||||
function em.configure() {
|
||||
"${MODULE_SRCDIR}"/configure \
|
||||
Reference in new issue
Block a user