- Bootstrap/ moved one level up

- pmodules.xyz() functions renamed to pbuild::xyz()
- use pbuild for bootstrapping components
This commit is contained in:
2015-09-17 15:03:03 +02:00
parent 99a7feb85c
commit eee5c158cb
31 changed files with 135 additions and 60 deletions

View File

@@ -1,3 +0,0 @@
environment.bash
modulecmd.bash
modmanage.bash

View File

@@ -1,57 +0,0 @@
#!/bin/bash
#set -o functrace
source "$(dirname $0)/../../../lib/libpmodules.bash"
TCL_DIR="${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION}"
PATH="${TCL_DIR}/bin:${PATH}"
pmodules.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="${PMODULES_ROOT}/Tools/${PMODULES_MODULEFILES_DIR}" \
--with-tcl="${TCL_DIR}/lib" \
--without-x \
--disable-versioning \
|| exit 1
}
pmodules.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
pmodules.add_to_group 'Tools'
pmodules.make_all
# Local Variables:
# mode: sh
# sh-basic-offset: 8
# tab-width: 8
# End:

View File

@@ -1,155 +0,0 @@
#!/bin/bash
#############################################################################
# bash 3 or newer ...
#
if [ ${BASH_VERSINFO:-0} -lt 3 ]; then
echo "BASH version ${BASH_VERSION} ist not supported! You need at least version 3..."
return
fi
#############################################################################
# implement module comand as function
#
module() {
local -r modulecmd="${PMODULES_HOME}/bin/modulecmd"
local -a args=()
local -a switches=()
while (( $# > 0 ));do
case $1 in
-* )
switches+=( $1 )
;;
[/~a-zA-Z]* )
args+=( $1 )
;;
esac
shift
done
[[ ${#args[@]} == 0 ]] && args+=( 'help' )
[[ ${#args[@]} == 1 ]] && args+=( '--' )
local -i i=1
for (( i=1; i < ${#args[@]}; i++ )); do
eval $( "${modulecmd}" bash "${args[0]}" "${switches[@]}" "${args[i]}" )
done
}
export -f module
#############################################################################
# helper functions
#
std::append_path () {
local -r P=$1
local -r d=$2
if ! echo ${!P} | egrep -q "(^|:)${d}($|:)" ; then
if [[ -z ${!P} ]]; then
eval $P=${d}
else
eval $P="${!P}:${d}"
fi
fi
}
#
# Replace or remove a directory in a path variable.
#
# To remove a dir:
# std::replace_path PATH <pattern>
#
# To replace a dir:
# std::replace_path PATH <pattern> /replacement/path
#
# Args:
# $1 name of the shell variable to set (e.g. PATH)
# $2 a grep pattern identifying the element to be removed/replaced
# $3 the replacement string (use "" for removal)
#
# Based on solution published here:
# https://stackoverflow.com/questions/273909/how-do-i-manipulate-path-elements-in-shell-scripts
#
std::replace_path () {
local -r path=$1
local -r removepat=$2
local -r replacestr=$3
local -r removestr=$(echo "${!path}" | tr ":" "\n" | grep -m 1 "^$removepat\$")
export $path=$(echo "${!path}" | tr ":" "\n" | sed "s:^${removestr}\$:${replacestr}:" |
sed '/^\s*$/d' | tr "\n" ":" | sed -e 's|^:||' -e 's|:$||')
}
save_env() {
local s=''
while (( $# > 0 )); do
s+="$( typeset -p $1 );"
shift
done
echo export PMODULES_ENV=$( "${PMODULES_HOME}/bin/base64" --wrap=0 <<< "$s" )
}
#module purge
#############################################################################
# setup environment
#
declare -x LOADEDMODULES=''
declare -x _LMFILES_=''
declare -x PMODULES_USED_GROUPS=''
declare -x MODULEPATH=''
for group in ${PMODULES_DEFAULT_GROUPS//:/ }; do
std::append_path MODULEPATH "${PMODULES_ROOT}/${group}/${PMODULES_MODULEFILES_DIR}"
std::append_path PMODULES_USED_GROUPS "${group}"
done
declare -x UsedReleases=''
for r in ${PMODULES_DEFAULT_RELEASES//:/ }; do
std::append_path UsedReleases "${r}"
done
eval $(save_env UsedReleases PMODULES_DEFAULT_RELEASES PMODULES_DEFAULT_GROUPS PMODULES_DEFINED_RELEASES)
unset UsedReleases
unset PMODULES_DEFAULT_RELEASES
unset PMODULES_DEFAULT_GROUPS
unset PMODULES_DEFINED_RELEASES
std::replace_path PATH "${PMODULES_HOME%/*}/.*"
std::replace_path MANPATH "${PMODULES_HOME%/*}/.*"
std::append_path PATH "${PMODULES_HOME}/bin"
if [[ -r /etc/man.config ]]; then
declare _manconf='/etc/man.config'
elif [[ -r /etc/man.conf ]]; then
declare _manconf='/etc/man.conf'
fi
if [[ -n ${_manconf} ]]; then
while read name value rest; do
std::append_path MANPATH "${value}"
done < <(grep "^MANPATH\s" "${_manconf}")
unset _manconf
else
std::append_path MANPATH "${PMODULES_HOME}/share/man"
std::append_path MANPATH "/usr/share/man"
fi
#############################################################################
# initialize bash completion
#
if [[ -r "${PMODULES_HOME}/init/bash_completion" ]]; then
source "${PMODULES_HOME}/init/bash_completion"
fi
#############################################################################
# legacy...
#
unset MODULE_VERSION
unset MODULE_VERSION_STACK
unset MODULESHOME
# Local Variables:
# mode: sh
# sh-basic-offset: 8
# tab-width: 8
# End:

View File

@@ -1,76 +0,0 @@
#
# Bash commandline completion (bash 3.0 and above) for Modules 3.2.10
#
_module_avail() {
"${PMODULES_HOME}"/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

View File

@@ -1,44 +0,0 @@
if ($?tcsh) then
set modules_shell="tcsh"
else
set modules_shell="csh"
endif
set exec_prefix = $PMODULES_HOME/bin'
set prefix=""
set postfix=""
if ( $?histchars ) then
set histchar = `echo $histchars | cut -c1`
set _histchars = $histchars
set prefix = 'unset histchars;'
set postfix = 'set histchars = $_histchars;'
else
set histchar = \!
endif
if ($?prompt) then
set prefix = "$prefix"'set _prompt="$prompt";set prompt="";'
set postfix = "$postfix"'set prompt="$_prompt";unset _prompt;'
endif
if ($?noglob) then
set prefix = "$prefix""set noglob;"
set postfix = "$postfix""unset noglob;"
endif
set postfix = "set _exit="'$status'"; $postfix; test 0 = "'$_exit;'
alias module $prefix'eval `'$exec_prefix'/modulecmd '$modules_shell' '$histchar'*`; '$postfix
unset exec_prefix
unset prefix
unset postfix
if (! $?MODULEPATH ) then
setenv MODULEPATH `sed -n 's/[ #].*$//; /./H; $ { x; s/^\n//; s/\n/:/g; p; }' ${MODULESHOME}/init/.modulespath`
endif
if (! $?LOADEDMODULES ) then
setenv LOADEDMODULES ""
endif

View File

@@ -1,353 +0,0 @@
#!/usr/bin/env bash
# Hardcoded path to dialog software
DIALOG_CMD=$PMODULES_HOME/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
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[@]}
}
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
}
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
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
}
mod_path() { # $1: module info index
local -i i
local -a m=(${modlist[$1]})
local res="$PMODULES_ROOT/${fmmap[${m[0]%%/*}]}/${m[0]}"
for (( i=${#m[@]}; i>3; i-- )); do
res+="/${m[i-1]}"
done
echo "$res"
}
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[@]}"
}
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
}
# "$1": source module environment
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 uid
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
uid="$(unique_id $i)"
uidmap["$uid"]=$i
depcnt[i]=0
[[ -z ${fmmap[$name]} ]] && { fmmap[$name]=${mc[2]}; }
relmap[i]=${mc[1]}
i+=1
done < <(${PMODULES_HOME}/bin/modulecmd bash search --src="$1" --no-header -a 2>&1)
}
# "$1": source module environment
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 "$1/*/${PMODULES_MODULEFILES_DIR}")
}
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"
}
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 n
pushd "$1/$PMODULES_MODULEFILES_DIR" > /dev/null || exit 1;
trap "popd" EXIT
for m in $(find . -follow -type f); do
n=${m##*/}
[[ "${n:0:1}" == "." ]] && continue
uid=""
mpc=( ${m//\// } )
for ((i=2; i<${#mpc[@]}-2; i+=2)); do
uid+="${mpc[i]}/${mpc[i+1]} "
done
uid+="${mpc[-2]}/${mpc[-1]}"
PMODULES_ROOT="$1" select_uid "$uid"
done
popd
trap - EXIT
}
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
}
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 $?
}
module_id() { # $@: module info components
echo "$1 ${@:4}"
}
module_release() { # $@: module info components
echo "$2"
}
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
module_out() { # $1: module info index
local -a args=(${modlist[$1]})
echo "${args[@]}"
}
# "$1": prefix for preselected modules (destination module environment)
# "$2": prefix for selectable modules (source module environment)
module_picker() {
find_families "$2"
find_modules "$2"
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
PMODULES_ROOT="$2" update_deps -1 "$(set_difference "$oldsel" "${selected[$sel]}")" # remove dependencies
PMODULES_ROOT="$2" 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 ${PMODULES_HOME}/bin/modulecmd ]]; then
module_picker "${1:-$PMODULES_ROOT}" "${2:-/afs/psi.ch/sys/psi.x86_64_slp6}"
exit $?
else
echo "ERROR: module environment configuration: ${PMODULES_HOME}/bin/modulecmd is not an executable!"
exit 1
fi
}

View File

@@ -1,27 +0,0 @@
#!/bin/bash
#
# Notes:
# - PMODULES_ROOT is derived from the location of this file.
# - Some for PMODULES_CONFIG_DIR.
# - The Pmodules software must be installed in
# ${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION}
#
declare -x PMODULES_MODULEFILES_DIR='modulefiles'
declare -x PMODULES_TEMPLATES_DIR='templates'
declare -x PMODULES_DEFAULT_GROUPS='Tools Programming'
declare -x PMODULES_DEFINED_RELEASES=':unstable:stable:deprecated:'
declare -x PMODULES_DEFAULT_RELEASES='stable'
if [[ -z ${PMODULES_VERSION} ]]; then
declare -x PMODULES_VERSION="@PMODULES_VERSION@"
fi
#
# DO NOT CHANGE THE FOLLOWING LINES!
declare -x PMODULES_ROOT=$(cd $(dirname "${BASH_SOURCE}")/.. && pwd)
declare -x PMODULES_CONFIG_DIR=$(basename $(cd $(dirname "${BASH_SOURCE}") && pwd))
declare -x PMODULES_HOME="${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION}"
declare -x PMODULES_DIR="${PMODULES_HOME}"

View File

@@ -1,17 +0,0 @@
#!/bin/tcsh
setenv PMODULES_ROOT "/opt/psi"
if ( ! $?PMODULES_VERSION ) then
setenv PMODULES_VERSION "@PMODULES_VERSION@"
endif
setenv PMODULES_HOME "$PMODULES_ROOT/Tools/Pmodules/$PMODULES_VERSION"
setenv PMODULES_DIR "${PMODULES_HOME}"
setenv PMODULES_CONFIG_DIR 'config'
setenv PMODULES_MODULEFILES_DIR 'modulefiles'
setenv PMODULES_TEMPLATES_DIR 'templates'
setenv PMODULES_DEFAULT_GROUPS 'Tools Programming'
setenv PMODULES_DEFINED_RELEASES ':unstable:stable:deprecated:'
setenv PMODULES_DEFAULT_RELEASES 'stable'

View File

@@ -1,340 +0,0 @@
#
# :TODO:
# switch/swap
# unload modules if parent removed
#
if {[info exists env(PMODULES_DEBUG)] && $env(PMODULES_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} {}
}
debug "loading libmodules"
proc module-addgroup { group } {
global env
global name
global version
debug $group
set Implementation [file join {*}$::implementation]
set GROUP [string toupper $group]
regsub -- "-" ${GROUP} "_" GROUP
setenv ${GROUP} $name
setenv ${GROUP}_VERSION $version
set ::${group} $name
set ::${group}_version $version
if { [module-info mode load] } {
debug "mode is load"
append-path MODULEPATH $::PmodulesRoot/$group/$::PmodulesModulfilesDir/$Implementation
append-path PMODULES_USED_GROUPS $group
debug "mode=load: new MODULEPATH=$env(MODULEPATH)"
debug "mode=load: new PMODULES_USED_GROUPS=$env(PMODULES_USED_GROUPS)"
} elseif { [module-info mode remove] } {
# remove orphan modules
debug "remove orphan modules"
set GROUP [string toupper $group]
if { [info exists env(PMODULES_LOADED_${GROUP})] } {
set modules [split $env(PMODULES_LOADED_${GROUP}) ":"]
foreach m ${modules} {
if { ${m} == "--APPMARKER--" } {
continue
}
if { [is-loaded ${module_name}] } {
debug "unloading module: $m"
module unload ${m}
}
}
}
remove-path MODULEPATH $::PmodulesRoot/$group/$::PmodulesModulfilesDir/$Implementation
remove-path PMODULES_USED_GROUPS $group
debug "mode=remove: $env(MODULEPATH)"
debug "mode=remove: $env(PMODULES_USED_GROUPS)"
}
if { [module-info mode switch2] } {
debug "mode=switch2"
append-path MODULEPATH $::PmodulesRoot/$group/$::PmodulesModulfilesDir/[module-info name]
append-path PMODULES_USED_GROUPS ${group}
}
}
proc set-family { group } {
module-addgroup $group
}
proc _pmodules_update_loaded_modules { group name version } {
if { ${group} == "--APPMARKER--" } {
return
}
set GROUP [string toupper $group]
debug "${GROUP} $name/$version"
append-path PMODULES_LOADED_${GROUP} "$name/$version"
remove-path PMODULES_LOADED_${GROUP} "--APPMARKER--"
}
#
# load dependencies, but do *not* unload dependencies
#
proc _pmodules_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 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 _pmodules_setenv { PREFIX name version } {
#
# Hack for supporting legacy modules
if { "${::group}" == "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
}
} else {
debug "$PREFIX is not a directory"
}
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
}
}
}
proc module-url { _url } {
set ::url ${_url}
}
proc module-license { _license } {
set ::license ${_license}
}
proc module-maintainer { _maintainer } {
set ::maintainer ${_maintainer}
}
proc module-help { _help } {
set ::help ${_help}
}
proc ModulesHelp { } {
if { [info exists ::whatis] } {
puts stderr "${::whatis}"
} else {
module whatis ModulesCurrentModulefile
}
if { [info exists ::version] } {
puts stderr "Version: ${::version}"
} else {
module whatis
}
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"
}
}
#
# intialize global vars
# Modulefile is something like
#
# ${PMODULES_ROOT}/group/${PMODULES_MODULEFILES_DIR}/name/version
# or
# ${PMODULES_ROOT}/group/${PMODULES_MODULEFILES_DIR}/X1/Y1/name/version
# or
# ${PMODULES_ROOT}/group/${PMODULES_MODULEFILES_DIR}/X1/Y1//X2/Y2/name/version
#
proc _pmodules_init_global_vars { } {
global group
global name
global version
global implementation
global PREFIX # prefix of package
debug "$::ModulesCurrentModulefile"
set ::PmodulesRoot $::env(PMODULES_ROOT)
set ::PmodulesModulfilesDir $::env(PMODULES_MODULEFILES_DIR)
set modulefile [file split $::ModulesCurrentModulefile]
set pmodules_root [file split $::PmodulesRoot]
set pmodules_root_num_dirs [llength $pmodules_root]
set modulefile_root [file join {*}[lrange $modulefile 0 [expr $pmodules_root_num_dirs - 1]]]
if { $::PmodulesRoot != $modulefile_root } {
debug "stop sourcing: ${::PmodulesRoot} != $modulefile_root"
return
}
debug "modulefile is inside our root"
set rel_modulefile [lrange $modulefile [llength $pmodules_root] end]
set group [lindex $rel_modulefile 0]
set name [lindex $modulefile end-1]
set version [lindex $modulefile end]
set implementation [lrange $rel_modulefile 2 end]
set prefix "$pmodules_root $group [lreverse_n $implementation 2]"
set PREFIX [file join {*}$prefix]
debug "PREFIX=$PREFIX"
debug "group of module $name: $group"
}
proc _pmodules_output_message { fname } {
if { [ file exists "${fname}" ] } {
set fp [open "${fname}" r]
set info_text [read $fp]
close $fp
puts stderr ${info_text}
}
}
if { [info exists ::whatis] } {
module-whatis "$whatis"
}
_pmodules_init_global_vars
#
# we cannot load another module with the same name
#
conflict $name
if { [module-info mode load] } {
debug "${name}/${version}: loading ... "
_pmodules_output_message "${PREFIX}/.info"
_pmodules_load_dependencies "${PREFIX}/.dependencies"
}
_pmodules_setenv ${PREFIX} ${name} ${version}
_pmodules_update_loaded_modules ${group} ${name} ${version}
debug "return from lib"

View File

@@ -1,157 +0,0 @@
#!/bin/bash
if [[ -z ${bindir} ]]; then
local bindir=$(dirname "${BASH_SOURCE}")
bindir=$(cd "${bindir}"/.. && pwd)"/bin"
fi
pmodules::get_options() {
"${bindir}/getopt" "$@"
}
pmodules::check_env_vars() {
[[ -n "${PMODULES_ROOT}" ]] &&
[[ -n "${PMODULES_CONFIG_DIR}" ]] &&
[[ -n "${PMODULES_TEMPLATES_DIR}" ]] &&
[[ -n "${PMODULES_HOME}" ]] &&
[[ -n "${PMODULES_VERSION}" ]] || std::die 1 "
Error: the module environment you are going to use as source has not been
initialized properly!"
}
pmodules::check_directories() {
local -r src_prefix="$1"
[[ -d "${src_prefix}" ]] &&
[[ -d "${src_prefix}/${PMODULES_CONFIG_DIR}" ]] &&
[[ -d "${src_prefix}/${PMODULES_TEMPLATES_DIR}" ]] &&
[[ -d "${src_prefix}/Tools/Pmodules/${PMODULES_VERSION}" ]] || std::die 1 "
Error: the module environment '${src_prefix}' has not been initialized properly!"
}
pmodules::check_env() {
pmodules::check_env_vars
pmodules::check_directories "${PMODULES_ROOT}"
}
std::log() {
local -ri fd=$1
local -r fmt="$2\n"
shift 2
printf -- "$fmt" "$@" 1>&$fd
}
std::info() {
std::log 2 "$1" "${@:2}"
}
std::error() {
std::log 2 "$1" "${@:2}"
}
std::debug() {
[[ ${PMODULES_DEBUG} ]] || return 0
std::log 2 "$@"
}
std::die() {
local -ri ec=$1
shift
if [[ -n $@ ]]; then
local -r fmt=$1
shift
std::log 2 "$fmt" "$@"
fi
exit $ec
}
#
# get answer to yes/no question
#
# $1: prompt
#
std::get_YN_answer() {
local -r prompt="$1"
local ans
read -p "${prompt}" ans
case ${ans} in
y|Y )
return 0;;
* )
return 1;;
esac
}
#
# return normalized abolute pathname
# $1: filename
std::get_abspath() {
local -r fname=$1
[[ -r "${fname}" ]] || return 1
if [[ -d ${fname} ]]; then
echo $(cd "${fname}" && pwd)
else
local -r dname=$(dirname "${fname}")
echo $(cd "${dname}" && pwd)/$(basename "${fname}")
fi
}
std::append_path () {
local -r P=$1
local -r d=$2
if ! echo ${!P} | egrep -q "(^|:)${d}($|:)" ; then
if [[ -z ${!P} ]]; then
eval $P=${d}
else
eval $P=${!P}:${d}
fi
fi
}
std::prepend_path () {
local -r P=$1
local -r d=$2
if ! echo ${!P} | egrep -q "(^|:)${d}($|:)" ; then
if [[ -z ${!P} ]]; then
eval $P=${d}
else
eval $P=${d}:${!P}
fi
fi
}
std::remove_path() {
local -r P=$1
local -r d=$2
local new_path=''
local -r _P=( ${!P//:/ } )
# loop over all entries in path
for entry in "${_P[@]}"; do
[[ "${entry}" != "${d}" ]] && new_path+=":${entry}"
done
# remove leading ':'
eval ${P}="${new_path:1}"
}
#
# split file name
#
std::split_fname() {
local -r savedIFS="${IFS}"
IFS='/'
local std__split_fname_result__=( $(echo "${@: -1}") )
IFS=${savedIFS}
eval $1=\(\"\${std__split_fname_result__[@]}\"\)
if (( $# >= 3 )); then
eval $2=${#std__split_fname_result__[@]}
fi
}
# Local Variables:
# mode: sh
# sh-basic-offset: 8
# tab-width: 8
# End:

View File

@@ -1,6 +0,0 @@
#!/bin/sh --noprofile
unset BASH_ENV
declare -r bindir=$( cd $(dirname $0) && pwd -P )
"${bindir}/bash" --noprofile --norc "${bindir}/../libexec/modmanage.bash" "$@"

View File

@@ -1,775 +0,0 @@
#!@PMODULES_HOME@/bin/bash
# we have to unset CDPATH, otherwise 'cd' prints the directoy!
unset CDPATH
# used for some output only
declare -r CMD=$(basename "$0")
declare -r mydir=$(cd $(dirname "$0") && pwd)
declare -r prefix=$(dirname "${mydir}")
declare -r bindir="${prefix}/bin"
declare -r libdir="${prefix}/lib"
declare -r libexecdir="${prefix}/libexec"
source "${libdir}/libpmodules.bash"
PATH="${bindir}:${PATH}"
_exit () {
std::die 1 "Interrupted..."
}
_err () {
std::info "Oops: got an error in function '${FUNCNAME[1]}', line ${BASH_LINENO[0]}"
std::die 1 "Aborting ..."
}
trap '_exit' INT TERM
trap '_err' ERR
# make sure that everything is used from this version
declare PMODULES_VERSION='@PMODULES_VERSION@'
print_version() {
echo "
Pmodules @PMODULES_VERSION@ using Tcl Environment Modules @MODULES_VERSION@
Copyright GNU GPL v2
" 1>&2
}
usage() {
local -r prog=$(basename $0)
print_version
echo "
Usage: ${prog} [ switches ] [ subcommand ] [subcommand-args ]
Switches:
--dry-run do nothing
--force force overwrite
Available SubCommands and Args:
init [--src=<src>] [--user=<user>] <dst>
Initialize a new minimal Pmodule environment.
install <module> [--with=<dep>...]
Install matching modules
sync [--delete] [--dst=<dst>] <src>
Synchronize modules.
"
}
declare force='no'
declare dry_run='no'
declare DRY=''
declare subcommand=''
declare sargs=()
subcommand_help_init() {
echo "
init [--src=<src>] [--user=<user>] [--version=<version>] <dst>
Initialize a new minimal Pmodule environment in directory
<dst>. The <user> parameter must only be present if
${prog} is executed as root.
" 1>&2
}
subcommand_help_install() {
echo "
install <module>... [--with=<dep>...] [--release=<release>...] [--src=<src>]
Install matching modules
" 1>&2
}
subcommand_help_sync() {
echo "
sync [--delete] [--dst=<dst>] <src>
Synchronize environment modules and configuration files
from Pmodule environment <src> to Pmodule environment <dst>
(default: currently active Pmodule environment).
Not yet implemented:
If --delete is given, unmarked modules present in <dst>
will be deleted.
" 1>&2
}
subcommand_help() {
if [[ $# == 0 ]]; then
usage
elif typeset -F subcommand_help_$1 > /dev/null 2>&1 ; then
# help for sub-command
subcommand_help_$1
else
usage
fi
}
#
# Derive the relative module installation path
# from the relative modulefile path
#
# $1: relative module file path
#
get_module_prefix() {
local -a comp=( ${1//\// } ) # split rel.path into components
local path="${comp[0]}" # result path
local -i i
for ((i=1; i<${#comp[@]}-1; i+=2)); do
path+="/${comp[$((-i-1))]}/${comp[$((-i))]}"
done
echo "${path}"
}
#
# Derive the relative module release file path
# from the relative module file path
#
# $1: relative module file path
#
get_releasefile_name() {
echo "$(dirname "$1")/.release-$(basename "$1")"
}
#
# Sync a module from one Pmodules environment to another:
# - sync module installation
# - sync modulefile
# - sync release file
#
# Note:
# We do not take care of files in $PMODULES_ROOT/$PMODULES_TEMPLATES_DIR. If
# the modulefile is a sym-link it is expected that the target exists.
#
# $1: relative modulefile path (something like: Tools/gnuplot/5.0.0)
# $2: source prefix of Pmodule environment
# $3: target prefix of Pmodule environment
#
sync_module() {
local -r rel_modulefile=$1
local -r src_prefix=$2
local -r target_prefix=$3
local -r rel_module_prefix=$( get_module_prefix "${rel_modulefile}" )
local -r rel_releasefile=$( get_releasefile_name "${rel_modulefile}" )
# install/update module
if [[ ! -d "${target_prefix}/${rel_module_prefix}" ]] || [[ "${force}" == 'yes' ]]; then
$DRY mkdir -p "${target_prefix}/${rel_module_prefix}" || return $?
$DRY rsync --links --perms --recursive --delete \
"${src_prefix}/${rel_module_prefix}/" \
"${target_prefix}/${rel_module_prefix}/" 2>/dev/null || return $?
fi
local -r src_modulefile="${src_prefix}/${rel_modulefile}"
local -r src_releasefile="${src_prefix}/${rel_releasefile}"
local -r target_modulefile="${target_prefix}/${rel_modulefile}"
local -r target_releasefile="${target_prefix}/${rel_releasefile}"
# create target directory for module- and release-file
if [[ -e "${src_modulefile}" ]] || [[ -e "${src_releasefile}" ]]; then
local dir=$( dirname "${target_modulefile}" )
$DRY mkdir -p "${dir}" || return $?
fi
# copy modulefile
if [[ -e "${src_modulefile}" ]]; then
$DRY rsync --links --perms --recursive \
"${src_modulefile}" "${target_modulefile}" 2>/dev/null || return $?
fi
# copy release-file
if [[ -e "${src_releasefile}" ]]; then
$DRY rsync --links --perms --recursive \
"${src_releasefile}" "${target_releasefile}" 2>/dev/null|| return $?
fi
}
#
# Sync the Pmodules configuration and templates
#
# $1: source prefix of Pmodule environment
# $2: target prefix of Pmodule environment
#
sync_config() {
src="$1/${PMODULES_CONFIG_DIR}/"
dst="$2/${PMODULES_CONFIG_DIR}/"
$DRY rsync --recursive --links --perms --delete \
"${src}" "${dst}" 2>/dev/null || return $?
sed -i.bak "s/PMODULES_VERSION=\(.*\)/PMODULES_VERSION=${PMODULES_VERSION}/" "${dst}/environment.bash"
echo
src="$1/${PMODULES_TEMPLATES_DIR}/"
dst="$2/${PMODULES_TEMPLATES_DIR}/"
$DRY rsync --recursive --links --perms --delete --exclude="${src}/.git*" \
"${src}" "${dst}" 2>/dev/null || return $?
echo
}
#
# Delete a module
#
# $1: relative modulefile path
# $2: target prefix of Pmodule environment
#
delete_module() {
echo "Not implemented yet!"
}
subcommand_init() {
local src=''
local target_prefixes=()
local user=''
local opts=''
opts=$(pmodules::get_options -o h -l src: -l user: -l help -l version: -- "$@")
if [[ $? != 0 ]]; then
subcommand_help_init
exit 1
fi
eval set -- "${opts}"
while (($# > 0)); do
case $1 in
--src )
src=$2
shift
;;
--user )
user=$2
shift
;;
--version )
PMODULES_VERSION=$2
shift
;;
-- )
:
;;
-* | -h | --help )
echo "$1: illegal option" 1>&2
subcommand_help_init
exit 1
;;
* )
target_prefixes+=( "$1" )
;;
esac
shift
done
(( ${#target_prefixes[@]} != 0 )) || \
std::die 1 "Error: no target directory specified!"
# if source directory is not passed as argument, derive it from script name
if [[ -z "${src}" ]]; then
src=$(cd "${bindir}/../../../.." && pwd)
fi
[[ -d "${src}" ]] || \
std::die 1 "Error: ${src}: source directory does not exist!"
[[ -r "${src}/config/profile.bash" ]] || \
std::die 1 "Error: ${src}: shell profile does not exist or is not readable!"
source "${src}/config/profile.bash"
local -i euid=$(id -u)
if (( euid == 0 )); then
[[ -n "${user}" ]] || \
std::die 1 "Error: --user parameter is required!"
id -u "${user}" > /dev/null 2>&1 || \
std::die 1 "Error: Unable to retrieve user id of user '${user}'"
else
[[ -z "${user}" ]] || \
std::die 1 "Error: --user option is only allowed if running as root!"
fi
pmodules::check_env || \
std::die 1 "Giving up..."
echo "
Attempting to create a minimal module environment from the
environment at '${PMODULES_ROOT}'
"
init_pmodules_environment() {
local -r src_prefix="${PMODULES_ROOT}"
local -r target_prefix=$1
local src=''
local dst=''
echo "Initializing target directory '${target_prefix}' ..."
echo
if [[ -d "${target_prefix}" ]] && [[ ${force} == no ]]; then
echo "Warning: ${target_prefix} already exists."
std::get_YN_answer "Do you really want to re-run the initialization? (y/N) " || \
std::die 1 "Abort ..."
fi
force='yes'
echo "Creating target directory '${target_prefix}'..."
$DRY mkdir -p "${target_prefix}" || \
std::die 1 "Error: make directory failed!"
echo
echo "Syncing configuration ..."
sync_config "${PMODULES_ROOT}" \
"${target_prefix}" || \
std::die 1 "Error: configuration synchronization failed!"
echo "Syncing Pmodules ${PMODULES_VERSION} from '${src_prefix}' to '${target_prefix}'..."
sync_module "Tools/Pmodules/${PMODULES_VERSION}" \
"${src_prefix}" \
"${target_prefix}" || \
std::die 1 "Error: sync Pmodules failed!"
mkdir -p "${target_prefix}/Tools/${PMODULES_MODULEFILES_DIR}"
echo
dst="${target_prefix}/${PMODULES_CONFIG_DIR}/environment.bash"
echo "Adding installation source '${src_prefix}' to '${dst}'..."
sed -i.bak '/PMODULES_INSTALL_SOURCE/d' "${dst}"
echo "declare -x PMODULES_INSTALL_SOURCE=\"${src_prefix}\"" >> "${dst}"
echo
if [[ -n "${user}" ]]; then
echo "Changing user of new module environment to '${user}'..."
$DRY chown -R "${user}" "${target_prefix}" || \
std::die 1 "Error: changing owner failed!"
echo
fi
echo "New minimal module environment created at '${target_prefix}'."
echo "To use this environment, execute"
echo " sudo ln -fs ${target_prefix} /opt/psi"
echo " source /opt/psi/${PMODULES_CONFIG_DIR}/profile.bash"
}
umask 022
for target_prefix in "${target_prefixes[@]}"; do
init_pmodules_environment "${target_prefix}"
done
}
declare -a Groups=()
declare -A HierarchyDepths
get_groups () {
local -r root="$1"
{
cd "${root}"
# for some unknown reason [A-Z]* doesn't work on (some?) SL6 systems
for f in [ABCDEFGHIJKLMNOPQRSTUVWXYZ]*; do
[[ -d ${f}/${PMODULES_MODULEFILES_DIR} ]] || continue
Groups+=( $f )
done
};
}
#
# $1: root of modulefile hierarchy
get_hierarchy_depth () {
local -r root="$1"
local -a modulefiles_dir
std::split_fname modulefiles_dir "${PMODULES_MODULEFILES_DIR}"
local -ir off=$(( ${#modulefiles_dir[@]} + 3 ))
{
cd "${root}"
local group
for group in "${Groups[@]}"; do
local fname=$(find "${group}/${PMODULES_MODULEFILES_DIR}" \
-depth \( -type f -o -type l \) -print -quit)
[[ -n ${fname} ]] || continue
#local -a tmp2=( ${fname//\// } )
local -a tmp
std::split_fname tmp "${fname}"
(( HierarchyDepths[$group]=${#tmp[@]}-off ))
done
};
}
subcommand_install() {
local opts=''
local -a with=()
local -a releases=()
local -a module_pattern=()
local src_prefix="${PMODULES_INSTALL_SOURCE}"
local -r target_prefix="${PMODULES_ROOT}"
local modulefile=''
local -A modules_to_install
local -A dependencies_to_install
local -A map_to_family
local -a initial_modulepath=()
#
# Resolve dependencies to given module
#
# $1: modulefile relativ to src prefix. Something like:
# MPI/modulefiles/gcc/4.9.2/openmpi/1.8.4/hdf5/1.8.14
#
# Notes:
# The variables
# initial_modulepath
# modules_to_install
# map_to_family
# from the calling function are used!
#
resolve_dependencies_of_module () {
local -r modulefile=$1
local -a modulepath=( "${initial_modulepath[@]}" )
# compute filename with dependencies of given module
local -i i=0 n=0
std::split_fname items n "${modulefile}"
local fname_dependencies="${src_prefix}/${items[0]}"
for (( i = n-2; i >= 2; i-=2 )); do
fname_dependencies+="/${items[$i]}/${items[i+1]}"
done
fname_dependencies+='/.dependencies'
[[ -r ${fname_dependencies} ]] || return 0
# loop over all dependecies
local dep
while read dep; do
# skip empty lines
# :FIXME: skip comments?!
[[ -z ${dep} ]] && continue
# search for module with current modulepath and remember
local modulename=$(find "${modulepath[@]}" -path "*/${dep}" 2>/dev/null | head -n 1 )
[[ -n ${modulename} ]] || \
std::die 3 "Oops: required module '${dep}' not found!"
modulename=${modulename/${src_prefix}\/}
dependencies_to_install[${modulename}]='.'
resolve_dependencies_of_module "${modulename}"
# append new node in hierarchy to modulepath
if [[ -n ${map_to_family[${dep}]} ]]; then
local path="${src_prefix}/${map_to_family[${dep}]}/${PMODULES_MODULEFILES_DIR}/"
path+="${modulename/*\/${PMODULES_MODULEFILES_DIR}\/}"
modulepath+=( "${path}" )
fi
done < "${fname_dependencies}"
}
print_modules_to_install() {
local modulefile
std::info "The following modules will be installed/updated:"
for modulefile in "${!modules_to_install[@]}"; do
if [[ -e "${target_prefix}/${modulefile}" ]]; then
std::info " Updating: ${modulefile/\/${PMODULES_MODULEFILES_DIR}\//: }"
else
std::info " Installing: ${modulefile/\/${PMODULES_MODULEFILES_DIR}\//: }"
fi
done 2>&1 | sort
if (( ${#dependencies_to_install[@]} > 0 )); then
std::info "\nThe following dependencies will be installed/updated:"
for modulefile in "${!dependencies_to_install[@]}"; do
if [[ -e "${target_prefix}/${modulefile}" ]]; then
std::info " Updating: ${modulefile/\/${PMODULES_MODULEFILES_DIR}\//: }"
else
std::info " Installing: ${modulefile/\/${PMODULES_MODULEFILES_DIR}\//: }"
fi
done 2>&1 | sort
fi
std::info ""
std::get_YN_answer "Do you want to continue? [n] " || \
std::die 1 "Aborting..."
std::info ""
}
opts=$(pmodules::get_options -o hf -l dry-run -l force -l with: -l release: -l help -l src: -- "$@")
if [[ $? != 0 ]]; then
subcommand_help_install
exit 1
fi
eval set -- "${opts}"
while (($# > 0)); do
case $1 in
--dry-run )
DRY='echo'
;;
--force | -f )
force='yes'
;;
--release )
releases+=( "$2" )
shift
;;
--src )
src_prefix="$2"
shift
;;
--with )
with+=( "$2" )
shift
;;
-- )
:
;;
-h | --help )
subcommand_help_install
exit 1
;;
-* )
echo "$1: illegal option" 1>&2
subcommand_help_init
exit 1
;;
* )
module_pattern+=( "$1" )
;;
esac
shift
done
[[ -n ${src_prefix} ]] \
|| std::die 3 "Oops: no installation source given."
[[ -d ${src_prefix} ]] \
|| std::die 3 "Oops: '${src_prefix}' is not a valid installation source."
# scan available groups and their depth
get_groups "${src_prefix}"
get_hierarchy_depth "${src_prefix}"
# set initial modulepath
local group
for group in "${!HierarchyDepths[@]}"; do
if (( ${HierarchyDepths[${group}]} == 0 )); then
initial_modulepath+=( "${src_prefix}/${group}/${PMODULES_MODULEFILES_DIR}" )
fi
done
#
# create a mapping from module name to their family.
# Examples:
# gcc/5.2.0 -> Compiler
# openmpi/1.8.4 -> MPI
local _fname=''
while read _fname; do
local _family="${_fname%/${PMODULES_MODULEFILES_DIR}/*}"
local -a items
std::split_fname items "${_fname#*/${PMODULES_MODULEFILES_DIR}/}"
local -i n=${#items[*]}
# We are only interested in families adding something to
# the modulepath.
if (( n >= 4 )); then
local _key=$( IFS='/'; echo "${items[*]:$n-4:2}" )
map_to_family[$_key]=${_family}
fi
done < <({ cd "${src_prefix}" && \
find */"${PMODULES_MODULEFILES_DIR}" \
\( -type l -o -type f \) \! -name ".*"; } 2>/dev/null )
#
# search for to be installed modules and their dependencies
#
local -i n=0
while read modulefile; do
resolve_dependencies_of_module "${modulefile}"
modules_to_install["${modulefile}"]+='.'
let n+=1
done < <(${PMODULES_HOME}/bin/modulecmd bash search \
"${module_pattern[@]}" \
"${with[@]/#/--with=}" \
"${releases[@]/#/--release=}" \
--no-header --print-modulefiles \
--src="${src_prefix}" 2>&1 1>/dev/null)
(( n == 0 )) && \
std::die 0 "No matching modules found ..."
print_modules_to_install
# install ...
for modulefile in "${!modules_to_install[@]}" "${!dependencies_to_install[@]}"; do
if [[ -e "${target_prefix}/${modulefile}" ]]; then
std::info " Updating: ${modulefile/\/${PMODULES_MODULEFILES_DIR}\//: }"
else
std::info " Installing: ${modulefile/\/${PMODULES_MODULEFILES_DIR}\//: }"
fi
sync_module "${modulefile}" \
"${src_prefix}" \
"${target_prefix}"
done
std::info "\nDone!\n"
}
#
# delete specified module(s)
#
subcommand_delete() {
:
}
#
# remove modules which have been removed in our source
#
subcommand_cleanup() {
:
}
subcommand_sync() {
local delete=false
local opts=''
local dst_prefix=''
local src_prefix=''
opts=$(pmodules::get_options -o h -l dst: -l delete -l help -- "$@")
if [[ $? != 0 ]]; then
subcommand_help_sync
exit 1
fi
eval set -- "${opts}"
while (($# > 0)); do
case $1 in
--dst )
dst_prefix="$2"
shift
;;
--delete )
delete=true
;;
-- )
:
;;
-* | -h | --help )
echo "$1: illegal option" 1>&2
subcommand_help_init
exit 1
;;
* )
[[ -n "${src_prefix}" ]] && \
std::die 1 "Error: Only one source is allowed!"
src_prefix="$1"
;;
esac
shift
done
unset -v opts
if [[ -z "${dst_prefix}" ]]; then
dst_prefix="${PMODULES_ROOT}"
fi
(
PMODULES_ROOT="${dst_prefix}" pmodules::check_env || \
std::die 1 "Error: invalid destination modules environment!"
) || std::die 1 "Giving up..."
: ${src_prefix:=${PMODULES_INSTALL_SOURCE}}
if [[ -z "${src_prefix}" ]]; then
std::die 1 "Error: no source module environment was specified!"
fi
(
PMODULES_ROOT="${src_prefix}" pmodules::check_env || \
std::die 1 "Error: invalid source modules environment!"
) || std::die 1 "Giving up..."
[[ "$( cd "$src_prefix"; pwd -P )" == "$( cd "$dst_prefix"; pwd -P )" ]] && \
std::die 1 "Error: source and destination are equal!"
local modbin=${PMODULES_HOME#"${PMODULES_ROOT}/"}/bin/modulecmd.tcl
local file_type_src=$( file -b "${src_prefix}/${modbin}" 2>&1 || echo err1 )
local file_type_dst=$( file -b "${dst_prefix}/${modbin}" 2>&1 || echo err2 )
[[ "${file_type_src}" == "${file_type_dst}" ]] || \
std::die 1 "Error: The file signatures in the source and destination installation do not match!"
unset -v file_type_src file_type_dst
local dialog_script="${PMODULES_HOME}/bin/dialog.bash"
[[ -r "$dialog_script" ]] || \
std::die 1 "Error: Unable to find dialog script of installation $dialog_script";
DIALOG_LIB=1 # use dialog script as a library
source "$dialog_script" # dialog functions
# Redefine module_out to append modules to the selected_modules variable
local -a selected_modules
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_prefix}" "${src_prefix}" || {
# this calls module_out for each selected module,
#filling up the selected_modules array
echo "Abort!"
exit 1
}
local -a destination_modules=( $(cd "${dst_prefix}/${PMODULES_MODULEFILES_DIR}"; find -L . -type f | while read f; do n=${f##*/}; [[ "${n:0:1}" == "." ]] || echo ${f#./}; done) )
# redefine set difference, the version in dialog.bash only handles integers
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[@]}
}
if [[ "$delete" == "true" ]]; then
local -a modules_delete=( $(set_difference "${destination_modules[*]}" "${selected_modules[*]}") )
for m in "${modules_delete[@]}"; do
echo "Deleting module $m ..."
delete_module "$m" "$dst_prefix"
done
unset modules_delete
fi
local -a modules_copy=( $(set_difference "${selected_modules[*]}" "${destination_modules[*]}") )
if [[ -n $modules_copy ]]; then
echo "Syncing configuration ..."
sync_config "$src_prefix" "$dst_prefix" || \
std::die 1 "Error: syncing the configuration failed"
fi
for m in "${modules_copy[@]}"; do
echo "Copying module $m ..."
sync_module "$m" "$src_prefix" "$dst_prefix" || \
std::die 1 "Error: syncing of module $m failed!"
done
unset modules_copy
}
while (($# > 0)); do
case $1 in
-h | -H | -\? | --help | -help )
usage
exit 1
;;
-V | --version )
print_version
exit 1
;;
-f | --force )
force='yes'
;;
--dry-run )
dry_run='yes'
DRY='echo'
;;
-* )
echo "$1: unknown switch.\n" 1>&2
exit 1
;;
init|install|sync|help )
subcommand="subcommand_$1"
shift
sargs=( $* )
shift $#
;;
* )
echo "$1: unknown sub-command" 1>&2
exit 1
esac
shift || :
done
if [[ -z ${subcommand} ]]; then
usage
exit 1
fi
[[ -z "${PMODULES_ROOT}" ]] && \
std::die 1 "Error: No current module environment is configured!"
$subcommand "${sargs[@]}"
# Local Variables:
# mode: sh
# sh-basic-offset: 8
# tab-width: 8
# End:

View File

@@ -1,236 +0,0 @@
#!/usr/bin/env bash
declare -r DEFAULT_SRC="/afs/psi.ch/sys/psi.@sys"
declare -r DEFAULT_DST="/opt/psi.local"
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
}
die() {
echo "$1" >&2
exit 1
}
# check if directory $1 is a valid prefix
is_module_prefix() {
if [[ -d "$1" ]] &&
[[ -d "$1/$PMODULES_CONFIG_DIR" ]] &&
[[ -d "$1/$PMODULES_MODULEFILES_DIR" ]]
then
return 0
fi
return 1
}
# set the source and destination module installations
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 "$PMODULES_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
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
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
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/$PMODULES_MODULEFILES_DIR/$2\""
echo "rm -v \"$3/$PMODULES_MODULEFILES_DIR/$( get_release_path $2 )\""
echo "rmdir -vp \"$( dirname "$3/$PMODULES_MODULEFILES_DIR/$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
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/$PMODULES_MODULEFILES_DIR/$2" )
(
cd $3
rsync --links --perms --relative --verbose "$PMODULES_MODULEFILES_DIR/$2" "$4"
rsync --links --perms --relative --verbose "$PMODULES_MODULEFILES_DIR/$( 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
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/$PMODULES_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
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/$PMODULES_MODULEFILES_DIR"; find -L . -type f | while read f; do echo ${f#./}; done) )
# redefine set difference, the version in dialog.bash only handles integers
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/$PMODULES_CONFIG_DIR from $src_dir/$PMODULES_CONFIG_DIR" 1>&2
else
(
local -a extraoption="$( [[ "$delete" == "true" ]] && echo --delete )"
cd "$src_dir"
rsync --recursive --links --perms --relative $extraoption --verbose --exclude .git "$PMODULES_CONFIG_DIR" "$dst_dir"
echo "updated: $PMODULES_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 "$@"

View File

@@ -1,6 +0,0 @@
#!/bin/sh --noprofile
unset BASH_ENV
declare -r bindir=$( cd $(dirname $0) && pwd -P )
"${bindir}/bash" --noprofile --norc "${bindir}/../libexec/modulecmd.bash" "$@"

File diff suppressed because it is too large Load Diff

View File

@@ -1,59 +0,0 @@
#!/bin/bash
#
#############################################################################
# D O N O T C H A N G E T H I S F I L E ! #
#############################################################################
#############################################################################
# read Pmodules configuration
#
_init_env_file="$(dirname ${BASH_SOURCE})/environment.bash"
if [[ ! -r "${_init_env_file}" ]]; then
echo "Oops: cannot initialize Modules!"
echo "${_init_env_file}: file does not exist or is not readable."
return 1
fi
source "${_init_env_file}"
unset _init_env_file
############################################################################
# check configuration
#
if [[ -z ${PMODULES_ROOT} ]]; then
echo "Oops: Pmodules root not set." 1>&2
return 1
fi
if [[ ! -d ${PMODULES_ROOT} ]]; then
echo "Oops: ${PMODULES_ROOT}: Set as Pmodules root, but this is not a directory." 1>&2
return 1
fi
if [[ -z ${PMODULES_VERSION} ]]; then
echo "Oops: ${PMODULES_VERSION}: Pmodules version not set." 1>&2
return 1
fi
if [[ -z ${PMODULES_HOME} ]]; then
echo "Oops: Pmodules home not set." 1>&2
return 1
fi
if [[ ! -d ${PMODULES_HOME} ]]; then
echo "Oops: ${PMODULES_HOME}: Set as Pmodules home, but this is not a directory." 1>&2
return 1
fi
############################################################################
# inititialize Pmodules for bash
#
_init_bash="${PMODULES_HOME}/init/bash"
if [[ ! -r "${_init_bash}" ]]; then
echo "Oops: cannot initialize Modules!"
echo "${_init_bash}: File does not exist or is not readable."
return 1
fi
source "${_init_bash}"
unset _init_bash
# Local Variables:
# mode: sh
# sh-basic-offset: 8
# tab-width: 8
# End:

View File

@@ -1,69 +0,0 @@
#!/bin/tcsh
#############################################################################
# read Pmodules configuration
#
set _init_env_file="/opt/psi/config/environment.bash"
if ( ! -r "$_init_env_file" ); then
echo "Oops: cannot initialize Modules!"
echo "$_init_env_file: file does not exist or is not readable."
return 1
fi
source "$_init_env_file"
unset _init_env_file
############################################################################
# check configuration
#
if ( ! $?PMODULES_PREFIX ) then
echo "Oops: Pmodules prefix not set."
return 1
endif
if ( "$PMODULES_PREFIX" == "" ) then
echo "Oops: Pmodules prefix set to empty string!"
endif
if ( ! -d ${PMODULES_PREFIX} ) then
echo "Oops: ${PMODULES_PREFIX}: Set as Pmodules prefix, but this is not a directory!"
return 1
endif
if ( ! $?PMODULES_VERSION ) then
echo "Oops: Pmodules version not set!"
return 1
endif
if ( "$PMODULES_VERSION" == "" ) then
echo "Oops: Pmodules version set to empty string!"
return 1
endif
if ( $?PMODULES_HOME ) then
echo "Oops: Pmodules home not set!"
return 1
endif
if ( "$PMODULES_HOME" == "" ) then
echo "Oops: Pmodules home set to empty string!"
return 1
fi
if ( ! -d "$PMODULES_HOME" ) then
echo "Oops: $PMODULES_HOME: Set as Pmodules home, but this is not a directory!"
return 1
endif
############################################################################
# inititialize Pmodules for bash
#
set _init_csh="$PMODULES_HOME/init/csh"
if ( ! -r "$_init_csh" ) then
echo "Oops: cannot initialize Modules!"
echo "$_init_csh: File does not exist or is not readable."
return 1
fi
source "$_init_csh"
unset _init_csh
# Local Variables:
# mode: csh
# sh-basic-offset: 8
# tab-width: 8
# End:

View File

@@ -1,8 +0,0 @@
bash 4.3.30
coreutils 8.23
dialog 1.2.1
getopt 1.1.6
gettext 0.19.4
Modules 3.2.10
Pmodules 0.99.5
Tcl 8.6.3

View File

@@ -1,26 +0,0 @@
#!/bin/bash
source "$(dirname $0)/../../../lib/libpmodules.bash"
pmodules.configure() {
case ${OS} in
Linux )
srcdir="${MODULE_SRCDIR}/unix"
;;
Darwin )
srcdir="${MODULE_SRCDIR}/macosx"
;;
esac
"${srcdir}"/configure \
--prefix="${PREFIX}" \
--enable-shared=no \
|| exit 1
}
pmodules.post_install() {
{ cd "${PREFIX}"/bin && rm -f tclsh && ln -fs tclsh${V%.*} tclsh; };
}
pmodules.add_to_group 'Tools'
pmodules.set_docfiles 'license.terms' 'README'
pmodules.make_all

View File

@@ -1,12 +0,0 @@
#!/bin/bash
source "$(dirname $0)/../../../lib/libpmodules.bash"
pmodules.configure() {
"${MODULE_SRCDIR}"/configure \
--prefix="${PREFIX}" \
|| exit 1
}
pmodules.add_to_group 'Tools'
pmodules.make_all

View File

@@ -1,7 +0,0 @@
#!/bin/bash
declare -r BASE_DIR=$(cd "$(dirname $0)/../.." && pwd)
declare -r BOOTSTRAP_DIR="${BASE_DIR}/scripts/Bootstrap"
${BOOTSTRAP_DIR}/compile_pmodules.sh
${BOOTSTRAP_DIR}/install_pmodules.sh

View File

@@ -1,54 +0,0 @@
#!/bin/bash
declare -r BASE_DIR=$(cd "$(dirname $0)/../.." && pwd)
declare -r BOOTSTRAP_DIR="${BASE_DIR}/scripts/Bootstrap"
source "${BASE_DIR}/lib/lib.bash"
unset PMODULES_HOME
unset PMODULES_VERSION
read_versions "${BOOTSTRAP_DIR}/Pmodules_version.conf"
source "/opt/psi/config/environment.bash"
#if [[ -n ${PMODULES_DIR} ]] && [[ "${PMODULES_DIR}" != "/" ]] && [[ -d "${PMODULES_DIR}" ]]; then
# rm -rf "${PMODULES_DIR}"
#fi
build () {
local -r name="$1"
local -r version="$2"
"${BOOTSTRAP_DIR}/${name}/build" --bootstrap --disable-cleanup "${version}" || \
std::die 3 "Compiling '${name}' failed!"
}
if [[ ! -f "${PMODULES_HOME}/bin/base64" ]]; then
build coreutils "${COREUTILS_VERSION}"
fi
if [[ ! -f "${PMODULES_HOME}/bin/xgettext" ]]; then
build gettext "${GETTEXT_VERSION}"
fi
if [[ ! -f "${PMODULES_HOME}/bin/getopt" ]]; then
build getopt "${GETOPT_VERSION}"
fi
if [[ ! -f "${PMODULES_HOME}/bin/dialog" ]]; then
build dialog "${DIALOG_VERSION}"
fi
if [[ ! -f "${PMODULES_HOME}/bin/bash" ]]; then
build bash "4.3.30"
fi
if [[ ! -e "${PMODULES_HOME}/bin/tclsh" ]]; then
build Tcl "${TCL_VERSION}"
fi
if [[ ! -e "${PMODULES_HOME}/bin/modulecmd.tcl" ]]; then
build Modules "${MODULES_VERSION}"
mv -v "${PMODULES_HOME}/bin/modulecmd" "${PMODULES_HOME}/libexec/modulecmd.tcl"
fi
echo "Done..."

View File

@@ -1,12 +0,0 @@
#!/bin/bash
source "$(dirname $0)/../../../lib/libpmodules.bash"
pmodules.configure() {
"${MODULE_SRCDIR}"/configure \
--prefix="${PREFIX}" \
|| exit 1
}
pmodules.add_to_group 'Tools'
pmodules.make_all

View File

@@ -1,12 +0,0 @@
#!/bin/bash
source "$(dirname $0)/../../../lib/libpmodules.bash"
pmodules.configure() {
"${MODULE_SRCDIR}"/configure \
--prefix="${PREFIX}" \
|| exit 1
}
pmodules.add_to_group 'Tools'
pmodules.make_all

View File

@@ -1,42 +0,0 @@
#!/bin/bash
source "$(dirname $0)/../../../lib/libpmodules.bash"
pmodules.configure() {
:
}
pmodules.build() {
case ${OS} in
Linux )
declare -x LDFLAGS="-lintl"
;;
Darwin )
declare -x LDFLAGS="-lintl -liconv -framework CoreFoundation"
;;
esac
cd "${MODULE_SRCDIR}"
make -e
}
pmodules.install() {
cd "${MODULE_SRCDIR}"
declare -x DESTDIR="${PREFIX}"
declare -x prefix=''
make -e install
}
pmodules.cleanup_build() {
cd "${MODULE_SRCDIR}"
make -e realclean
}
pmodules.add_to_group 'Tools'
pmodules.make_all
# Local Variables:
# mode: sh
# sh-basic-offset: 8
# tab-width: 8
# End:

View File

@@ -1,24 +0,0 @@
#!/bin/bash
source "$(dirname $0)/../../../lib/libpmodules.bash"
pmodules.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 \
--with-pic=yes \
|| exit 1
}
pmodules.add_to_group 'Tools'
pmodules.make_all

View File

@@ -1,46 +0,0 @@
#!/bin/bash
declare -r BASE_DIR=$(cd "$(dirname $0)/../.." && pwd)
declare -r BOOTSTRAP_DIR="${BASE_DIR}/scripts/Bootstrap"
declare -r SRC_DIR="${BOOTSTRAP_DIR}/Pmodules"
source "${BASE_DIR}/lib/lib.bash"
unset PMODULES_HOME
unset PMODULES_VERSION
read_versions "${BOOTSTRAP_DIR}/Pmodules_version.conf"
source "/opt/psi/config/environment.bash"
echo "Installing to ${PMODULES_HOME} ..."
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}" "${SRC_DIR}/modulecmd.bash.in" > "${SRC_DIR}/modulecmd.bash"
sed "${sed_cmd}" "${SRC_DIR}/modmanage.bash.in" > "${SRC_DIR}/modmanage.bash"
sed "${sed_cmd}" "${SRC_DIR}/environment.bash.in" > "${SRC_DIR}/environment.bash"
install -d -m 0755 "${PMODULES_HOME}/bin"
install -d -m 0755 "${PMODULES_HOME}/config"
install -d -m 0755 "${PMODULES_HOME}/init"
install -d -m 0755 "${PMODULES_HOME}/lib"
install -m 0755 "${SRC_DIR}/modulecmd" "${PMODULES_HOME}/bin"
install -m 0755 "${SRC_DIR}/modulecmd.bash" "${PMODULES_HOME}/libexec"
install -m 0755 "${SRC_DIR}/modmanage" "${PMODULES_HOME}/bin"
install -m 0755 "${SRC_DIR}/modmanage.bash" "${PMODULES_HOME}/libexec"
install -m 0755 "${SRC_DIR}/dialog.bash" "${PMODULES_HOME}/bin"
install -m 0755 "${SRC_DIR}/environment.bash" "${PMODULES_HOME}/config"
install -m 0755 "${SRC_DIR}/profile.bash" "${PMODULES_HOME}/config"
install -m 0644 "${SRC_DIR}/bash" "${PMODULES_HOME}/init"
install -m 0644 "${SRC_DIR}/bash_completion" "${PMODULES_HOME}/init"
install -m 0644 "${SRC_DIR}/libpmodules.bash" "${PMODULES_HOME}/lib"
install -m 0644 "${SRC_DIR}/libmodules.tcl" "${PMODULES_HOME}/lib/tcl8.6"
{
cd "${PMODULES_HOME}/lib/tcl8.6"
"${BOOTSTRAP_DIR}/mkindex.tcl"
}

View File

@@ -1,3 +0,0 @@
#!/usr/bin/env tclsh
auto_mkindex . *.tcl