mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-06-29 10:49:41 +02:00
master merged
This commit is contained in:
@@ -35,8 +35,6 @@ unset MODULE_VERSION_STACK
|
||||
unset MODULESHOME
|
||||
unset PMODULES_ENV
|
||||
|
||||
PATH="${PMODULES_HOME}/bin:$PATH"
|
||||
|
||||
#############################################################################
|
||||
# implement module comand as shell function
|
||||
#
|
||||
|
||||
@@ -47,4 +47,3 @@ if (! $?LOADEDMODULES ) then
|
||||
setenv LOADEDMODULES ""
|
||||
endif
|
||||
|
||||
setenv PATH "${PMODULES_HOME}/bin:${PATH}"
|
||||
|
||||
+124
-149
@@ -183,9 +183,6 @@ pbuild.verbose() {
|
||||
verbose="$1"
|
||||
}
|
||||
|
||||
# module name including path in hierarchy and version
|
||||
# (ex: 'gcc/6.1.0/openmpi/1.10.2' for openmpi compiled with gcc 6.1.0)
|
||||
declare -x fully_qualified_module_name=''
|
||||
|
||||
# group this module is in (ex: 'Programming')
|
||||
declare -x GROUP=''
|
||||
@@ -245,76 +242,6 @@ pbuild::supported_os() {
|
||||
pbuild::supported_compilers() {
|
||||
SUPPORTED_COMPILERS+=( "$@" )
|
||||
}
|
||||
#......................................................................
|
||||
#
|
||||
# compute full module name and installation prefix
|
||||
#
|
||||
# The following variables are expected to be set:
|
||||
# GROUP module group
|
||||
# P module name
|
||||
# V module version
|
||||
# variables defining the hierarchical environment like
|
||||
# COMPILER and COMPILER_VERSION
|
||||
#
|
||||
# The following variables are set in this function
|
||||
# fully_qualified_module_name
|
||||
# PREFIX
|
||||
#
|
||||
set_full_module_name_and_prefix() {
|
||||
join_by() {
|
||||
local IFS="$1"
|
||||
shift
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
[[ -n ${GROUP} ]] || std::die 1 \
|
||||
"${module_name}/${module_version}:" \
|
||||
"group not set."
|
||||
|
||||
# build module name
|
||||
# :FIXME: this should be read from a configuration file
|
||||
local name=()
|
||||
case ${GROUP} in
|
||||
Compiler )
|
||||
name+=( "${COMPILER}/${COMPILER_VERSION}" )
|
||||
name+=( "${module_name}/${module_version}" )
|
||||
;;
|
||||
MPI )
|
||||
name+=( "${COMPILER}/${COMPILER_VERSION}" )
|
||||
name+=( "${MPI}/${MPI_VERSION}" )
|
||||
name+=( "${module_name}/${module_version}" )
|
||||
;;
|
||||
HDF5 )
|
||||
name+=( "${COMPILER}/${COMPILER_VERSION}" )
|
||||
name+=( "${MPI}/${MPI_VERSION}" )
|
||||
name+=( "${HDF5}/${HDF5_VERSION}" )
|
||||
name+=( "${module_name}/${module_version}" )
|
||||
;;
|
||||
OPAL )
|
||||
name+=( "${COMPILER}/${COMPILER_VERSION}" )
|
||||
name+=( "${MPI}/${MPI_VERSION}" )
|
||||
name+=( "${OPAL}/${OPAL_VERSION}" )
|
||||
name+=( "${module_name}/${module_version}" )
|
||||
;;
|
||||
HDF5_serial )
|
||||
name+=( "${COMPILER}/${COMPILER_VERSION}" )
|
||||
name+=( "hdf5_serial/${HDF5_SERIAL_VERSION}" )
|
||||
name+=( "${module_name}/${module_version}" )
|
||||
;;
|
||||
* )
|
||||
name+=("${module_name}/${module_version}" )
|
||||
;;
|
||||
esac
|
||||
|
||||
# set full module name
|
||||
fully_qualified_module_name=$( join_by '/' "${name[@]}" )
|
||||
# set PREFIX of module
|
||||
PREFIX="${overlay}/${GROUP}/"
|
||||
local -i i=0
|
||||
for ((i=${#name[@]}-1; i >= 0; i--)); do
|
||||
PREFIX+="/${name[i]}"
|
||||
done
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -330,7 +257,6 @@ pbuild::add_to_group() {
|
||||
"${FUNCNAME}: missing group argument."
|
||||
fi
|
||||
GROUP="$1"
|
||||
set_full_module_name_and_prefix
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
@@ -503,13 +429,13 @@ pbuild::prep() {
|
||||
unpack() {
|
||||
local -r file="$1"
|
||||
local -r dir="${2:-${SRC_DIR}}"
|
||||
(
|
||||
if [[ -n "${dir}" ]]; then
|
||||
mkdir -p "${dir}"
|
||||
cd "${dir}"
|
||||
fi
|
||||
tar -xv --strip-components 1 -f "${file}"
|
||||
)
|
||||
tar --directory="${dir}" -xv --strip-components 1 -f "${file}" || {
|
||||
rm -f "${file}"
|
||||
std::die 4 \
|
||||
"%s " \
|
||||
"${module_name}/${module_version}:" \
|
||||
"cannot unpack sources!"
|
||||
}
|
||||
}
|
||||
|
||||
patch_sources() {
|
||||
@@ -521,7 +447,11 @@ pbuild::prep() {
|
||||
"${module_name}/${module_version}:" \
|
||||
"Appling patch '${PATCH_FILES[_i]}' ..."
|
||||
local -i strip_val="${PATCH_STRIPS[_i]:-${PATCH_STRIP_DEFAULT}}"
|
||||
patch -p${strip_val} < "${BUILDBLOCK_DIR}/${PATCH_FILES[_i]}"
|
||||
patch -p${strip_val} < "${BUILDBLOCK_DIR}/${PATCH_FILES[_i]}" || \
|
||||
std::die 4 \
|
||||
"%s " \
|
||||
"${module_name}/${module_version}:" \
|
||||
"error patching sources!"
|
||||
done
|
||||
}
|
||||
if [[ -z "${SOURCE_URLS}" ]]; then
|
||||
@@ -656,7 +586,10 @@ pbuild::pre_compile() {
|
||||
}
|
||||
|
||||
pbuild::compile() {
|
||||
make -j${JOBS}
|
||||
make -j${JOBS} || \
|
||||
std::die 3 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"compilation failed!"
|
||||
}
|
||||
|
||||
pbuild::post_compile() {
|
||||
@@ -668,7 +601,10 @@ pbuild::pre_install() {
|
||||
}
|
||||
|
||||
pbuild::install() {
|
||||
make install
|
||||
make install || \
|
||||
std::die 3 \
|
||||
"%s " "${module_name}/${module_version}:" \
|
||||
"compilation failed!"
|
||||
}
|
||||
|
||||
pbuild::install_shared_libs() {
|
||||
@@ -722,6 +658,10 @@ pbuild::make_all() {
|
||||
|
||||
set -e
|
||||
local -r logfile="${BUILDBLOCK_DIR}/pbuild.log"
|
||||
# module name including path in hierarchy and version
|
||||
# (ex: 'gcc/6.1.0/openmpi/1.10.2' for openmpi compiled with gcc 6.1.0)
|
||||
local modulefile_dir=''
|
||||
local modulefile_name=''
|
||||
|
||||
#
|
||||
# To be able to set environment variables in one of the 'pbuild::TARGET'
|
||||
@@ -783,6 +723,75 @@ pbuild::make_all() {
|
||||
}
|
||||
|
||||
#......................................................................
|
||||
#
|
||||
# compute full module name and installation prefix
|
||||
#
|
||||
# The following variables are expected to be set:
|
||||
# GROUP module group
|
||||
# P module name
|
||||
# V module version
|
||||
# variables defining the hierarchical environment like
|
||||
# COMPILER and COMPILER_VERSION
|
||||
#
|
||||
# The following variables are set in this function
|
||||
# modulefile_dir
|
||||
# modulefile_name
|
||||
# PREFIX
|
||||
#
|
||||
set_full_module_name_and_prefix() {
|
||||
join_by() {
|
||||
local IFS="$1"
|
||||
shift
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
[[ -n ${GROUP} ]] || std::die 1 \
|
||||
"${module_name}/${module_version}:" \
|
||||
"group not set."
|
||||
|
||||
# define defaults if not set in configuration file
|
||||
: ${Compiler_HIERARCHY:='${COMPILER}/${COMPILER_VERSION}'}
|
||||
: ${CUDA_HIERARCHY:='${COMPILER}/${COMPILER_VERSION} cuda/${CUDA_VERSION}'}
|
||||
: ${MPI_HIERARCHY:='${COMPILER}/${COMPILER_VERSION} ${MPI}/${MPI_VERSION}'}
|
||||
: ${HDF5_HIERARCHY:='${COMPILER}/${COMPILER_VERSION} ${MPI}/${MPI_VERSION} hdf5/${HDF5_VERSION}'}
|
||||
: ${HDF5_SERIAL_HIERARCHY:='${COMPILER}/${COMPILER_VERSION} hdf5_serial/${HDF5_SERIAL_VERSION}'}
|
||||
|
||||
# evaluate
|
||||
local names=()
|
||||
local vname="${GROUP}_HIERARCHY"
|
||||
if [[ -n ${!vname} ]]; then
|
||||
names=( $(eval echo ${!vname}) )
|
||||
fi
|
||||
|
||||
modulefile_dir=$(join_by '/' \
|
||||
"${overlay}/${GROUP}/${PMODULES_MODULEFILES_DIR}" \
|
||||
"${names[@]}" \
|
||||
"${module_name}")
|
||||
modulefile_name="${modulefile_dir}/${module_version}"
|
||||
|
||||
PREFIX="${overlay}/${GROUP}/${module_name}/${module_version}"
|
||||
local -i i=0
|
||||
for ((i=${#names[@]}-1; i >= 0; i--)); do
|
||||
PREFIX+="/${names[i]}"
|
||||
done
|
||||
}
|
||||
|
||||
#......................................................................
|
||||
# Select the modulefile to install. Modulefiles can be versioned like
|
||||
# modulefile-10.2.0
|
||||
# modulefile-10.2
|
||||
# modulefile-10
|
||||
# modulefile
|
||||
# the most specific modulefile will be selected. Example:
|
||||
# For a version 10.2.1 the file moduelfile-10.2 would be selected.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 upvar to return the filename
|
||||
#
|
||||
# Used gloabal variables:
|
||||
# VERSIONS
|
||||
# BUILDBLOCK_DIR
|
||||
#
|
||||
find_modulefile() {
|
||||
local "$1"
|
||||
local fname=''
|
||||
@@ -798,11 +807,17 @@ pbuild::make_all() {
|
||||
}
|
||||
|
||||
#......................................................................
|
||||
# non-redefinable post-install
|
||||
# non-redefinable post-install. Install:
|
||||
# - documentation files as defined in the build-script
|
||||
# - modulefile and file with release
|
||||
# .
|
||||
post_install() {
|
||||
#..............................................................
|
||||
# install the doc-files specified in the build-script
|
||||
#
|
||||
# Arguments:
|
||||
# none
|
||||
#
|
||||
install_doc() {
|
||||
if [[ -z "${MODULE_DOCFILES}" ]]; then
|
||||
for f in ${VERSIONS[@]/#/pbuild::install_docfiles_}; do
|
||||
@@ -829,12 +844,14 @@ pbuild::make_all() {
|
||||
}
|
||||
|
||||
#..............................................................
|
||||
# install build-block files
|
||||
# install build-block files
|
||||
# - modulefile
|
||||
# - build-script
|
||||
# - build dependencies
|
||||
# - run-time and build dependencies
|
||||
# in ${PREFIX}/share/${GROUP}/${module_name}
|
||||
#
|
||||
# Skip installation if modulefile does not exist.
|
||||
# Arguments:
|
||||
# none
|
||||
#
|
||||
install_pmodules_files() {
|
||||
local modulefile=''
|
||||
@@ -924,9 +941,11 @@ pbuild::make_all() {
|
||||
}
|
||||
|
||||
#......................................................................
|
||||
# Install modulefile
|
||||
# Install modulefile in ${PMODULES_ROOT}/${GROUP}/modulefiles/...
|
||||
#
|
||||
# Arguments
|
||||
# none
|
||||
install_modulefile() {
|
||||
|
||||
local src=''
|
||||
find_modulefile src
|
||||
if (( $? != 0 )); then
|
||||
@@ -936,34 +955,16 @@ pbuild::make_all() {
|
||||
"skipping modulefile installation ..."
|
||||
return
|
||||
fi
|
||||
# assemble name of modulefile
|
||||
local dst="${overlay}/"
|
||||
dst+="${GROUP}/"
|
||||
dst+="${PMODULES_MODULEFILES_DIR}/"
|
||||
dst+="${fully_qualified_module_name}"
|
||||
|
||||
# directory where to install modulefile
|
||||
local -r dstdir=${dst%/*}
|
||||
|
||||
std::info \
|
||||
"%s " \
|
||||
"${module_name}/${module_version}:" \
|
||||
"installing modulefile in '${dstdir}' ..."
|
||||
mkdir -p "${dstdir}"
|
||||
install -m 0444 "${src}" "${dst}"
|
||||
"installing modulefile '${modulefile_name}' ..."
|
||||
mkdir -p "${modulefile_dir}"
|
||||
install -m 0444 "${src}" "${modulefile_name}"
|
||||
}
|
||||
|
||||
install_release_file() {
|
||||
local dst="${overlay}/"
|
||||
dst+="${GROUP}/"
|
||||
dst+="${PMODULES_MODULEFILES_DIR}/"
|
||||
dst+="${fully_qualified_module_name}"
|
||||
|
||||
# directory where to install release file
|
||||
local -r dstdir=${dst%/*}
|
||||
mkdir -p "${dstdir}"
|
||||
|
||||
local -r release_file="${dst%/*}/.release-${module_version}"
|
||||
install_release_file() {
|
||||
local -r release_file="${modulefile_dir}/.release-${module_version}"
|
||||
|
||||
if [[ -r "${release_file}" ]]; then
|
||||
local release
|
||||
@@ -1121,24 +1122,14 @@ pbuild::make_all() {
|
||||
"removing all files in '${PREFIX}' ..."
|
||||
[[ "${dry_run}" == 'no' ]] && rm -rf ${PREFIX}
|
||||
fi
|
||||
|
||||
# assemble name of modulefile
|
||||
local dst="${overlay}/"
|
||||
dst+="${GROUP}/"
|
||||
dst+="${PMODULES_MODULEFILES_DIR}/"
|
||||
dst+="${fully_qualified_module_name}"
|
||||
|
||||
# directory where to install modulefile
|
||||
local -r dstdir=${dst%/*}
|
||||
|
||||
if [[ -e "${dst}" ]]; then
|
||||
if [[ -e "${modulefile_name}" ]]; then
|
||||
std::info \
|
||||
"%s " \
|
||||
"${module_name}/${module_version}:" \
|
||||
"removing modulefile '${dst}' ..."
|
||||
[[ "${dry_run}" == 'no' ]] && rm -v "${dst}"
|
||||
"removing modulefile '${modulefile_name}' ..."
|
||||
[[ "${dry_run}" == 'no' ]] && rm -v "${modulefile_name}"
|
||||
fi
|
||||
local release_file="${dstdir}/.release-${module_version}"
|
||||
local release_file="${modulefile_dir}/.release-${module_version}"
|
||||
if [[ -e "${release_file}" ]]; then
|
||||
std::info \
|
||||
"%s " \
|
||||
@@ -1146,7 +1137,7 @@ pbuild::make_all() {
|
||||
"removing release file '${release_file}' ..."
|
||||
[[ "${dry_run}" == 'no' ]] && rm -v "${release_file}"
|
||||
fi
|
||||
rmdir -p "${dstdir}" 2>/dev/null || :
|
||||
rmdir -p "${modulefile_dir}" 2>/dev/null || :
|
||||
}
|
||||
|
||||
########################################################################
|
||||
@@ -1160,8 +1151,9 @@ pbuild::make_all() {
|
||||
check_supported_os
|
||||
check_supported_compilers
|
||||
set_full_module_name_and_prefix
|
||||
if module_exists "${module_name}/${module_version}" \
|
||||
&& [[ ${forece_rebuild} != 'yes' ]]; then
|
||||
if [[ -e "${modulefile_name}" ]] \
|
||||
&& [[ -d ${PREFIX} ]] \
|
||||
&& [[ ${force_rebuild} != 'yes' ]]; then
|
||||
if [[ "${module_release}" == 'removed' ]]; then
|
||||
remove_module
|
||||
else
|
||||
@@ -1210,13 +1202,13 @@ pbuild.init_env() {
|
||||
V_MINOR='' # second number in version string (or empty)
|
||||
V_PATCHLVL='' # third number in version string (or empty)
|
||||
V_RELEASE='' # module release (or empty)
|
||||
USE_FLAGS='' # architectures (or empty)
|
||||
: ${USE_FLAGS:=''} # architectures (or empty)
|
||||
|
||||
local tmp=''
|
||||
|
||||
if [[ "$v" =~ "_" ]]; then
|
||||
tmp="${v#*_}"
|
||||
USE_FLAGS=":${tmp//_/:}:"
|
||||
USE_FLAGS+=":${tmp//_/:}:"
|
||||
v="${v%%_*}"
|
||||
fi
|
||||
V_PKG="${v%%-*}" # version without the release number
|
||||
@@ -1278,18 +1270,6 @@ pbuild.init_env() {
|
||||
configure_with='undef'
|
||||
}
|
||||
|
||||
#..............................................................
|
||||
#
|
||||
# Test whether a module with the given name already exists.
|
||||
#
|
||||
# Arguments:
|
||||
# $1: module name/version
|
||||
#
|
||||
module_exists() {
|
||||
[[ -n $("${MODULECMD}" bash avail -m "$1" \
|
||||
2>&1 1>/dev/null) ]]
|
||||
}
|
||||
|
||||
pbuild.build_module() {
|
||||
module_name="$1"
|
||||
module_version="$2"
|
||||
@@ -1485,11 +1465,6 @@ pbuild.build_module() {
|
||||
|
||||
pbuild.init_env "${module_name}" "${module_version}"
|
||||
pbuild::make_all
|
||||
std::info \
|
||||
"%s " \
|
||||
"${module_name}/${module_version}:" \
|
||||
${with_modules:+with ${with_modules[@]}} \
|
||||
"done!"
|
||||
std::info "* * * * *\n"
|
||||
}
|
||||
|
||||
|
||||
@@ -205,72 +205,6 @@ std::upvar() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Assign variables one scope above the caller
|
||||
# Usage: local varname [varname ...] &&
|
||||
# upvars [-v varname value] | [-aN varname [value ...]] ...
|
||||
# Available OPTIONS:
|
||||
# -aN Assign next N values to varname as array
|
||||
# -v Assign single value to varname
|
||||
# Return: 1 if error occurs
|
||||
# Example:
|
||||
#
|
||||
# f() { local a b; g a b; declare -p a b; }
|
||||
# g() {
|
||||
# local c=( foo bar )
|
||||
# local "$1" "$2" && upvars -v $1 A -a${#c[@]} $2 "${c[@]}"
|
||||
# }
|
||||
# f # Ok: a=A, b=(foo bar)
|
||||
#
|
||||
std::upvars() {
|
||||
if ! (( $# )); then
|
||||
echo "${FUNCNAME[0]}: usage: ${FUNCNAME[0]} [-v varname"\
|
||||
"value] | [-aN varname [value ...]] ..." 1>&2
|
||||
return 2
|
||||
fi
|
||||
while (( $# )); do
|
||||
case $1 in
|
||||
-a*)
|
||||
# Error checking
|
||||
[[ ${1#-a} ]] || { echo "bash: ${FUNCNAME[0]}: \`$1': missing"\
|
||||
"number specifier" 1>&2; return 1; }
|
||||
printf %d "${1#-a}" &> /dev/null || { echo "bash:"\
|
||||
"${FUNCNAME[0]}: \`$1': invalid number specifier" 1>&2
|
||||
return 1; }
|
||||
# Assign array of -aN elements
|
||||
[[ "$2" ]] && unset -v "$2" && eval $2=\(\"\${@:3:${1#-a}}\"\) &&
|
||||
shift $((${1#-a} + 2)) || { echo "bash: ${FUNCNAME[0]}:"\
|
||||
"\`$1${2+ }$2': missing argument(s)" 1>&2; return 1; }
|
||||
;;
|
||||
-v)
|
||||
# Assign single value
|
||||
[[ "$2" ]] && unset -v "$2" && eval $2=\"\$3\" &&
|
||||
shift 3 || { echo "bash: ${FUNCNAME[0]}: $1: missing"\
|
||||
"argument(s)" 1>&2; return 1; }
|
||||
;;
|
||||
--help) echo "\
|
||||
Usage: local varname [varname ...] &&
|
||||
${FUNCNAME[0]} [-v varname value] | [-aN varname [value ...]] ...
|
||||
Available OPTIONS:
|
||||
-aN VARNAME [value ...] assign next N values to varname as array
|
||||
-v VARNAME value assign single value to varname
|
||||
--help display this help and exit
|
||||
--version output version information and exit"
|
||||
return 0 ;;
|
||||
--version) echo "\
|
||||
${FUNCNAME[0]}-0.9.dev
|
||||
Copyright (C) 2010 Freddy Vulto
|
||||
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law."
|
||||
return 0 ;;
|
||||
*)
|
||||
echo "bash: ${FUNCNAME[0]}: $1: invalid option" 1>&2
|
||||
return 1 ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
std.get_os_release_linux() {
|
||||
local lsb_release=$(which lsb_release)
|
||||
local ID=''
|
||||
|
||||
@@ -234,6 +234,13 @@ parse_args() {
|
||||
--system=* )
|
||||
opt_system="${1/*=}"
|
||||
;;
|
||||
--use-flags )
|
||||
USE_FLAGS="y:$2:"
|
||||
shift
|
||||
;;
|
||||
--use-flags=* )
|
||||
USE_FLAGS=":${1/--use-flags=}:"
|
||||
;;
|
||||
--with )
|
||||
opt_with_modules+=( "$2" )
|
||||
shift
|
||||
@@ -420,11 +427,6 @@ pbuild.update_modulefiles "${opt_update_modulefiles}"
|
||||
pbuild.system "${opt_system}"
|
||||
pbuild.verbose "${opt_verbose}"
|
||||
|
||||
source libpbuild_dyn.bash || \
|
||||
std::die 3 "Oops: cannot source library -- '$_'"
|
||||
|
||||
# source build configuration,
|
||||
# must be done before sourcing libpbuild!
|
||||
if [[ "${opt_bootstrap}" == 'yes' ]]; then
|
||||
test -d "${BUILDBLOCK_DIR}/../../config" && PATH+=":$_"
|
||||
else
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
unset BASH_ENV
|
||||
|
||||
bindir=$( cd $(dirname "$0")/../sbin && pwd -P )
|
||||
"${bindir}/bash" --noprofile --norc "${bindir}/../libexec/modmanage.bash" "$@"
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
unset BASH_ENV
|
||||
|
||||
"@BASH@" --noprofile --norc "@MODMANAGE@ "$@"
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
unset BASH_ENV
|
||||
|
||||
bindir=$( cd $(dirname "$0")/../sbin && pwd -P )
|
||||
"${bindir}/bash" --noprofile --norc "${bindir}/../libexec/modulecmd.bash" "$@"
|
||||
+232
-109
@@ -1,4 +1,4 @@
|
||||
#!@PMODULES_HOME@/sbin/bash --noprofile
|
||||
#!@BASH@ --noprofile
|
||||
#
|
||||
|
||||
#set -o nounset
|
||||
@@ -10,18 +10,29 @@ declare -r CMD='module'
|
||||
|
||||
declare -r mydir=$(cd $(dirname "$0") && pwd)
|
||||
declare prefix=$(dirname "${mydir}")
|
||||
declare -r sbindir="${prefix}/sbin"
|
||||
declare -r libdir="${prefix}/lib"
|
||||
declare -r libexecdir="${prefix}/libexec"
|
||||
|
||||
declare -r base64="${sbindir}/base64"
|
||||
declare -r mktemp="${sbindir}/mktemp"
|
||||
declare -r sort="${sbindir}/sort"
|
||||
declare -r getopt="${sbindir}/getopt"
|
||||
declare -r find="${sbindir}/find"
|
||||
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)
|
||||
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"
|
||||
|
||||
: ${PMODULES_DEFINED_RELEASES:=':unstable:stable:deprecated:'}
|
||||
|
||||
@@ -36,6 +47,10 @@ fi
|
||||
|
||||
declare verbosity_lvl=${PMODULES_VERBOSITY:-'verbose'}
|
||||
|
||||
# we use newline as internal field separator
|
||||
IFS=$' \t\n'
|
||||
declare -r __IFS=${IFS} # used to restore IFS
|
||||
|
||||
shopt -s nullglob
|
||||
|
||||
declare -A GroupDepths='()'
|
||||
@@ -281,6 +296,65 @@ USAGE:
|
||||
subcommand_load() {
|
||||
local -r subcommand='load'
|
||||
local current_modulefile=''
|
||||
local prefix=''
|
||||
local m=''
|
||||
|
||||
IFS=':'
|
||||
local -a modulepath=(${MODULEPATH})
|
||||
IFS=${__IFS}
|
||||
|
||||
#
|
||||
# Test whether a given module is available.
|
||||
# The passed module-name can be
|
||||
#
|
||||
# - an absolute file- or link-name.
|
||||
# The module can be either in- or outside our hierarchy.
|
||||
#
|
||||
# - a relative file- or link-name.
|
||||
# The module can be either in- or outside out hierarchy.
|
||||
#
|
||||
# - specified with name and version (like gcc/5.2.0).
|
||||
# The module can be either in- or outside our hierarchy.
|
||||
#
|
||||
# - specified with name only (without version, like gcc).
|
||||
# The module can be either in- or outside our hierarchy.
|
||||
#
|
||||
# - directory in- or outsite our hierarchy (not supported by
|
||||
# modulecmd.tcl!)
|
||||
#
|
||||
# arguments:
|
||||
# $1: module name or file
|
||||
#
|
||||
# possible return values:
|
||||
# 0: module is loadable
|
||||
# 1: either not a modulefile or unsused release
|
||||
#
|
||||
# The following variables in the enclosing function are set:
|
||||
# current_modulefile
|
||||
# prefix
|
||||
# release
|
||||
#
|
||||
is_available() {
|
||||
local m=$1
|
||||
local -a array
|
||||
#
|
||||
# the next command assigns the absolute modulefile path
|
||||
# to ${arry[0]} and - if the module is in our root - the
|
||||
# prefix of the module to ${array[1]}.
|
||||
#
|
||||
# The trick with the first line matching "_PREFIX" is not
|
||||
# 100% reliable: One of the Pmodules extensions must be
|
||||
# called before something like
|
||||
# setenv FOO_PREFIX bar
|
||||
# can be used.
|
||||
#
|
||||
mapfile -t array < <("${modulecmd}" 'bash' show "$m" 2>&1 | \
|
||||
${awk} 'NR == 2 {print substr($0, 1, length($0)-1)}; /_PREFIX |_HOME / {print $3; exit}')
|
||||
current_modulefile="${array[0]}"
|
||||
prefix="${array[1]}"
|
||||
test -n "${current_modulefile}" || return 1
|
||||
get_release release "${current_modulefile}" "${UsedReleases}"
|
||||
}
|
||||
|
||||
#
|
||||
# output load 'hints'
|
||||
@@ -418,27 +492,10 @@ subcommand_load() {
|
||||
# - release:name
|
||||
# - release:group:name
|
||||
# - name:release
|
||||
#
|
||||
# :FIXME: move to a function
|
||||
#
|
||||
# following variables are manipulated:
|
||||
#
|
||||
# m
|
||||
# the module to load (group and release are stripped)
|
||||
#
|
||||
# MODULEPATH, modulepath
|
||||
# if a group as been given, both variables are set
|
||||
# to the corresponding module-file directories of the
|
||||
# used overlays.
|
||||
#
|
||||
# UsedReleases
|
||||
# if a release as been given, UsedReleases is set to
|
||||
# this release.
|
||||
#
|
||||
local save_ifs=${IFS}
|
||||
|
||||
IFS=':'
|
||||
local -a toks=($m)
|
||||
IFS=${save_ifs}
|
||||
IFS=${__IFS}
|
||||
local group=''
|
||||
local release=''
|
||||
if is_group "${toks[0]}"; then
|
||||
@@ -622,7 +679,15 @@ subcommand_unload() {
|
||||
"${CMD}" "${subcommand}" \
|
||||
"missing argument"
|
||||
fi
|
||||
|
||||
|
||||
# The module() function uses PMODULES_HOME to call modulecmd.
|
||||
# If a Pmodules module is unloaded this evnvironment variable
|
||||
# will be unset. In consequence the module() function would
|
||||
# fail. Instead of comparing the name of the module to unload
|
||||
# with 'Pmodules', we save the value and set it at the end of
|
||||
# the loop again, if it has been unset.
|
||||
local saved_home="${PMODULES_HOME}"
|
||||
|
||||
local arg
|
||||
for arg in "${args[@]}"; do
|
||||
local output=$("${modulecmd}" "${Shell}" 'unload' "${arg}")
|
||||
@@ -636,6 +701,10 @@ subcommand_unload() {
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ -z ${PMODULES_HOME} ]]; then
|
||||
PMODULES_HOME=${saved_home}
|
||||
export_env 'PMODULES_HOME'
|
||||
fi
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
@@ -740,27 +809,21 @@ subcommand_show() {
|
||||
# Find all modules in a given modulepath matching a specific string.
|
||||
# The search can be restricted to certain releases.
|
||||
#
|
||||
# $1 modulepath (colon separated)
|
||||
# $2 string (module name or part of, might be empty)
|
||||
# $3 releases, defaults to used releases
|
||||
#
|
||||
# return list like
|
||||
# modulename1 release1 modulefile1 modulename2 release2 modulefile2 ...
|
||||
#
|
||||
get_available_modules() {
|
||||
local saved_IFS=${IFS};
|
||||
IFS=':'
|
||||
local -a dirs=($1)
|
||||
IFS=${saved_IFS}
|
||||
local var="$1"
|
||||
local -r module="$2"
|
||||
local -r releases="${3:-${UsedReleases}}"
|
||||
shift 3 # in the for loop below we use $@ to loop over the directories
|
||||
local -a mods=()
|
||||
local release
|
||||
|
||||
local -A dict
|
||||
local -A modulenames
|
||||
local dir
|
||||
for dir in "${dirs[@]}"; do
|
||||
for dir in "$@"; do
|
||||
test -d "${dir}" || continue
|
||||
{
|
||||
cd "${dir}"
|
||||
@@ -814,7 +877,7 @@ get_available_modules() {
|
||||
-ipath "${module}*")
|
||||
}
|
||||
done
|
||||
echo "${mods[@]}"
|
||||
std::upvar ${var} "${mods[@]}"
|
||||
}
|
||||
|
||||
#
|
||||
@@ -1075,10 +1138,9 @@ subcommand_avail() {
|
||||
pattern+=( '' )
|
||||
fi
|
||||
local -a modulepath
|
||||
local saved_IFS=${IFS}
|
||||
IFS=':'
|
||||
modulepath=(${MODULEPATH})
|
||||
IFS=${saved_IFS}
|
||||
IFS=${__IFS}
|
||||
|
||||
local overlay=''
|
||||
local group=''
|
||||
@@ -1097,10 +1159,12 @@ subcommand_avail() {
|
||||
local string
|
||||
for string in "${pattern[@]}"; do
|
||||
for group in "${groups[@]}"; do
|
||||
mods=( $( get_available_modules \
|
||||
"${modulepath_of_group[${group}]}" \
|
||||
"${string}" \
|
||||
"${opt_use_releases}" ) )
|
||||
get_available_modules \
|
||||
mods \
|
||||
"${string}" \
|
||||
"${opt_use_releases}" \
|
||||
"${modulepath_of_group[${group}]}"
|
||||
|
||||
[[ ${#mods[@]} == 0 ]] && continue
|
||||
|
||||
${output_function} "${group}"
|
||||
@@ -1121,7 +1185,7 @@ compute_group_depth () {
|
||||
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)
|
||||
-printf "%d" -quit 2>/dev/null)
|
||||
(( depth-=2 ))
|
||||
# if a group doesn't contain a modulefile, depth is negativ
|
||||
# :FIXME: better solution?
|
||||
@@ -1179,10 +1243,9 @@ SWITCHES:
|
||||
|
||||
subcommand_use() {
|
||||
local -r subcommand='use'
|
||||
local saved_IFS=${IFS};
|
||||
IFS=':'
|
||||
local -a modulepath=(${MODULEPATH})
|
||||
IFS=${saved_IFS}
|
||||
IFS=${__IFS}
|
||||
local add2path_func='std::append_path'
|
||||
|
||||
group_is_used() {
|
||||
@@ -1724,7 +1787,6 @@ pmodules_init() {
|
||||
reset_used_groups
|
||||
reset_modulepath
|
||||
reset_used_releases
|
||||
init_path
|
||||
init_manpath
|
||||
export_env \
|
||||
PMODULES_OVERLAYS \
|
||||
@@ -1768,8 +1830,15 @@ subcommand_purge() {
|
||||
"${CMD}" "${subcommand}" \
|
||||
"no arguments allowd"
|
||||
fi
|
||||
# we cannot unset PMODULES_HOME, otherwise the module function
|
||||
# would fail.
|
||||
local saved_home="${PMODULES_HOME}"
|
||||
"${modulecmd}" "${Shell}" "${subcommand}"
|
||||
export_env MODULEPATH
|
||||
reset_modulepath
|
||||
reset_used_groups
|
||||
PMODULES_HOME="${saved_home}"
|
||||
|
||||
export_env MODULEPATH PMODULES_HOME
|
||||
}
|
||||
|
||||
##############################################################################
|
||||
@@ -1865,7 +1934,8 @@ subcommand_clear() {
|
||||
Subcommands[search]='search'
|
||||
Options[search]='-o aH -l help -l no-header -l print-modulefiles '
|
||||
Options[search]+='-l release: -l with: -l all-releases -l src: -l print-csv '
|
||||
Options[search]+='-l verbose'
|
||||
Options[search]+='-l verbose '
|
||||
Options[search]+='-l all-deps -l wrap'
|
||||
Help[search]='
|
||||
USAGE:
|
||||
module search [switches] string...
|
||||
@@ -1873,6 +1943,12 @@ USAGE:
|
||||
for modules whose name match the argument.
|
||||
|
||||
SWITCHES:
|
||||
-a|--all-releases
|
||||
Search within all releases.
|
||||
|
||||
--all-deps
|
||||
Show all dependecies
|
||||
|
||||
--no-header
|
||||
Suppress output of a header.
|
||||
|
||||
@@ -1881,8 +1957,8 @@ SWITCHES:
|
||||
switch multiple times. Without this switch, the used releases
|
||||
will be searched.
|
||||
|
||||
-a|--all-releases
|
||||
Search within all releases.
|
||||
--verbose
|
||||
vebose output
|
||||
|
||||
--with=STRING
|
||||
Search for modules compiled with modules matching string. The
|
||||
@@ -1892,20 +1968,24 @@ SWITCHES:
|
||||
|
||||
lists all modules in the hierarchy compiled with gcc 4.8.3.
|
||||
|
||||
--verbose
|
||||
vebose output
|
||||
--wrap
|
||||
wrap output
|
||||
'
|
||||
|
||||
subcommand_search() {
|
||||
local -r subcommand='search'
|
||||
local modules=()
|
||||
local with_modules='//'
|
||||
local -ir cols=$(tput cols) # get number of columns of terminal
|
||||
local -i max_len_modulename=0
|
||||
local src_prefix=()
|
||||
local opt_print_header='yes'
|
||||
local opt_print_modulefiles='no'
|
||||
local opt_print_csv='no'
|
||||
local opt_print_verbose='no'
|
||||
local opt_use_releases=':'
|
||||
local opt_all_deps='no'
|
||||
local opt_wrap='no'
|
||||
|
||||
#.....................................................................
|
||||
#
|
||||
@@ -1923,21 +2003,8 @@ subcommand_search() {
|
||||
local func_print_line=''
|
||||
local fmt=''
|
||||
|
||||
# no args
|
||||
print_header_default() {
|
||||
std::info ''
|
||||
std::info "${fmt}" "Module" "Release" "Group" "Requires"
|
||||
std::info '-%.0s' {1..60}
|
||||
std::info ''
|
||||
}
|
||||
|
||||
print_line_default() {
|
||||
local deps="${@:5}"
|
||||
std::info "${fmt}" "$1" "$2" "$3" "${deps}"
|
||||
}
|
||||
|
||||
print_default() {
|
||||
fmt="%-20s %-10s %-12s %-s"
|
||||
fmt="%-${max_len_modulename}s %-10s %-12s %-s"
|
||||
if [[ ${opt_print_header} == 'yes' ]]; then
|
||||
func_print_header='print_header_default'
|
||||
else
|
||||
@@ -1946,23 +2013,64 @@ subcommand_search() {
|
||||
func_print_line='print_line_default'
|
||||
}
|
||||
|
||||
print_header_verbose() {
|
||||
std::info ''
|
||||
std::info "${fmt}" "Module" "Release" "Group" "Overlay" "Requires"
|
||||
std::info '-%.0s' {1..79}
|
||||
print_header_default() {
|
||||
std::info ''
|
||||
std::info "${fmt}" "Module" "Release" "Group" "Requires"
|
||||
std::info '-%.0s' $(seq 1 ${cols})
|
||||
}
|
||||
|
||||
print_line_verbose() {
|
||||
std::info "${fmt}" "$@"
|
||||
print_line_default() {
|
||||
write_line() {
|
||||
local str="$1"
|
||||
if (( ${#str} >= cols )); then
|
||||
str="${str:0:$((cols-1))}>"
|
||||
fi
|
||||
std::info "${str}"
|
||||
}
|
||||
if [[ "${opt_wrap}" == 'no' ]]; then
|
||||
local deps="${@:5}"
|
||||
local str=$(printf "${fmt}" "$1" "$2" "$3" "${deps[@]}")
|
||||
write_line "${str}"
|
||||
else
|
||||
local deps=( "${@:5}" )
|
||||
local str=$(printf "${fmt}" "$1" "$2" "$3" "${deps[0]}")
|
||||
for (( i = 1; i < ${#deps[@]}; i++ )); do
|
||||
if (( ${#str} + ${#deps[i]} + 1 <= cols )); then
|
||||
str+=" ${deps[i]}"
|
||||
else
|
||||
write_line "${str}"
|
||||
str=$(printf "${fmt}" "" "" "" "> ${deps[i]}")
|
||||
fi
|
||||
done
|
||||
write_line "${str}"
|
||||
fi
|
||||
}
|
||||
|
||||
print_verbose() {
|
||||
fmt="%-20s %-10s %-12s %-20s %-s"
|
||||
fmt="%-${max_len_modulename}s %-10s %-12s %-s"
|
||||
func_print_header='print_header_verbose'
|
||||
func_print_line='print_line_verbose'
|
||||
}
|
||||
|
||||
print_header_verbose() {
|
||||
std::info ''
|
||||
std::info "${fmt}" "Module" "Release" "Group" "Dependencies/Modulefile"
|
||||
std::info '-%.0s' $(seq 1 ${cols})
|
||||
}
|
||||
|
||||
print_line_verbose() {
|
||||
local deps="${@:5}"
|
||||
std::info "${fmt}" "$1" "$2" "$3" "dependencies: ${deps}"
|
||||
std::info "${fmt}" "" "" "" "modulefile: $4"
|
||||
}
|
||||
|
||||
# print full modulefile names only
|
||||
print_modulefiles() {
|
||||
fmt=''
|
||||
func_print_header='print_header_none'
|
||||
func_print_line='print_header_none'
|
||||
}
|
||||
|
||||
print_header_none() {
|
||||
:
|
||||
}
|
||||
@@ -1980,13 +2088,6 @@ subcommand_search() {
|
||||
std::info "${out}"
|
||||
}
|
||||
|
||||
# print full modulefile names only
|
||||
print_modulefiles() {
|
||||
fmt=''
|
||||
func_print_header='print_header_none'
|
||||
func_print_line='print_header_none'
|
||||
}
|
||||
|
||||
print_line_csv() {
|
||||
:
|
||||
}
|
||||
@@ -2013,14 +2114,14 @@ subcommand_search() {
|
||||
while read -a toks; do
|
||||
${func_print_line} "${toks[@]}"
|
||||
done < <("${sort}" -k 1,1 -k 4,4 -k 5,5 "${tmpfile}" | \
|
||||
awk "${with_modules}")
|
||||
${awk} "${with_modules}")
|
||||
}
|
||||
|
||||
get_module_prefix() {
|
||||
local "$1"
|
||||
local modulefile="$2"
|
||||
local -r _prefix=$("${modulecmd}" bash show "${modulefile}" 2>&1 | \
|
||||
awk '/_PREFIX |_HOME / {print $3; exit}')
|
||||
${awk} '/_PREFIX |_HOME / {print $3; exit}')
|
||||
std::upvar $1 "${_prefix}"
|
||||
}
|
||||
|
||||
@@ -2044,43 +2145,59 @@ subcommand_search() {
|
||||
# loop over all directories which can be added to
|
||||
# MODULEPATH inside current group
|
||||
local depth=${GroupDepths[${group}]}
|
||||
local mpaths=( $(${find} \
|
||||
"${src_prefix[@]/%//${group}/modulefiles}" \
|
||||
-type d \
|
||||
-mindepth ${depth} -maxdepth ${depth} \
|
||||
2>/dev/null))
|
||||
local modulepath=''
|
||||
for ((i=0; i<${#mpaths[@]}; i++)); do
|
||||
modulepath+=":${mpaths[i]}"
|
||||
done
|
||||
local requires=""
|
||||
|
||||
local s=''
|
||||
if (( depth > 0 )); then
|
||||
s=$(printf '/*%.0s' $(seq 1 ${depth}))
|
||||
fi
|
||||
local modulepath=( ${src_prefix[@]/%//${group}/modulefiles$s} )
|
||||
|
||||
# get and print all available modules in $mpath
|
||||
# with respect to the requested releases
|
||||
# tmpfile: module/version release group group-
|
||||
# dependencies...
|
||||
local mods=( $( get_available_modules \
|
||||
"${modulepath:1}" \
|
||||
"${module}" \
|
||||
"${opt_use_releases}" ) )
|
||||
local mods
|
||||
get_available_modules \
|
||||
mods \
|
||||
"${module}" \
|
||||
"${opt_use_releases}" \
|
||||
"${modulepath[@]}" \
|
||||
|
||||
for (( i=0; i<${#mods[@]}; i+=3 )); do
|
||||
local name=${mods[i]}
|
||||
local release=${mods[i+1]}
|
||||
local modulefile=${mods[i+2]}
|
||||
local prefix
|
||||
get_module_prefix prefix "${modulefile}"
|
||||
local dependencies_file="${prefix}/.dependencies"
|
||||
if [[ -n ${prefix} ]] && [[ -r "${dependencies_file}" ]]; then
|
||||
requires=$(< "${dependencies_file}")
|
||||
|
||||
if (( ${#name} > max_len_modulename)); then
|
||||
max_len_modulename=${#name}
|
||||
fi
|
||||
|
||||
echo ${mods[i]} ${mods[i+1]} \
|
||||
${group} ${mods[i+2]} \
|
||||
${requires} >> "${tmpfile}"
|
||||
if [[ "${opt_print_verbose}" == 'yes' ]] || [[ "${opt_all_deps}" == 'yes' ]]; then
|
||||
local prefix=''
|
||||
get_module_prefix prefix "${modulefile}"
|
||||
local dependencies_file="${prefix}/.dependencies"
|
||||
if [[ -n ${prefix} ]] && [[ -r "${dependencies_file}" ]]; then
|
||||
deps=($(< "${dependencies_file}"))
|
||||
else
|
||||
deps=()
|
||||
fi
|
||||
else
|
||||
# get dependencies encoded in directory name
|
||||
local deps=()
|
||||
local -i j
|
||||
IFS='/'
|
||||
local toks=( ${modulefile} )
|
||||
for ((j = -depth-2; j < -2; j += 2)); do
|
||||
deps+=( "${toks[*]: $j:2}" );
|
||||
done
|
||||
IFS=${__IFS}
|
||||
fi
|
||||
|
||||
echo ${name} ${release} ${group} ${modulefile} \
|
||||
${deps[@]} >> "${tmpfile}"
|
||||
done
|
||||
done
|
||||
print_result "${tmpfile}"
|
||||
#rm -f "${tmpfile}"
|
||||
${rm} -f "${tmpfile}"
|
||||
}
|
||||
|
||||
while (( $# > 0 )); do
|
||||
@@ -2088,6 +2205,9 @@ subcommand_search() {
|
||||
-H | --help )
|
||||
print_help "${subcommand}"
|
||||
;;
|
||||
--all-deps )
|
||||
opt_all_deps='yes'
|
||||
;;
|
||||
--no-header )
|
||||
opt_print_header='no'
|
||||
;;
|
||||
@@ -2136,13 +2256,16 @@ subcommand_search() {
|
||||
opt_use_releases="${PMODULES_DEFINED_RELEASES}"
|
||||
;;
|
||||
--src )
|
||||
# :FIXME: do we have to add some sanity checks here?
|
||||
src_prefix=$2
|
||||
pmodules::check_directories "${src_prefix}"
|
||||
shift
|
||||
;;
|
||||
-v | --verbose )
|
||||
opt_print_verbose='yes'
|
||||
;;
|
||||
--wrap )
|
||||
opt_wrap='yes'
|
||||
;;
|
||||
-- )
|
||||
;;
|
||||
* )
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
unset BASH_ENV
|
||||
|
||||
"@BASH@" --noprofile --norc "@MODULECMD@" "$@"
|
||||
@@ -0,0 +1,10 @@
|
||||
#%Module1.0
|
||||
|
||||
module-whatis "Pmodules environment"
|
||||
module-url "https://gitlab.psi.ch/Pmodules/src"
|
||||
module-license "GNU GPL v2"
|
||||
module-maintainer "Achim Gsell <achim.gsell@psi.ch>"
|
||||
|
||||
module-help "
|
||||
Pmodules are a hierarchical module environment based on Environment Modules.
|
||||
"
|
||||
@@ -89,10 +89,6 @@ unset PMODULES_DEFAULT_RELEASES
|
||||
unset PMODULES_DEFAULT_GROUPS
|
||||
unset PMODULES_DEFINED_RELEASES
|
||||
|
||||
# setup PATH
|
||||
dirs_to_remove="${PMODULES_HOME%/*}/*"
|
||||
path=( ${(m)path:#${dirs_to_remove}} "${PMODULES_HOME}/bin" )
|
||||
|
||||
# initialize MANPATH with output of `man --path` if not set
|
||||
[[ -z "${MANPATH}" ]] && manpath=$( man --path )
|
||||
|
||||
|
||||
+2
-2
@@ -14,12 +14,12 @@ pbuild::configure() {
|
||||
esac
|
||||
"${srcdir}"/configure \
|
||||
--prefix="${PREFIX}" \
|
||||
--bindir="${PREFIX}/sbin" \
|
||||
--bindir="${PREFIX}/${UTILBIN_DIR}" \
|
||||
--enable-shared=no \
|
||||
|| exit 1
|
||||
}
|
||||
|
||||
pbuild::post_install() {
|
||||
{ cd "${PREFIX}"/sbin && rm -f tclsh && ln -fs tclsh${V%.*} tclsh; };
|
||||
{ cd "${PREFIX}/${UTILBIN_DIR}" && rm -f tclsh && ln -fs tclsh${V%.*} tclsh; };
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env modbuild
|
||||
|
||||
pbuild::set_download_url "https://ftp.gnu.org/gnu/$P/$P-$V.tar.gz"
|
||||
pbuild::add_configure_args "--bindir=${PREFIX}/sbin"
|
||||
pbuild::add_configure_args "--bindir=${PREFIX}/${UTILBIN_DIR}"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env modbuild
|
||||
|
||||
pbuild::set_download_url "http://ftp.gnu.org/gnu/coreutils/$P-$V.tar.xz"
|
||||
pbuild::add_configure_args "--bindir=${PREFIX}/sbin"
|
||||
pbuild::add_configure_args "--bindir=${PREFIX}/${UTILBIN_DIR}"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env modbuild
|
||||
|
||||
pbuild::set_download_url "https://ftp.gnu.org/pub/gnu/$P/$P-$V.tar.xz"
|
||||
pbuild::add_configure_args "--bindir=${PREFIX}/sbin"
|
||||
pbuild::add_configure_args "--bindir=${PREFIX}/${UTILBIN_DIR}"
|
||||
|
||||
+15
-7
@@ -17,22 +17,30 @@ pbuild::compile() {
|
||||
declare -x LIBRARY_PATH="${PREFIX}/lib"
|
||||
case ${OS} in
|
||||
Linux )
|
||||
declare -x C_INCLUDE_PATH="${PREFIX}/include"
|
||||
declare -x LIBRARY_PATH="${PREFIX}/lib"
|
||||
declare -x LDFLAGS="-lintl -L${PREFIX}/lib"
|
||||
;;
|
||||
Darwin )
|
||||
declare -x LDFLAGS="-lintl -liconv -framework CoreFoundation"
|
||||
if [[ ! -d '/opt/local/bin' ]] || [[ ! -x '/opt/local/bin/msgfmt' ]]; then
|
||||
std::die 1 "gettext port from Macports is required to build 'getopt'!"
|
||||
fi
|
||||
PATH+=':/opt/local/bin'
|
||||
declare -x C_INCLUDE_PATH='/opt/local/include'
|
||||
declare -x LDFLAGS="/opt/local/lib/libintl.a /opt/local/lib/libiconv.a -framework CoreFoundation"
|
||||
;;
|
||||
esac
|
||||
|
||||
make -e all
|
||||
make -e all || exit 1
|
||||
declare -x DESTDIR="${PREFIX}"
|
||||
declare -x prefix='' || exit 1
|
||||
PATH="${PREFIX}/${UTILBIN_DIR}:${PATH}"
|
||||
make -e install
|
||||
mv "${PREFIX}/bin/getopt" "${PREFIX}/${UTILBIN_DIR}"
|
||||
}
|
||||
|
||||
pbuild::install() {
|
||||
declare -x DESTDIR="${PREFIX}"
|
||||
declare -x prefix=''
|
||||
make -e install
|
||||
mkdir -p "${PREFIX}/sbin"
|
||||
mv "${PREFIX}/bin/getopt" "${PREFIX}/sbin"
|
||||
:
|
||||
}
|
||||
|
||||
pbuild::cleanup_build() {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
pbuild::set_download_url "https://ftp.gnu.org/pub/gnu/$P/$P-$V.tar.gz"
|
||||
|
||||
pbuild::add_configure_args "--prefix=${PREFIX}"
|
||||
pbuild::add_configure_args "--bindir=${PREFIX}/sbin"
|
||||
pbuild::add_configure_args "--bindir=${PREFIX}/${UTILBIN_DIR}"
|
||||
pbuild::add_configure_args "--disable-java"
|
||||
pbuild::add_configure_args "--disable-threads"
|
||||
pbuild::add_configure_args "--disable-shared"
|
||||
|
||||
+13
-12
@@ -29,18 +29,19 @@ pbuild::configure() {
|
||||
}
|
||||
|
||||
pbuild::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
|
||||
cp -v "${BUILD_DIR}/modulecmd" "${PREFIX}/libexec/modulecmd.bin" || exit 1
|
||||
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"
|
||||
rm -f "${PREIX}/init/{ksh,perl.pm,python.py,ruby.rb,cmake,.modulespath}"
|
||||
cp -v "${BUILD_DIR}/modulecmd" "${PREFIX}/libexec/modulecmd.bin" || exit 1
|
||||
}
|
||||
|
||||
# fake module command
|
||||
|
||||
@@ -5,6 +5,8 @@ if [ "${BASH_VERSINFO[0]}" -lt 4 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
declare -r OS=$(uname -s)
|
||||
|
||||
declare BOOTSTRAP_DIR=$(dirname "$0")
|
||||
source "${BOOTSTRAP_DIR}/Pmodules/libstd.bash" || { echo "Oops!" 1>&2; exit 42; }
|
||||
|
||||
@@ -25,6 +27,9 @@ declare -rx DEFAULT_DISTFILES_DIR="var/distfiles"
|
||||
declare -rx DEFAULT_VERSIONS_CONFIG="${CONFIG_DIR}/versions.conf"
|
||||
declare -rx DEFAULT_TMPDIR='var/tmp/${USER}'
|
||||
|
||||
# directory where the required tools will be installed (like bash, tclsh, etc)
|
||||
declare -rx UTILBIN_DIR='libexec'
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
#
|
||||
get_version() {
|
||||
@@ -224,11 +229,9 @@ Use the option --force to override.\nAborting..."
|
||||
|
||||
read_config_file 'config_file'
|
||||
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 -d -m 0755 "${PMODULES_HOME}/libexec"
|
||||
install -d -m 0755 "${PMODULES_HOME}/sbin"
|
||||
echo "Configuration:"
|
||||
echo " root of Pmodules environment: ${prefix}"
|
||||
echo " Pmodule prefix: ${PMODULES_HOME}"
|
||||
@@ -326,24 +329,30 @@ pmodules::compile() {
|
||||
|
||||
local config_file="${prefix}/${CONFIG_DIR}/${CONFIG_FILE}"
|
||||
read_config_file config_file
|
||||
install -d -m 0755 "${PMODULES_HOME}/bin"
|
||||
install -d -m 0755 "${PMODULES_HOME}/init"
|
||||
install -d -m 0755 "${PMODULES_HOME}/lib"
|
||||
install -d -m 0755 "${PMODULES_HOME}/libexec"
|
||||
|
||||
echo "Configuration:"
|
||||
echo " root of Pmodules environment: ${prefix}"
|
||||
echo " Pmodule prefix: ${PMODULES_HOME}"
|
||||
|
||||
if [[ ! -f "${PMODULES_HOME}/sbin/base64" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
build coreutils
|
||||
#if [[ ! -f "${PMODULES_HOME}/${UTILBIN_DIR}/base64" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
# build coreutils
|
||||
#fi
|
||||
|
||||
if [[ "${OS}" == 'Darwin' ]]; then
|
||||
if [[ ! -f "${PMODULES_HOME}/${UTILBIN_DIR}/getopt" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
build getopt
|
||||
fi
|
||||
|
||||
if [[ ! -f "${PMODULES_HOME}/${UTILBIN_DIR}/find" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
build findutils
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -f "${PMODULES_HOME}/sbin/xgettext" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
build gettext
|
||||
fi
|
||||
|
||||
if [[ ! -f "${PMODULES_HOME}/sbin/getopt" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
build getopt
|
||||
fi
|
||||
|
||||
if [[ ! -f "${PMODULES_HOME}/sbin/bash" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
if [[ ! -f "${PMODULES_HOME}/${UTILBIN_DIR}/bash" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
build bash
|
||||
fi
|
||||
|
||||
@@ -358,6 +367,14 @@ pmodules::compile() {
|
||||
if [[ ! -e "${PMODULES_HOME}/libexec/modulecmd.bin" ]] || [[ ${opt_force} == 'yes' ]]; then
|
||||
build modules
|
||||
fi
|
||||
rm -rf "${PMODULES_HOME}/include"
|
||||
rm -rf "${PMODULES_HOME}/lib/"*.a
|
||||
rm -rf "${PMODULES_HOME}/lib/"*.la
|
||||
rm -rf "${PMODULES_HOME}/lib/bash"
|
||||
rm -rf "${PMODULES_HOME}/lib/pkginfo"
|
||||
rm -rf "${PMODULES_HOME}/man"
|
||||
rm -rf "${PMODULES_HOME}/share"
|
||||
|
||||
echo "Done..."
|
||||
}
|
||||
|
||||
@@ -441,7 +458,7 @@ pmodules::install() {
|
||||
sed_cmd+="s:@MODULES_VERSION@:${MODULES_VERSION}:g;"
|
||||
sed_cmd+="s:@PMODULES_DISTFILESDIR@:${PMODULES_DISTFILESDIR}:g;"
|
||||
sed_cmd+="s:@PMODULES_TMPDIR@:${PMODULES_TMPDIR}:g;"
|
||||
sed_cmd+="s:@TCLSHDIR@:${PMODULES_HOME}/sbin:g;"
|
||||
sed_cmd+="s:@TCLSHDIR@:${PMODULES_HOME}/${UTILBIN_DIR}:g;"
|
||||
sed_cmd+="s:@pager@::g;"
|
||||
sed_cmd+="s:@pageropts@::g;"
|
||||
sed_cmd+="s:@etcdir@:${PMODULES_ROOT}/${CONFIG_DIR}:g;"
|
||||
@@ -449,6 +466,9 @@ pmodules::install() {
|
||||
sed_cmd+="s:@prefix@:${PMODULES_HOME}:g;"
|
||||
sed_cmd+="s:@initdir@:${PMODULES_HOME}/init:g;"
|
||||
sed_cmd+="s:@MODULES_RELEASE@:${PMODULES_VERSION}:g;"
|
||||
sed_cmd+="s:@BASH@:${PMODULES_HOME}/${UTILBIN_DIR}/bash:g;"
|
||||
sed_cmd+="s:@MODULECMD@:${PMODULES_HOME}/${UTILBIN_DIR}/modulecmd.bash:g;"
|
||||
sed_cmd+="s:@MODMANAGE@:${PMODULES_HOME}/${UTILBIN_DIR}/modmanage.bash:g;"
|
||||
|
||||
sed "${sed_cmd}" "${SRC_DIR}/profile.bash.in" > "${PMODULES_ROOT}/${CONFIG_DIR}/profile.bash-${PMODULES_VERSION}"
|
||||
sed "${sed_cmd}" "${SRC_DIR}/profile.csh.in" > "${PMODULES_ROOT}/${CONFIG_DIR}/profile.csh-${PMODULES_VERSION}"
|
||||
@@ -464,18 +484,21 @@ pmodules::install() {
|
||||
test -e "${PMODULES_ROOT}/${CONFIG_DIR}/profile.zsh" || \
|
||||
install -m 0644 "$_-${PMODULES_VERSION}" "$_"
|
||||
|
||||
sed "${sed_cmd}" "${SRC_DIR}/modulecmd.in" > "${PMODULES_HOME}/bin/modulecmd"
|
||||
chmod 0755 "${PMODULES_HOME}/bin/modulecmd"
|
||||
sed "${sed_cmd}" "${SRC_DIR}/modulecmd.bash.in" > "${PMODULES_HOME}/libexec/modulecmd.bash"
|
||||
chmod 0755 "${PMODULES_HOME}/libexec/modulecmd.bash"
|
||||
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}/modbuild.in" > "${PMODULES_HOME}/bin/modbuild"
|
||||
chmod 0755 "${PMODULES_HOME}/bin/modbuild"
|
||||
|
||||
sed "${sed_cmd}" "${SRC_DIR}/modmanage.in" > "${PMODULES_HOME}/bin/modmanage"
|
||||
chmod 0755 "${PMODULES_HOME}/bin/modmanage"
|
||||
sed "${sed_cmd}" "${SRC_DIR}/modmanage.bash.in" > "${PMODULES_HOME}/libexec/modmanage.bash"
|
||||
chmod 0755 "${PMODULES_HOME}/libexec/modmanage.bash"
|
||||
|
||||
install -m 0755 "${SRC_DIR}/modulecmd" "${PMODULES_HOME}/bin"
|
||||
install -m 0755 "${SRC_DIR}/modmanage" "${PMODULES_HOME}/bin"
|
||||
|
||||
install -m 0644 "${SRC_DIR}/bash" "${PMODULES_HOME}/init"
|
||||
install -m 0644 "${SRC_DIR}/bash_completion" "${PMODULES_HOME}/init"
|
||||
install -m 0644 "${SRC_DIR}/csh" "${PMODULES_HOME}/init"
|
||||
@@ -489,12 +512,13 @@ pmodules::install() {
|
||||
install -m 0644 "${SRC_DIR}/libmodules.tcl" "${PMODULES_HOME}/lib/Pmodules"
|
||||
|
||||
{
|
||||
PATH="${PMODULES_HOME}/sbin:${PATH}"
|
||||
PATH="${PMODULES_HOME}/${UTILBIN_DIR}:${PATH}"
|
||||
cd "${PMODULES_HOME}/lib/Pmodules"
|
||||
"${BOOTSTRAP_DIR}/mkindex.tcl"
|
||||
}
|
||||
|
||||
mkdir -p "${PMODULES_ROOT}/Tools/modulefiles"
|
||||
install -m 0755 -d "${PMODULES_ROOT}/Tools/modulefiles/Pmodules"
|
||||
install -m 0644 "${SRC_DIR}/modulefile" "${PMODULES_ROOT}/Tools/modulefiles/Pmodules/${PMODULES_VERSION}"
|
||||
mkdir -p "${PMODULES_ROOT}/Libraries/modulefiles"
|
||||
mkdir -p "${PMODULES_ROOT}/Programming/modulefiles"
|
||||
test -e "${PMODULES_DISTFILESDIR}" || mkdir -p "$_"
|
||||
|
||||
Reference in New Issue
Block a user