diff --git a/.gitignore b/.gitignore index 613f567..d97b8ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ environment.bash +modbuild.conf modulecmd.bash modulecmd.tcl modmanage.bash diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index f5e5aae..6dbcbf9 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -191,6 +191,9 @@ pbuild::use_cc() { # If the source URL is given, we look for the file-name specified in # the URL. Otherwise we test for several possible names/extensions. # +# The downloaded file will be stored with the name "$P-$V" and extension +# derived from URL. The download directory is the first directory passed. +# # Arguments: # $1: store file name with upvar here # $2: download URL @@ -205,26 +208,28 @@ download_source_file() { local -r url="$2" shift 2 dirs+=( "$@" ) - - fname="${url##*/}" + + local -r fname="${url##*/}" + local -r extension=$(echo ${fname} | sed 's/.*\(.tar.bz2\|.tbz2\|.tar.gz\|.tgz\|.tar.xz\|.zip\)/\1/') + echo "fname=\"${fname}\"" + local dir='' dirs+=( 'not found' ) for dir in "${dirs[@]}"; do [[ -r "${dir}/${fname}" ]] && break done - local output_fname if [[ "${dir}" == 'not found' ]]; then - local -r output_fname="${dirs[0]}/${fname}" + dir="${dirs[0]}" local -r method="${url%:*}" case "${method}" in http | https | ftp ) curl \ -L \ - --output "${output_fname}" \ + --output "${dir}/${fname}" \ "${url}" if (( $? != 0 )); then curl \ --insecure \ - --output "${output_fname}" \ + --output "${dir}/${fname}" \ "${url}" fi ;; @@ -232,11 +237,9 @@ download_source_file() { std::die 4 "Error in download URL: unknown download method '${method}'!" ;; esac - else - output_fname="${dir}/${fname}" fi - std::upvar "${var}" "${output_fname}" - [[ -r "${output_fname}" ]] + std::upvar "${var}" "${dir}/${fname}" + [[ -r "${dir}/${fname}" ]] } pbuild::pre_prep() { @@ -789,7 +792,7 @@ pbuild::make_all() { local dst="${PMODULES_ROOT}/" dst+="${ModuleGroup}/" dst+="${PMODULES_MODULEFILES_DIR}/" - dst+="${ModuleName}" # = name/version + dst+="${ModuleName}" # = group hierarchy + name/version # directory where to install modulefile local -r dstdir=${dst%/*} @@ -806,7 +809,7 @@ pbuild::make_all() { local target_dir="${PMODULES_ROOT}/" target_dir+="${ModuleGroup}/" target_dir+="${PMODULES_MODULEFILES_DIR}/" - target_dir+="${P}" + target_dir+="${ModuleName%/*}" # = group hierarchy + name mkdir -p "${target_dir}" std::info "${P}/${V}: setting release to '${ModuleRelease}' ..." @@ -893,8 +896,6 @@ pbuild::make_all() { fi [[ "${target}" == "install" ]] && return 0 - install_modulefile - [[ ${enable_cleanup_build} == yes ]] && pbuild::cleanup_build [[ ${enable_cleanup_src} == yes ]] && pbuild::cleanup_src return 0 @@ -913,8 +914,12 @@ pbuild::make_all() { [[ "${force_rebuild}" == 'yes' ]] || \ [[ -n "${target}" ]]; then build_module + install_modulefile else std::info "${P}/${V}: already exists, not rebuilding ..." + if [[ "${opt_install_modulefile}" == "yes" ]]; then + install_modulefile + fi fi set_module_release else diff --git a/Pmodules/modbuild b/Pmodules/modbuild index 5fd459c..2bc49c6 100755 --- a/Pmodules/modbuild +++ b/Pmodules/modbuild @@ -149,6 +149,7 @@ declare enable_cleanup_src='no' declare target='' declare bootstrap='no' declare variants_file='' +declare opt_install_modulefile='' # array collecting all modules specified on the command line via '--with=module' with_modules=() @@ -249,6 +250,9 @@ while (( $# > 0 )); do --bootstrap ) bootstrap='yes' ;; + --install-modulefile ) + opt_install_modulefile='yes' + ;; [0-9]* ) V=$1 ;; diff --git a/Pmodules/profile.bash.in b/Pmodules/profile.bash.in index 1910f76..11ddef7 100644 --- a/Pmodules/profile.bash.in +++ b/Pmodules/profile.bash.in @@ -1,5 +1,24 @@ #!/bin/bash # +# The following settings are system defaults. They can be (re-)defined +# in a system wide profile or in a user's profile. + +# set groups which should be available after initialization +: ${PMODULES_DEFAULT_GROUPS:='Tools Programming'} + +# set releases which should be available after initialization +: ${PMODULES_DEFAULT_RELEASES:='stable'} + +# set default version +: ${PMODULES_VERSION:=@PMODULES_VERSION@} + +export PMODULES_DEFAULT_GROUPS +export PMODULES_DEFAULT_RELEASES +export PMODULES_VERSION + +############################################################################# +# N O C H A N G E S B E L O W T H I S L I N E ! # +# # Notes: # - PMODULES_ROOT is derived from the location of this file. # - Some for PMODULES_CONFIG_DIR. @@ -7,14 +26,6 @@ # ${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION} # -: ${PMODULES_DEFAULT_GROUPS:='Tools Programming'} -: ${PMODULES_DEFAULT_RELEASES:='stable'} -: ${PMODULES_VERSION:=@PMODULES_VERSION@} - -############################################################################# -# N O C H A N G E S B E L O W T H I S L I N E ! # -############################################################################# - export PMODULES_DEFAULT_GROUPS export PMODULES_DEFAULT_RELEASES export PMODULES_VERSION diff --git a/build b/build index 4da9435..165f1e9 100755 --- a/build +++ b/build @@ -155,7 +155,7 @@ pmodules::compile() { fi if [[ ! -e "${PMODULES_HOME}/libexec/modulecmd.bin" ]] || [[ ${force} == 'yes' ]]; then - build Modules "${MODULES_VERSION}" + build modules "${MODULES_VERSION}" fi echo "Done..." } diff --git a/config/modbuild.conf b/config/modbuild.conf deleted file mode 100644 index aaaa12a..0000000 --- a/config/modbuild.conf +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -# -# define PMODULES_ROOT only if it has not been passed as argument -# to build/install scripts -# - -declare -x PMODULES_ROOT -declare -x PMODULES_DISTFILESDIR -declare -x PMODULES_TMPDIR - -: ${PMODULES_ROOT:=/opt/psi} -: ${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' - -#----------------------------------------------------------------------------- -# OS specific configuration -# -case ${OS} in -Darwin ) - declare -x MACOSX_DEPLOYMENT_TARGET='10.12' - #declare -rx SDKROOT='macosx10.9' - ;; -esac - diff --git a/config/modbuild.conf.in b/config/modbuild.conf.in index 0f9e61e..b1e6090 100644 --- a/config/modbuild.conf.in +++ b/config/modbuild.conf.in @@ -17,8 +17,8 @@ declare -x PMODULES_DEFAULT_GROUPS='Tools Programming' declare -x PMODULES_DEFINED_RELEASES=':unstable:stable:deprecated:' declare -x PMODULES_DEFAULT_RELEASES='stable' -declare -x PMODULES_DISTFILESDIR -declare -x PMODULES_TMPDIR +export PMODULES_DISTFILESDIR +export PMODULES_TMPDIR #----------------------------------------------------------------------------- # OS specific configuration diff --git a/Modules/build b/modules/build similarity index 93% rename from Modules/build rename to modules/build index 435b4e0..d7a4335 100755 --- a/Modules/build +++ b/modules/build @@ -1,6 +1,6 @@ #!/usr/bin/env modbuild -SOURCE_URL="https://netix.dl.sourceforge.net/project/modules/Modules/modules-$V/modules-$V.tar.bz2" +SOURCE_URL="https://amas.web.psi.ch/Downloads/$P/$P-$V.tar.bz2" TCL_DIR="${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION}"