changes from master merged

This commit is contained in:
2020-04-02 18:08:41 +02:00
11 changed files with 808 additions and 568 deletions
+1
View File
@@ -10,4 +10,5 @@ profile.zsh
Downloads
tmp
tclIndex
pbuild.log
*~
+20
View File
@@ -0,0 +1,20 @@
Changes in version 1.0.0rc5 (since 1.0.0rc2)
- build-system
* lot of cleanup, refactoring and bugfixes
* '.*' is now a valid version argument
* 'system' isn't a synonym for OS/kernel any more. It defines a target operating system like RHEL6, macOS1014.
* checks for supported system, OS and compiler
* compute default for the number of parallel make jobs
* calling pbuild::make_all in a build-script is now deprecate
- modulecmd
* --with option of sub-command search now accepts a comma separated list of strings
* better load hints
* log modules loaded to syslog
* PMODULES_ENV is exported only on content changes
* bugfixes and cleanup
1.0.0rc4
- never tagged
1.0.0rc3
- never tagged
+2
View File
@@ -46,3 +46,5 @@ end
if (! $?LOADEDMODULES ) then
setenv LOADEDMODULES ""
endif
setenv PATH "${PMODULES_HOME}/bin:${PATH}"
+557 -497
View File
File diff suppressed because it is too large Load Diff
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
eval "pbuild::pre_prep_${system}() { :; }"
eval "pbuild::pre_prep_${OS}() { :; }"
eval "pbuild::post_prep_${system}() { :; }"
eval "pbuild::post_prep_${OS}() { :; }"
eval "pbuild::add_patch_${system}() { pbuild::add_patch \"\$@\"; }"
eval "pbuild::add_patch_${OD}() { pbuild::add_patch \"\$@\"; }"
eval "pbuild::pre_configure_${system}() { :; }"
eval "pbuild::pre_configure_${OS}() { :; }"
eval "pbuild::post_configure_${system}() { :; }"
eval "pbuild::post_configure_${OS}() { :; }"
eval "pbuild::pre_compile_${system}() { :; }"
eval "pbuild::pre_compile_${OS}() { :; }"
eval "pbuild::post_compile_${system}() { :; }"
eval "pbuild::post_compile_${OS}() { :; }"
eval "pbuild::pre_install_${system}() { :; }"
eval "pbuild::pre_install_${OS}() { :; }"
eval "pbuild::post_install_${system}() { :; }"
eval "pbuild::post_install_${OS}() { :; }"
+36
View File
@@ -271,6 +271,42 @@ There is NO WARRANTY, to the extent permitted by law."
done
}
std.get_os_release_linux() {
local lsb_release=$(which lsb_release)
local ID=''
local VERSION_ID=''
if [[ -n $(which lsb_release) ]]; then
ID=$(lsb_release -is)
VERSION_ID=$(lsb_release -rs)
elif [[ -r '/etc/os-release' ]]; then
source /etc/os-release
else
std::die 4 "Cannot determin OS release!\n"
fi
case "${ID}" in
RedHatEnterpriseServer | RedHatEnterprise | Scientific | rhel | centos | fedora )
echo "rhel${VERSION_ID%.*}"
;;
* )
echo "Unknown"
exit 1
;;
esac
}
std.get_os_release_macos() {
VERSION_ID=$(sw_vers -productVersion)
echo "macOS${VERSION_ID%.*}"
}
std::get_os_release() {
local -A func_map;
func_map['Linux']=std.get_os_release_linux
func_map['Darwin']=std.get_os_release_macos
${func_map[${OS}]}
}
# Local Variables:
# mode: sh
# sh-basic-offset: 8
+96 -43
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash --
#!/usr/bin/env bash
#
# The following build specific variables are set and used in libpbuild.bash:
# ARGS
@@ -16,16 +16,26 @@ declare -r mydir=$(cd ${mydir} && pwd -P)
# initialize PATH,
# add library installation directories to the PATH,
# so 'source' is able find them
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
if [[ $(uname -s) == 'Darwin' ]]; then
PATH='/usr/local/bin:'
else
PATH=''
fi
PATH+='/usr/bin:/bin:/usr/sbin:/sbin'
PATH+=":${mydir}"
PATH+=":${mydir}/../lib:${mydir}/../config"
source libstd.bash || {
echo "Oops: library '$_' cannot be loaded!" 1>&2; exit 3;
echo "Oops: cannot source library -- '$_'" 1>&2; exit 3;
}
# can be set in the configuration file
declare PMODULES_DISTFILESDIR=''
declare PMODULES_TMPDIR=''
source libpbuild.bash || \
std::die 3 "Oops: Cannot source library -- '$_'"
std::die 3 "Oops: cannot source library -- '$_'"
# save arguments, (still) required for building dependencies
declare -r ARGS="$@"
@@ -124,36 +134,48 @@ MISCELLANEOUS OPTIONS:
#
# parse options and arguments
#
# command line arguments are taken first
# then configuration file
# last default
# multiple version can be passed via comand line
# versions to be build, '.*' or none means all
declare -a versions=()
declare opt_all_variants='no'
declare opt_bootstrap='no'
declare opt_build_config='modbuild.conf'
declare opt_build_target='all'
declare opt_dry_run='no'
declare opt_enable_cleanup_build='yes'
declare opt_enable_cleanup_src='yes'
declare opt_force_rebuild='no'
declare -i opt_jobs=0
declare opt_update_modulefiles='no'
declare opt_system=''
declare opt_verbose='no'
# array collecting all modules specified on the command line via '--with=module'
declare -a opt_with_modules=()
declare overlay=''
declare build_config='modbuild.conf'
declare system="$(uname -s)"
parse_args() {
while (( $# > 0 )); do
case $1 in
-j )
pbuild.jobs "$2"
opt_jobs="$2"
shift
;;
--jobs=[0-9]* )
pbuild.jobs "${1/--jobs=}"
opt_jobs="${1/--jobs=}"
;;
-v | --verbose )
trap 'echo "$BASH_COMMAND"' DEBUG
pbuild.verbose 'yes'
opt_verbose='yes'
;;
--debug )
set -x
;;
-f | --force-rebuild )
pbuild.force_rebuild 'yes'
opt_force_rebuild='yes'
;;
-\? | -h | --help )
usage
@@ -162,57 +184,55 @@ parse_args() {
std::die 0 "\nPmodules version ${VERSION}\nCopyright GNU GPL v2\n"
;;
--dry-run )
pbuild.dry_run 'yes'
opt_dry_run='yes'
;;
--config )
build_config="$2"
opt_build_config="$2"
shift 1
;;
--config=* )
build_config="${1#*=}"
opt_build_config="${1#*=}"
;;
--enable-cleanup )
pbuild.enable_cleanup_build 'yes'
pbuild.enable_cleanup_src 'yes'
opt_enable_cleanup_build='yes'
opt_enable_cleanup_src='yes'
;;
--disable-cleanup )
pbuild.enable_cleanup_build 'no'
pbuild.enable_cleanup_src 'no'
opt_enable_cleanup_build='no'
opt_enable_cleanup_src='no'
;;
--enable-cleanup-build )
pbuild.enable_cleanup_build 'yes'
opt_enable_cleanup_build='yes'
;;
--disable-cleanup-build )
pbuild.enable_cleanup_build 'no'
opt_enable_cleanup_build='no'
;;
--enable-cleanup-src )
pbuild.enable_cleanup_src 'yes'
opt_enable_cleanup_src='yes'
;;
--disable-cleanup-src )
pbuild.enable_cleanup_src 'no'
opt_enable_cleanup_src='no'
;;
--distdir )
pbuild.pmodules_distfilesdir "$2"
PMODULES_DISTFILESDIR="$2"
shift
;;
--distdir=* )
pbuild.pmodules_distfilesdir "${1/--distdir=}"
PMODULES_DISTFILESDIR="${1/--distdir=}"
;;
--tmpdir )
pbuild.temp_dir "$2"
PMODULES_TMPDIR="$2"
shift
;;
--tmpdir=* )
pbuilf.temp_dir "${1/--tmpdir=}"
PMODULES_TMPDIR="${1/--tmpdir=}"
;;
--system )
system=".$2"
pbuild.system "${system}"
opt_system="$2"
shift
;;
--system=* )
system=".${1/*=}"
pbuild.system "${system}"
opt_system="${1/*=}"
;;
--with )
opt_with_modules+=( "$2" )
@@ -223,13 +243,13 @@ parse_args() {
opt_with_modules+=( ${m} )
;;
--prep | --configure | --compile | --install | --all )
pbuild.build_target ${1:2}
opt_build_target=${1:2}
;;
--bootstrap )
opt_bootstrap='yes'
;;
--update-modulefiles )
pbuild.update_modulefiles 'yes'
opt_update_modulefiles='yes'
;;
--overlay )
overlay=$2
@@ -242,7 +262,7 @@ parse_args() {
-* )
std::die 1 "Invalid option -- '$1'"
;;
[=0-9]* )
[=0-9]* | '.*' )
versions+=( "$1" )
;;
'')
@@ -264,17 +284,21 @@ parse_args() {
shift
done
[[ -n ${BUILD_SCRIPT} ]] || std::die 1 "No build-block specified!"
(( ${#versions[@]} > 0)) || std::die 1 "Module version not specified!"
(( ${#versions[@]} > 0)) || versions+=( '.*' )
}
shopt -s nocaseglob
find_variants_files(){
shopt -q nullglob || :
local -i nullglob_set=$?
shopt -s nullglob
local files=( "${BUILDBLOCK_DIR}"/*/variants.${system} )
local files=( "${BUILDBLOCK_DIR}"/*/variants\.${opt_system} )
files+=( "${BUILDBLOCK_DIR}"/*/variants.$(uname -s) )
local f
for f in "${BUILDBLOCK_DIR}"/*/variants; do
[[ -e "${f}.${system}" ]] || files+=( "$f" )
[[ -e "${f}.${opt_system}" ]] \
|| [[ -e "${f}.$(uname -s)" ]] \
|| files+=( "$f" )
done
(( nullglob_set == 1 )) && shopt -u nullglob
std::upvar "$1" "${files[@]}"
@@ -381,20 +405,49 @@ build_modules() {
parse_args "$@"
if [[ -z "${opt_system}" ]]; then
opt_system=$(std::get_os_release)
fi
pbuild.jobs "${opt_jobs}"
pbuild.force_rebuild "${opt_force_rebuild}"
pbuild.build_target "${opt_build_target}"
pbuild.dry_run "${opt_dry_run}"
pbuild.enable_cleanup_build "${opt_enable_cleanup_build}"
pbuild.enable_cleanup_src "${opt_enable_cleanup_src}"
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}/../../${PMODULES_CONFIG_DIR}" && PATH+=":$_"
test -d "${BUILDBLOCK_DIR}/../../config" && PATH+=":$_"
else
test -d "${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}" && PATH+=":$_"
# Please note: if we trap DEBUG a statement like
# test -d ... && PATH+=$_
# does not work (at least on macOS with bash 4 and 5)
if [[ -d "${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}" ]]; then
PATH+=":${PMODULES_ROOT}/${PMODULES_CONFIG_DIR}"
fi
fi
source "${build_config}" || \
std::die 3 "Oops: Cannot source configuration file -- '${build_config}'"
source libpbuild.bash || \
std::die 3 "Oops: Cannot source library -- '$_'"
source "${opt_build_config}" || \
std::die 3 "Oops: Cannot source configuration file -- '$_'"
[[ -z "${overlay}" ]] && overlay=${PMODULES_ROOT}
# :FIXME: should go dist files to
# ${PMODULES_ROOT}/var/distfiles
# or
# ${overlay}/var/distfiles
# ?
: ${PMODULES_DISTFILESDIR:=${PMODULES_ROOT}/var/distfiles}
: ${PMODULES_TMPDIR:=/var/tmp/${USER}}
declare -r BUILD_SCRIPT
declare -r BUILDBLOCK_DIR
+38 -27
View File
@@ -55,7 +55,7 @@ print_help() {
export_env() {
case "${Shell}" in
bash | zsh )
sh | bash | zsh )
local -r fmt="export %s=\"%s\"; "
;;
csh | tcsh )
@@ -343,8 +343,10 @@ subcommand_load() {
# 0: module is loadable
# 1: either not a modulefile or unsused release
#
# Notes:
# The variable 'release' in function 'subcommand_load()' will be set.
# The following variables in the enclosing function are set:
# current_modulefile
# prefix
# release
#
is_available() {
local m=$1
@@ -408,13 +410,7 @@ subcommand_load() {
[[ -z ${dep} ]] && continue
[[ ${dep:0:1} == \# ]] && continue
module_is_loaded "${dep}" && continue
local output=$( subcommand_load 'bash' "${dep}")
eval ${output}
if [[ "${Shell}" == "bash" ]]; then
echo ${output}
else
subcommand_load "${Shell}" "${dep}"
fi
subcommand_load "${dep}"
done < "${fname}"
}
@@ -521,6 +517,8 @@ subcommand_load() {
fi
local found=''
for flag in "${UseFlags[@]/#/_}" ""; do
# :FIXME: this doesn't work if ${m} is a
# modulename without version
if is_available "${m}${flag}"; then
m+="${flag}"
found=':'
@@ -533,11 +531,12 @@ subcommand_load() {
[[ ${verbosity_lvl} == 'verbose' ]] && output_load_hints
std::die 3 ""
fi
if [[ ${current_modulefile} =~ ${PMODULES_ROOT} ]] \
&& [[ ! ${m} =~ / ]]; then
m+="/${current_modulefile##*/}"
fi
if [[ ":${LOADEDMODULES}:" =~ ":${m}:" ]]; then
std::die 3 "%s %s: %s -- %s\n" \
"${CMD}" "${subcommand}" \
"module already loaded" \
"${m}"
continue
fi
for root in "${!Overlays[@]}"; do
if [[ ${current_modulefile} =~ ${root} ]]; then
@@ -552,7 +551,6 @@ subcommand_load() {
|| std::die 1 "Oops: unable to create tmp file!\n"
local output=$("${modulecmd}" 'bash' ${opts} 'load' \
"${current_modulefile}" 2> "${tmpfile}")
eval "${output}"
# we do not want to print the error message we got from
# modulecmd, they are a bit ugly
@@ -573,21 +571,28 @@ subcommand_load() {
"${error_txt}" \
"${m}"
fi
if [[ "${Shell}" == "bash" ]]; then
if [[ "${Shell}" == "sh" ]]; then
# for sh-like shells just echo
echo "${output}"
echo "${error}" 1>&2
else
# re-run with right shell
"${modulecmd}" "${Shell}" ${opts} 'load' \
"${current_modulefile}"
fi
eval "${output}"
if [[ -n "${error}" ]]; then
echo "${error}" 1>&2
fi
if [[ ${verbosity_lvl} != silent ]] && \
[[ ${release} != stable ]]; then
std::info "%s %s: %s -- %s\n" \
local msg=$(printf "%s %s: %s -- %s" \
"${CMD}" 'load' \
"${release} module has been loaded" \
"${m}"
"${m}")
if [[ ${verbosity_lvl} != silent ]] && \
[[ ${release} != stable ]]; then
std::info "%s\n" "${msg}"
fi
logger "${msg}"
done
# fix LOADEDMODULES
LOADEDMODULES="${_LMFILES_}"
@@ -645,11 +650,14 @@ subcommand_unload() {
for arg in "${args[@]}"; do
local output=$("${modulecmd}" "${Shell}" 'unload' "${arg}")
eval "${output}"
if [[ "${Shell}" == "bash" ]]; then
case ${Shell} in
sh | bash | zsh )
echo "${output}"
else
;;
* )
"${modulecmd}" "${Shell}" 'unload' "${arg}"
fi
;;
esac
done
}
@@ -1160,6 +1168,9 @@ subcommand_use() {
done
fi
fi
if [[ -z ${GroupDepths[${arg}]} ]] && [[ -d "${PMODULES_ROOT}/${arg}" ]]; then
scan_groups "${PMODULES_ROOT}"
fi
if [[ -n ${GroupDepths[${arg}]} ]] &&
(( ${GroupDepths[${arg}]} == 0 )); then
# argument is group in our root with depth 0
@@ -1851,7 +1862,7 @@ subcommand_search() {
# help [module|sub-command]
#
Subcommands[help]='help'
Options[help]='-o hHV? -l version -l help'
Options[help]='-o hHV\? -l version -l help'
Help[help]='
USAGE:
module [ switches ] [ subcommand ] [subcommand-args ]
@@ -2106,8 +2117,8 @@ subcommand_initclear() {
# main
#
case "$1" in
bash | zsh )
declare Shell="$1"
sh | bash | zsh )
declare Shell="sh"
;;
csh | tcsh )
declare Shell='csh'
+1
View File
@@ -313,6 +313,7 @@ pmodules::install() {
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"
install -m 0755 -d "${PMODULES_HOME}/lib/Pmodules"
install -m 0644 "${SRC_DIR}/libmodules.tcl" "${PMODULES_HOME}/lib/Pmodules"
+32
View File
@@ -0,0 +1,32 @@
#!/bin/bash
#
# define PMODULES_ROOT only if it has not been passed as argument
# to build/install scripts
#
: ${PMODULES_ROOT:=/opt/psi-overlays}
: ${PMODULES_DISTFILESDIR:=/opt/psi/var/distfiles}
: ${PMODULES_TMPDIR:=/var/tmp/${USER}}
declare -x PMODULES_CONFIG_DIR='config'
declare -x PMODULES_MODULEFILES_DIR='modulefiles'
declare -x PMODULES_HOME="${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION}"
declare -x PMODULES_DEFAULT_GROUPS='Tools Programming'
declare -x PMODULES_DEFINED_RELEASES=':unstable:stable:deprecated:'
declare -x PMODULES_DEFAULT_RELEASES='stable'
export PMODULES_DISTFILESDIR
export PMODULES_TMPDIR
#-----------------------------------------------------------------------------
# OS specific configuration
#
case ${OS} in
Darwin )
declare -x MACOSX_DEPLOYMENT_TARGET='10.12'
#declare -rx SDKROOT='macosx10.9'
;;
esac
+1 -1
View File
@@ -3,5 +3,5 @@ coreutils 8.31
getopt 1.1.6
gettext 0.19.8
modules 3.2.10.1
Pmodules 1.0.0rc5
Pmodules 1.0.0rc6
Tcl 8.6.9