- em.xyz renamed to pmodules.xxy

- underscore removed as prefix of function names
- keyword function removed
This commit is contained in:
2015-06-04 20:38:33 +02:00
parent e26a9fae7f
commit b129a8d05d
68 changed files with 522 additions and 522 deletions

View File

@@ -108,7 +108,7 @@ prepend_path () {
# Based on solution published here:
# https://stackoverflow.com/questions/273909/how-do-i-manipulate-path-elements-in-shell-scripts
#
function replace_path () {
replace_path () {
local -r path=$1
local -r removepat=$2
local -r replacestr=$3

View File

@@ -13,7 +13,7 @@ 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
set_difference() { # $1 \ $2
local -a operand1=($1)
local -a operand2=($2)
local -A members
@@ -27,7 +27,7 @@ function set_difference() { # $1 \ $2
echo ${!members[@]}
}
function set_merge() { # $1 U $2 (where $1 and $2 are disjoint)
set_merge() { # $1 U $2 (where $1 and $2 are disjoint)
if [[ -z "$1" ]]; then
echo "$2"
elif [[ -z "$2" ]]; then
@@ -37,7 +37,7 @@ function set_merge() { # $1 U $2 (where $1 and $2 are disjoint)
fi
}
function set_union() { # $1 U $2 (sorted)
set_union() { # $1 U $2 (sorted)
local -a operand1=($1)
local -a operand2=($2)
local -A members
@@ -49,7 +49,7 @@ function set_union() { # $1 U $2 (sorted)
}
# unique id for a module
function unique_id() { # $1: module info index
unique_id() { # $1: module info index
local -a minfo=( ${modlist[$1]} )
if (( ${#minfo[@]} < 4 )); then
echo ${minfo[0]}
@@ -58,7 +58,7 @@ function unique_id() { # $1: module info index
fi
}
function mod_path() { # $1: module info index
mod_path() { # $1: module info index
local -i i
local -a m=(${modlist[$1]})
local res="$PMODULES_ROOT/${fmmap[${m[0]%%/*}]}/${m[0]}"
@@ -68,7 +68,7 @@ function mod_path() { # $1: module info index
echo "$res"
}
function calc_deps() { # $1: module info index
calc_deps() { # $1: module info index
local dpath="$(mod_path $1)/.dependencies"
[[ ! -r "$dpath" ]] && return
local -a d=( $(< "$dpath") ) # dependencies as versioned module names
@@ -96,7 +96,7 @@ function calc_deps() { # $1: module info index
echo "${deps[@]}"
}
function update_deps() { # $1: 1-add dependency, -1-remove dependency $2: set of module info indices
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
@@ -117,7 +117,7 @@ function update_deps() { # $1: 1-add dependency, -1-remove dependency $2: set
}
# "$1": source module environment
function find_modules() {
find_modules() {
# construct modlist/modmap/uidmap/depcnt/fmmap/relmap arrays from module search output
local -a mc # module info components
local -i i=0
@@ -144,7 +144,7 @@ function find_modules() {
}
# "$1": source module environment
function find_families() {
find_families() {
# construct fdmap
local -a t # tcl file components
local l s n
@@ -159,7 +159,7 @@ function find_families() {
done < <(grep -R set-family "$1/*/${PMODULES_MODULEFILES_DIR}")
}
function select_uid() { # $1: module uid
select_uid() { # $1: module uid
local -a uidc=($1) # uid components
local name=${uidc[-1]%%/*} # module name
local midx=${uidmap["$1"]} # module info index
@@ -168,7 +168,7 @@ function select_uid() { # $1: module uid
update_deps 1 "$midx"
}
function preselect() { # "$1": prefix for preselected modules
preselect() { # "$1": prefix for preselected modules
# module paths must not contain white space
[[ -z "$1" ]] && return
local -a mpc # module path components
@@ -193,7 +193,7 @@ function preselect() { # "$1": prefix for preselected modules
trap - EXIT
}
function is_dependency() { # $1: module name
is_dependency() { # $1: module name
local -a map=(${modmap[$1]})
local -i m
for ((m=0; m<${#map[@]}; m++)); do
@@ -202,7 +202,7 @@ function is_dependency() { # $1: module name
return 1
}
function dialog_1() {
dialog_1() {
local -a input
local marker
local m
@@ -220,15 +220,15 @@ function dialog_1() {
return $?
}
function module_id() { # $@: module info components
module_id() { # $@: module info components
echo "$1 ${@:4}"
}
function module_release() { # $@: module info components
module_release() { # $@: module info components
echo "$2"
}
function dialog_2() { # $1: module name
dialog_2() { # $1: module name
local -a map=(${modmap[$1]})
local -a sel=(${selected[$1]})
local -i j # mapping index
@@ -250,14 +250,14 @@ function dialog_2() { # $1: module name
}
# final dialog output
function module_out() { # $1: module info index
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)
function module_picker() {
module_picker() {
find_families "$2"
find_modules "$2"
preselect "$1"

View File

@@ -476,7 +476,7 @@ subcommand_sync() {
# Redefine module_out to append modules to the selected_modules variable
local -a selected_modules
function module_out() {
module_out() {
local -a args=(${modlist[$1]})
local path=""
IFS=/
@@ -495,7 +495,7 @@ subcommand_sync() {
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
function set_difference() { # $1 \ $2
set_difference() { # $1 \ $2
local -a operand1=($1)
local -a operand2=($2)
local -A members

View File

@@ -3,7 +3,7 @@
declare -r DEFAULT_SRC="/afs/psi.ch/sys/psi.@sys"
declare -r DEFAULT_DST="/opt/psi.local"
function usage() {
usage() {
echo "
$0 [--from=<source>] [--to=<destination>] [--dryrun] [--delete]
--from source module installation (default: $DEFAULT_SRC)
@@ -17,13 +17,13 @@ $0 [--from=<source>] [--to=<destination>] [--dryrun] [--delete]
(destination cleanup)" >&2
}
function die() {
die() {
echo "$1" >&2
exit 1
}
# check if directory $1 is a valid prefix
function is_module_prefix() {
is_module_prefix() {
if [[ -d "$1" ]] &&
[[ -d "$1/$PMODULES_CONFIG_DIR" ]] &&
[[ -d "$1/$PMODULES_MODULEFILES_DIR" ]]
@@ -34,7 +34,7 @@ function is_module_prefix() {
}
# set the source and destination module installations
function get_options() {
get_options() {
local src_dir="$DEFAULT_SRC"
local dst_dir="$DEFAULT_DST"
local dryrun=false
@@ -82,7 +82,7 @@ function get_options() {
# Derive the relative module installation path
# from the relative module file path
# $1 relative module file path
function get_modpath() {
get_modpath() {
local -a comp=( ${1//\// } ) # split rel.path into components
local -a path # result path
local -i i
@@ -98,14 +98,14 @@ function get_modpath() {
# Derive the relative module release file path
# from the relative module file path
# $1 relative module file path
function get_release_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
function delete_module() {
delete_module() {
if [[ "$1" != "false" ]]; then
echo "(dryrun) delete: $2 at $3" 1>&2
return 0
@@ -126,7 +126,7 @@ function delete_module() {
# $2 relative module file path of source module to be copied to the destination
# $3 source prefix
# $4 destination prefix
function copy_module() {
copy_module() {
if [[ "$1" != "false" ]]; then
echo "(dryrun) copy: $2 from $3 to $4" 1>&2
return 0
@@ -147,7 +147,7 @@ function copy_module() {
# destination module installations
# --from=<source> default: /afs/psi.ch/sys/psi.@sys
# --to=<destination> default: /opt/psi.local
function sync_modules() {
sync_modules() {
local -a options=( $(get_options "$@") )
[[ -z "$options" ]] && exit 1
local src_dir="${options[0]}"
@@ -177,7 +177,7 @@ function sync_modules() {
local -a selected_modules
# Redefine module_out to append modules to the selected_modules variable
function module_out() {
module_out() {
local -a args=(${modlist[$1]})
local path=""
IFS=/
@@ -191,7 +191,7 @@ function sync_modules() {
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
function set_difference() { # $1 \ $2
set_difference() { # $1 \ $2
local -a operand1=($1)
local -a operand2=($2)
local -A members