mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-06-27 18:13:08 +02:00
Merge branch 'master' into 32-overlay-implementation
Conflicts: Pmodules/modulecmd.bash.in
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ -z ${sbindir} ]]; then
|
||||
local sbindir=$(dirname "${BASH_SOURCE}")
|
||||
sbindir=$(cd "${sbindir}"/.. && pwd)"/sbin"
|
||||
fi
|
||||
|
||||
pmodules::get_options() {
|
||||
local "$1"
|
||||
std::upvar $1 $("${sbindir}/getopt" "${@:2}")
|
||||
}
|
||||
|
||||
pmodules::check_env_vars() {
|
||||
[[ -n "${PMODULES_ROOT}" ]] &&
|
||||
[[ -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}/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}"
|
||||
}
|
||||
|
||||
|
||||
# Local Variables:
|
||||
# mode: sh
|
||||
# sh-basic-offset: 8
|
||||
# tab-width: 8
|
||||
# End:
|
||||
@@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
declare PMODULES_MODULEFILES_DIR='modulefiles'
|
||||
declare PMODULES_CONFIG_DIR='config'
|
||||
declare -A GroupDepths=()
|
||||
declare -A Subcommands=()
|
||||
declare -A Options=()
|
||||
declare -A Help=()
|
||||
|
||||
# initialize help text of 'module --version'
|
||||
Help['version']="
|
||||
Pmodules @PMODULES_VERSION@ using Tcl Environment Modules @MODULES_VERSION@
|
||||
Copyright GNU GPL v2
|
||||
"
|
||||
|
||||
#
|
||||
# display help text for command given in $1
|
||||
#
|
||||
print_help() {
|
||||
echo -e "${Help[$1]}" 1>&2
|
||||
std::die 1
|
||||
}
|
||||
|
||||
#
|
||||
# compute depth of modulefile directory.
|
||||
#
|
||||
# Args:
|
||||
# $1: absolute path of a modulefile directory
|
||||
#
|
||||
compute_group_depth () {
|
||||
local -r dir=$1
|
||||
test -d "${dir}" || return 1
|
||||
local group=${dir%/*}
|
||||
local group=${group##*/}
|
||||
[[ -n "${GroupDepths[${group}]}" ]] && return 0
|
||||
local -i depth=$(${find} "${dir}" -depth \( -type f -o -type l \) \
|
||||
-printf "%d" -quit 2>/dev/null)
|
||||
(( depth-=2 ))
|
||||
# if a group doesn't contain a modulefile, depth is negativ
|
||||
# :FIXME: better solution?
|
||||
(( depth < 0 )) && (( depth = 0 ))
|
||||
GroupDepths[$group]=${depth}
|
||||
}
|
||||
|
||||
#
|
||||
# (Re-)Scan available groups in given root and compute group depth's
|
||||
#
|
||||
# Args:
|
||||
# $1: root of modulefile hierarchy
|
||||
#
|
||||
scan_groups () {
|
||||
local -r root="$1"
|
||||
local moduledir
|
||||
for moduledir in ${root}/*/${PMODULES_MODULEFILES_DIR}; do
|
||||
compute_group_depth "${moduledir}"
|
||||
done
|
||||
}
|
||||
|
||||
# Local Variables:
|
||||
# mode: sh
|
||||
# sh-basic-offset: 8
|
||||
# tab-width: 8
|
||||
# End:
|
||||
+75
-7
@@ -35,6 +35,17 @@ std::die() {
|
||||
exit $ec
|
||||
}
|
||||
|
||||
std::def_cmds(){
|
||||
local path="$1"
|
||||
shift
|
||||
for cmd in "$@"; do
|
||||
eval declare -g ${cmd}=$(PATH="${path}" which $cmd 2>/dev/null)
|
||||
if [[ -z "${!cmd}" ]]; then
|
||||
std::die 255 "${cmd} not found"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#
|
||||
# get answer to yes/no question
|
||||
#
|
||||
@@ -133,16 +144,73 @@ std::replace_path () {
|
||||
}
|
||||
|
||||
#
|
||||
# split file name
|
||||
# Functions to split a path into its components.
|
||||
#
|
||||
std::split_fname() {
|
||||
local -r savedIFS="${IFS}"
|
||||
# Args:
|
||||
# $1 upvar
|
||||
# $2 absolute or relative path (depends on the function)
|
||||
# $3 opt upvar: number of components
|
||||
#
|
||||
# Notes:
|
||||
# std::split_path()
|
||||
# if the path is absolute, the first element of the returned array is empty.
|
||||
#
|
||||
# std::split_abspath()
|
||||
# the path must begin with a slash, otherwise std::die() is called with
|
||||
# an internal error message.
|
||||
#
|
||||
# std::split_relpath()
|
||||
# analog to std::split_abspath() with a relative path.
|
||||
#
|
||||
std::split_path() {
|
||||
local parts="$1"
|
||||
local -r path="$2"
|
||||
|
||||
IFS='/'
|
||||
local std__split_fname_result__=( $(echo "${@: -1}") )
|
||||
IFS=${savedIFS}
|
||||
eval $1=\(\"\${std__split_fname_result__[@]}\"\)
|
||||
local std__split_path_result=( ${std__split_path_tmp} )
|
||||
unset IFS
|
||||
std::upvar ${parts} "${std__split_path_result[@]}"
|
||||
if (( $# >= 3 )); then
|
||||
eval $2=${#std__split_fname_result__[@]}
|
||||
# return number of parts
|
||||
std::upvar "$3" ${#std__split_path_result[@]}
|
||||
fi
|
||||
}
|
||||
|
||||
std::split_abspath() {
|
||||
local parts="$1"
|
||||
local -r path="$2"
|
||||
if [[ "${path:0:1}" == '/' ]]; then
|
||||
local -r std__split_path_tmp="${path:1}"
|
||||
else
|
||||
std::die 255 "Oops: Internal error in '${FUNCNAME[0]}' called by '${FUNCNAME[1]}' }"
|
||||
fi
|
||||
|
||||
IFS='/'
|
||||
local std__split_path_result=( ${std__split_path_tmp} )
|
||||
unset IFS
|
||||
std::upvar ${parts} "${std__split_path_result[@]}"
|
||||
if (( $# >= 3 )); then
|
||||
# return number of parts
|
||||
std::upvar "$3" ${#std__split_path_result[@]}
|
||||
fi
|
||||
}
|
||||
|
||||
std::split_relpath() {
|
||||
local parts="$1"
|
||||
local -r path="$2"
|
||||
if [[ "${path:0:1}" == '/' ]]; then
|
||||
std::die 255 "Oops: Internal error in '${FUNCNAME[0]}' called by '${FUNCNAME[1]}' }"
|
||||
else
|
||||
local -r std__split_path_tmp="${path}"
|
||||
fi
|
||||
|
||||
IFS='/'
|
||||
local std__split_path_result=( ${std__split_path_tmp} )
|
||||
unset IFS
|
||||
std::upvar ${parts} "${std__split_path_result[@]}"
|
||||
if (( $# >= 3 )); then
|
||||
# return number of parts
|
||||
std::upvar "$3" ${#std__split_path_result[@]}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
+503
-657
File diff suppressed because it is too large
Load Diff
@@ -2,4 +2,10 @@
|
||||
|
||||
unset BASH_ENV
|
||||
|
||||
"@BASH@" --noprofile --norc "@MODMANAGE@ "$@"
|
||||
declare mydir=$(cd $(dirname "$0") && pwd)
|
||||
declare libexecdir="$(dirname "${mydir}")/libexec"
|
||||
|
||||
declare bash="${libexecdir}/bash"
|
||||
declare modmanage="${libexecdir}/modmanage.bash"
|
||||
|
||||
"${bash}" --noprofile --norc "${modmanage}" "$@"
|
||||
|
||||
+157
-124
@@ -1,9 +1,12 @@
|
||||
#!@BASH@ --noprofile
|
||||
#
|
||||
|
||||
#set -o nounset
|
||||
# we have to unset CDPATH, otherwise 'cd' prints the directoy!
|
||||
unset CDPATH
|
||||
PATH='/bin:/usr/bin'
|
||||
|
||||
unset CDPATH # unset CDPATH, otherwise 'cd' prints the directoy!
|
||||
unset IFS # use default IFS
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
# used in some output messages only
|
||||
declare -r CMD='module'
|
||||
@@ -13,30 +16,14 @@ declare prefix=$(dirname "${mydir}")
|
||||
declare -r libdir="${prefix}/lib"
|
||||
declare -r libexecdir="${prefix}/libexec"
|
||||
|
||||
base64=$(PATH=/bin:/usr/bin /usr/bin/which base64)
|
||||
declare -r base64
|
||||
mktemp=$(PATH=/bin:/usr/bin /usr/bin/which mktemp)
|
||||
declare -r mktemp
|
||||
sort=$(PATH=/bin:/usr/bin /usr/bin/which sort)
|
||||
declare -r sort
|
||||
awk=$(PATH=/bin:/usr/bin /usr/bin/which awk)
|
||||
declare -r awk
|
||||
rm=$(PATH=/bin:/usr/bin /usr/bin/which rm)
|
||||
declare -r rm
|
||||
logger=$(PATH=/bin:/usr/bin /usr/bin/which logger)
|
||||
declare -r logger
|
||||
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
declare -r getopt="${libexecdir}/getopt"
|
||||
declare -r find="${libexecdir}/find"
|
||||
else
|
||||
getopt=$(PATH=/bin:/usr/bin /usr/bin/which getopt)
|
||||
declare -r getopt
|
||||
find=$(PATH=/bin:/usr/bin /usr/bin/which find)
|
||||
declare -r find
|
||||
fi
|
||||
|
||||
source "${libdir}/libstd.bash"
|
||||
source "${libdir}/libpmodules.bash"
|
||||
|
||||
path="/bin:/usr/bin"
|
||||
[[ $(uname -s) == 'Darwin' ]] && path+=":${libexecdir}"
|
||||
std::def_cmds "${path}" \
|
||||
'awk' 'base64' 'find' 'getopt' 'logger' 'mktemp' \
|
||||
'rm' 'sort' 'find'
|
||||
|
||||
if [[ ${PMODULES_PURETCL} == yes ]]; then
|
||||
declare -r modulecmd="${libexecdir}/modulecmd.tcl"
|
||||
@@ -51,21 +38,11 @@ declare -r ol_replacing='r'
|
||||
|
||||
declare verbosity_lvl=${PMODULES_VERBOSITY:-'verbose'}
|
||||
|
||||
# use default IFS
|
||||
unset IFS
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
declare -A GroupDepths='()'
|
||||
declare -A Dir2OverlayMap='()'
|
||||
declare Shell=''
|
||||
declare -A Subcommands
|
||||
declare -A Options
|
||||
declare -A Help
|
||||
|
||||
declare -r pmodules_config_file="${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}/Pmodules.conf"
|
||||
|
||||
# the following settings are used if the Pmodules.conf is not available
|
||||
# the following settings are used if the Pmodules.conf doesn't exist
|
||||
|
||||
# set groups which should be available after initialization
|
||||
declare -- DefaultGroups='Tools Programming'
|
||||
@@ -76,22 +53,6 @@ declare -- ReleaseStages=':unstable:stable:deprecated:'
|
||||
# set releases which should be available after initialization
|
||||
declare -- DefaultReleaseStages='stable'
|
||||
|
||||
# In the dictionary Help we store the help text of each single command
|
||||
# and for displaying the version.
|
||||
|
||||
# initialize help text of 'module --version'
|
||||
Help['version']="
|
||||
Pmodules @PMODULES_VERSION@ using Tcl Environment Modules @MODULES_VERSION@
|
||||
Copyright GNU GPL v2
|
||||
"
|
||||
|
||||
#
|
||||
# display help text for command given in $1
|
||||
#
|
||||
print_help() {
|
||||
echo -e "${Help[$1]}" 1>&2
|
||||
std::die 1
|
||||
}
|
||||
|
||||
export_env() {
|
||||
case "${Shell}" in
|
||||
@@ -299,11 +260,13 @@ subcommand_generic0() {
|
||||
local -a args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
:
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -325,11 +288,13 @@ subcommand_generic1() {
|
||||
local -a args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
:
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -355,11 +320,13 @@ subcommand_generic1plus() {
|
||||
local args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
:
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -383,7 +350,7 @@ subcommand_generic1plus() {
|
||||
#
|
||||
Subcommands[add]='load'
|
||||
Subcommands[load]='load'
|
||||
Options['load']='-l help -o Hfsvwi -l force -l silent -l verbose -l warn -l internal'
|
||||
Options[load]='-l help -o \?Hfsvw -l force -l silent -l verbose -l warn'
|
||||
Help[load]='
|
||||
USAGE:
|
||||
module add modulefile...
|
||||
@@ -546,7 +513,7 @@ subcommand_load() {
|
||||
local overlay
|
||||
while (($# > 0)); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-f | --force )
|
||||
@@ -562,6 +529,9 @@ subcommand_load() {
|
||||
verbosity_lvl='warn'
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( $1 )
|
||||
@@ -750,7 +720,7 @@ subcommand_load() {
|
||||
#
|
||||
Subcommands[rm]='unload'
|
||||
Subcommands[unload]='unload'
|
||||
Options[unload]='-o H -l help'
|
||||
Options[unload]='-o \?H -l help'
|
||||
Help[unload]="
|
||||
USAGE:
|
||||
module rm modulefile...
|
||||
@@ -769,10 +739,13 @@ subcommand_unload() {
|
||||
local args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -820,7 +793,7 @@ subcommand_unload() {
|
||||
#
|
||||
Subcommands[switch]='swap'
|
||||
Subcommands[swap]='swap'
|
||||
Options[swap]='-o H -l help'
|
||||
Options[swap]='-o \?H -l help'
|
||||
Help[swap]="
|
||||
USAGE:
|
||||
module switch [modulefile1] modulefile2
|
||||
@@ -835,10 +808,13 @@ subcommand_swap() {
|
||||
local args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -872,7 +848,7 @@ subcommand_swap() {
|
||||
#
|
||||
Subcommands[display]='show'
|
||||
Subcommands[show]='show'
|
||||
Options[show]='-o H -l help'
|
||||
Options[show]='-o \?H -l help'
|
||||
Help[show]='
|
||||
USAGE:
|
||||
module display modulefile...
|
||||
@@ -889,10 +865,13 @@ subcommand_show() {
|
||||
local args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -1083,7 +1062,8 @@ find_module() {
|
||||
# avail [-hlt] [<module-pattern>...]
|
||||
#
|
||||
Subcommands[avail]='avail'
|
||||
Options[avail]='-l help -o Hahlmt -l all -l all-release-stages -l human -l long -l machine -l terse'
|
||||
Options[avail]='-l help -o \?Hahlmtg: -l all -l all-release-stages -l group: '
|
||||
Options[avail]+='-l human -l long -l machine -l terse'
|
||||
Help[avail]="
|
||||
USAGE:
|
||||
module avail [switches] string
|
||||
@@ -1106,8 +1086,12 @@ SWITCHES:
|
||||
-l|--long
|
||||
Output in long format.
|
||||
|
||||
-g|--group=<GROUP>
|
||||
Output modules available in <GROUP>
|
||||
|
||||
-h|--human
|
||||
Output in human readable format.
|
||||
|
||||
-m|--machine
|
||||
Output in machine readable format
|
||||
"
|
||||
@@ -1199,6 +1183,8 @@ subcommand_avail() {
|
||||
(( n > max_length )) && (( max_length=n ))
|
||||
available_modules+=("${mod}")
|
||||
done
|
||||
IFS=$'\n' available_modules=($(sort --version-sort <<<"${available_modules[*]}"))
|
||||
unset IFS
|
||||
local -i span=$(( max_length / 16 + 1 )) # compute column size
|
||||
local -i colsize=$(( span * 16 )) # as multiple of 16
|
||||
local -i column=$cols # force a line-break
|
||||
@@ -1225,7 +1211,7 @@ subcommand_avail() {
|
||||
local val=''
|
||||
while (($# > 0)); do
|
||||
case $1 in
|
||||
-H | --help | -\? )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-a | --all | --all-release-stages )
|
||||
@@ -1245,14 +1231,17 @@ subcommand_avail() {
|
||||
;;
|
||||
-g | --group | --group=* )
|
||||
if [[ $1 == --group=* ]]; then
|
||||
val="${1/--group=}"
|
||||
val="${1#--*=}"
|
||||
else
|
||||
val="$2"
|
||||
shift
|
||||
fi
|
||||
opt_groups[${val}]=1
|
||||
;;
|
||||
-- | '' )
|
||||
-- )
|
||||
shift 1
|
||||
pattern+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
pattern+=( "$1" )
|
||||
@@ -1288,7 +1277,7 @@ subcommand_avail() {
|
||||
typeset -n path=modulepath_${group}
|
||||
get_available_modules \
|
||||
mods \
|
||||
"${string}" \
|
||||
"${string}*" \
|
||||
"${opt_use_rel_stages}" \
|
||||
"${path[@]}"
|
||||
|
||||
@@ -1303,7 +1292,7 @@ subcommand_avail() {
|
||||
# use [-a|--append|-p|--prepend] [directory|group|release_stage...]
|
||||
#
|
||||
Subcommands[use]='use'
|
||||
Options[use]='-l help -o Hap -l append -l prepend'
|
||||
Options[use]='-l help -o \?Hap -l append -l prepend'
|
||||
Help[use]="
|
||||
USAGE:
|
||||
module use [-a|--append|-p|--prepend] [directory|group|release_stage|...]
|
||||
@@ -1566,7 +1555,7 @@ subcommand_use() {
|
||||
local -a args=()
|
||||
while (( $# > 0)); do
|
||||
case "$1" in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-a | --append )
|
||||
@@ -1576,6 +1565,9 @@ subcommand_use() {
|
||||
add2path_func='std::prepend_path'
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -1600,7 +1592,7 @@ subcommand_use() {
|
||||
# unuse directory|group|release_stage|...
|
||||
#
|
||||
Subcommands[unuse]='unuse'
|
||||
Options[unuse]='-o H -l help'
|
||||
Options[unuse]='-o \?H -l help'
|
||||
Help[unuse]='
|
||||
unuse directory|group|release...
|
||||
Remove the given modulefiles directory, group, release stage,
|
||||
@@ -1748,10 +1740,13 @@ subcommand_unuse() {
|
||||
local -a args=()
|
||||
while (( $# > 0)); do
|
||||
case "$1" in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -1780,7 +1775,7 @@ subcommand_unuse() {
|
||||
# sub-command
|
||||
#
|
||||
Subcommands[update]='update'
|
||||
Options[update]='-o H -l help'
|
||||
Options[update]='-o \?H -l help'
|
||||
Help[update]='
|
||||
USAGE:
|
||||
module update
|
||||
@@ -1796,7 +1791,7 @@ subcommand_update() {
|
||||
# refresh
|
||||
#
|
||||
Subcommands[refresh]='refresh'
|
||||
Options[refresh]='-o H -l help'
|
||||
Options[refresh]='-o \?H -l help'
|
||||
Help[refresh]='
|
||||
USAGE:
|
||||
module refresh
|
||||
@@ -1902,7 +1897,7 @@ pmodules_init() {
|
||||
# purge
|
||||
#
|
||||
Subcommands[purge]='purge'
|
||||
Options[purge]='-o H -l help'
|
||||
Options[purge]='-o \?H -l help'
|
||||
Help[purge]='
|
||||
USAGE:
|
||||
module purge
|
||||
@@ -1921,10 +1916,13 @@ subcommand_purge() {
|
||||
local -a args=()
|
||||
while (( $# > 0)); do
|
||||
case "$1" in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -1993,7 +1991,7 @@ subcommand_purge() {
|
||||
# list [-hlt]
|
||||
#
|
||||
Subcommands[list]='list'
|
||||
Options[list]='-l help -o Hhlt -l human -l long -l terse'
|
||||
Options[list]='-l help -o \?Hhlt -l human -l long -l terse'
|
||||
Help[list]='
|
||||
USAGE:
|
||||
module list
|
||||
@@ -2006,7 +2004,7 @@ subcommand_list() {
|
||||
local args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-h | --human )
|
||||
@@ -2019,6 +2017,9 @@ subcommand_list() {
|
||||
opts+=( '-t' )
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -2040,7 +2041,7 @@ subcommand_list() {
|
||||
# clear
|
||||
#
|
||||
Subcommands[clear]='clear'
|
||||
Options[clear]='-o H -l help'
|
||||
Options[clear]='-o \?H -l help'
|
||||
Help[clear]='
|
||||
USAGE:
|
||||
module clear
|
||||
@@ -2053,11 +2054,13 @@ subcommand_clear() {
|
||||
local -a args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
:
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -2079,13 +2082,14 @@ subcommand_clear() {
|
||||
# search [switches] [STRING...]
|
||||
#
|
||||
Subcommands[search]='search'
|
||||
Options[search]='-o aH -l help -l no-header -l print-modulefiles '
|
||||
Options[search]='-o a\?H -l help -l no-header -l print-modulefiles '
|
||||
Options[search]+='-l release-stage: -l with: -l all-release-stages -l src: -l print-csv '
|
||||
Options[search]+='-l verbose '
|
||||
Options[search]+='-l all-deps -l wrap'
|
||||
Options[search]+='-l all-deps -l wrap '
|
||||
Options[search]+='-l glob'
|
||||
Help[search]='
|
||||
USAGE:
|
||||
module search [switches] string...
|
||||
module search [switches] STRING...
|
||||
Search installed modules. If an argument is given, search
|
||||
for modules whose name match the argument.
|
||||
|
||||
@@ -2096,6 +2100,9 @@ SWITCHES:
|
||||
--all-deps
|
||||
Show all dependecies
|
||||
|
||||
--glob
|
||||
Interpret STRING as shell pattern.
|
||||
|
||||
--no-header
|
||||
Suppress output of a header.
|
||||
|
||||
@@ -2133,6 +2140,7 @@ subcommand_search() {
|
||||
local opt_use_releases=':'
|
||||
local opt_all_deps='no'
|
||||
local opt_wrap='no'
|
||||
local opt_glob='no'
|
||||
|
||||
#.....................................................................
|
||||
#
|
||||
@@ -2215,7 +2223,7 @@ subcommand_search() {
|
||||
print_modulefiles() {
|
||||
fmt=''
|
||||
func_print_header='print_header_none'
|
||||
func_print_line='print_header_none'
|
||||
func_print_line='print_line_modulefile'
|
||||
}
|
||||
|
||||
print_header_none() {
|
||||
@@ -2223,16 +2231,7 @@ subcommand_search() {
|
||||
}
|
||||
|
||||
print_line_modulefile() {
|
||||
local line=( "$@" )
|
||||
# group first
|
||||
local out="${line[2]}/"
|
||||
# add directory of modulefiles
|
||||
out+="${PMODULES_MODULEFILES_DIR}/"
|
||||
for d in "${line[@]:3}"; do
|
||||
out+="$d/"
|
||||
done
|
||||
out+="${line[0]}"
|
||||
std::info "${out}"
|
||||
std::info "$4"
|
||||
}
|
||||
|
||||
print_line_csv() {
|
||||
@@ -2280,7 +2279,12 @@ subcommand_search() {
|
||||
# :FIXME:
|
||||
#
|
||||
search () {
|
||||
local -r module=$1
|
||||
if [[ ${opt_glob} == 'yes' ]]; then
|
||||
local -r module="$1"
|
||||
else
|
||||
local -r module="${1}*"
|
||||
fi
|
||||
|
||||
# write results to a temporary file for later processing
|
||||
local group
|
||||
# loop over all groups
|
||||
@@ -2343,7 +2347,7 @@ subcommand_search() {
|
||||
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | --help )
|
||||
-\? | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
--all-deps )
|
||||
@@ -2393,13 +2397,29 @@ subcommand_search() {
|
||||
with_modules+=" && / ${module//\//\\/}/"
|
||||
done
|
||||
;;
|
||||
-a | --all-releases )
|
||||
-a | --all-releases-stages )
|
||||
opt_use_rel_stages+="${ReleaseStages}"
|
||||
;;
|
||||
--src )
|
||||
# :FIXME: do we have to add some sanity checks here?
|
||||
src_prefix=$2
|
||||
shift
|
||||
--src | --src=*)
|
||||
if [[ "$1" == --src ]]; then
|
||||
local src_prefix="$2"
|
||||
shift
|
||||
else
|
||||
local src_prefix="${1/--src=}"
|
||||
fi
|
||||
if [[ ! -e "${src_prefix}" ]]; then
|
||||
std::die 1 "%s %s: %s -- %s" \
|
||||
"${CMD}" 'search' \
|
||||
"illegal value for --src option" \
|
||||
"${src_prefix} does not exist"
|
||||
fi
|
||||
if [[ ! -d "${src_prefix}" ]]; then
|
||||
std::die 1 "%s %s: %s -- %s" \
|
||||
"${CMD}" 'search' \
|
||||
"illegal value for --src option" \
|
||||
"${src_prefix} is not a directory"
|
||||
fi
|
||||
src_prefix=$(std::get_abspath "${src_prefix}")
|
||||
;;
|
||||
-v | --verbose )
|
||||
opt_print_verbose='yes'
|
||||
@@ -2407,7 +2427,13 @@ subcommand_search() {
|
||||
--wrap )
|
||||
opt_wrap='yes'
|
||||
;;
|
||||
--glob )
|
||||
opt_glob='yes'
|
||||
;;
|
||||
-- )
|
||||
shift 1
|
||||
modules+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
modules+=( "$1" )
|
||||
@@ -2431,6 +2457,7 @@ subcommand_search() {
|
||||
if (( ${#GroupDepths[@]} == 0 )) || \
|
||||
[[ ${src_prefix} != ${PMODULES_ROOT} ]]; then
|
||||
scan_groups "${src_prefix}"
|
||||
g_env_must_be_saved='yes'
|
||||
fi
|
||||
|
||||
local module
|
||||
@@ -2452,6 +2479,7 @@ USAGE:
|
||||
SWITCHES:
|
||||
-h|-H|-?|--help this usage info
|
||||
-V|--version modules version & configuration options
|
||||
--debug enable debug output
|
||||
|
||||
SUBCOMMANDS:
|
||||
+ add|load [switches] modulefile [modulefile ...]
|
||||
@@ -2482,14 +2510,16 @@ subcommand_help() {
|
||||
local -a args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-[hH] | --help )
|
||||
-\? | -h | -H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-V | --version )
|
||||
print_help 'version'
|
||||
;;
|
||||
-- )
|
||||
:
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -2517,7 +2547,7 @@ subcommand_help() {
|
||||
# whatis
|
||||
#
|
||||
Subcommands[whatis]='whatis'
|
||||
Options[whatis]='-o H -l help'
|
||||
Options[whatis]='-o \?H -l help'
|
||||
Help[whatis]='
|
||||
USAGE:
|
||||
module whatis [modulefile...]
|
||||
@@ -2540,7 +2570,7 @@ subcommand_whatis() {
|
||||
#
|
||||
Subcommands[apropos]='apropos'
|
||||
Subcommands[keyword]='apropos'
|
||||
Options[apropos]='-o H -l help'
|
||||
Options[apropos]='-o \?H -l help'
|
||||
Help[apropos]='
|
||||
USAGE:
|
||||
module apropos string
|
||||
@@ -2558,7 +2588,7 @@ subcommand_apropos() {
|
||||
# initadd module...
|
||||
#
|
||||
Subcommands[initadd]='initadd'
|
||||
Options[initadd]='-o H -l help'
|
||||
Options[initadd]='-o \?H -l help'
|
||||
Help[initadd]="
|
||||
USAGE:
|
||||
module initadd modulefile...
|
||||
@@ -2594,7 +2624,7 @@ subcommand_initadd() {
|
||||
# initprepend module...
|
||||
#
|
||||
Subcommands[initprepend]='initprepend'
|
||||
Options[initprepend]='-o H -l help'
|
||||
Options[initprepend]='-o \?H -l help'
|
||||
Help[initprepend]="
|
||||
USAGE:
|
||||
module initprepend modulefile...
|
||||
@@ -2611,7 +2641,7 @@ subcommand_initprepend() {
|
||||
# initrm module...
|
||||
#
|
||||
Subcommands[initrm]='initrm'
|
||||
Options[initrm]='-o H -l help'
|
||||
Options[initrm]='-o \?H -l help'
|
||||
Help[initrm]="
|
||||
USAGE:
|
||||
module initrm modulefile...
|
||||
@@ -2627,7 +2657,7 @@ subcommand_initrm() {
|
||||
# initswitch module1 module2
|
||||
#
|
||||
Subcommands[initswitch]='initswitch'
|
||||
Options[initswitch]='-o H -l help'
|
||||
Options[initswitch]='-o \?H -l help'
|
||||
Help[initswitch]="
|
||||
USAGE:
|
||||
module initswitch modulefile1 modulefile2
|
||||
@@ -2640,11 +2670,13 @@ subcommand_initswitch() {
|
||||
local args=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-h | --help )
|
||||
-\? | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
-- )
|
||||
:
|
||||
shift 1
|
||||
args+=( "$@" )
|
||||
break
|
||||
;;
|
||||
* )
|
||||
args+=( "$1" )
|
||||
@@ -2665,7 +2697,7 @@ subcommand_initswitch() {
|
||||
# initlist
|
||||
#
|
||||
Subcommands[initlist]='initlist'
|
||||
Options[initlist]='-o H -l help'
|
||||
Options[initlist]='-o \?H -l help'
|
||||
Help[initlist]="
|
||||
USAGE:
|
||||
module initlist
|
||||
@@ -2682,7 +2714,7 @@ subcommand_initlist() {
|
||||
# initclear
|
||||
#
|
||||
Subcommands[initclear]='initclear'
|
||||
Options[initclear]='-o H -l help'
|
||||
Options[initclear]='-o \?H -l help'
|
||||
Help[initclear]="
|
||||
USAGE:
|
||||
module initclear
|
||||
@@ -2714,7 +2746,7 @@ shift
|
||||
declare -a opts=()
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-H | -\? | --help | -help )
|
||||
-\? | -H | --help | -help )
|
||||
print_help 'help'
|
||||
;;
|
||||
-V | --version )
|
||||
@@ -2723,7 +2755,7 @@ while (( $# > 0 )); do
|
||||
--debug )
|
||||
set -x
|
||||
;;
|
||||
'' | -- )
|
||||
'' )
|
||||
;;
|
||||
-* )
|
||||
opts+=( "$1" )
|
||||
@@ -2830,11 +2862,12 @@ case ${subcommand} in
|
||||
;;
|
||||
esac
|
||||
|
||||
declare options
|
||||
options=$( "${getopt}" ${Options[${subcommand}]} -- -- "${opts[@]}" "$@" ) \
|
||||
|
||||
tmp=$("${getopt}" --name="${CMD}" ${Options[${subcommand}]} -- "${opts[@]}" "$@" ) \
|
||||
|| print_help "${subcommand}"
|
||||
eval set -- ${options}
|
||||
subcommand_${Subcommands[$subcommand]} "$@"
|
||||
eval args=( "$tmp" )
|
||||
unset tmp
|
||||
subcommand_${Subcommands[$subcommand]} "${args[@]}"
|
||||
|
||||
# Local Variables:
|
||||
# mode: sh
|
||||
|
||||
@@ -487,6 +487,9 @@ pmodules::install() {
|
||||
sed "${sed_cmd}" "${SRC_DIR}/modulecmd.tcl.in" > "${PMODULES_HOME}/libexec/modulecmd.tcl"
|
||||
chmod 0755 "${PMODULES_HOME}/libexec/modulecmd.tcl"
|
||||
|
||||
sed "${sed_cmd}" "${SRC_DIR}/libpmodules.bash.in" > "${PMODULES_HOME}/lib/libpmodules.bash"
|
||||
chmod 0755 "${PMODULES_HOME}/lib/libpmodules.bash"
|
||||
|
||||
sed "${sed_cmd}" "${SRC_DIR}/modbuild.in" > "${PMODULES_HOME}/bin/modbuild"
|
||||
chmod 0755 "${PMODULES_HOME}/bin/modbuild"
|
||||
|
||||
@@ -503,7 +506,6 @@ pmodules::install() {
|
||||
install -m 0644 "${SRC_DIR}/csh" "${PMODULES_HOME}/init"
|
||||
install -m 0644 "${SRC_DIR}/zsh" "${PMODULES_HOME}/init"
|
||||
|
||||
install -m 0644 "${SRC_DIR}/libpmodules.bash" "${PMODULES_HOME}/lib"
|
||||
install -m 0644 "${SRC_DIR}/libpbuild.bash" "${PMODULES_HOME}/lib"
|
||||
install -m 0644 "${SRC_DIR}/libpbuild_dyn.bash" "${PMODULES_HOME}/lib"
|
||||
install -m 0644 "${SRC_DIR}/libstd.bash" "${PMODULES_HOME}/lib"
|
||||
|
||||
Reference in New Issue
Block a user