From 6dce89ae73673114ab8b8ff56d9389df0ead5dc3 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 27 Mar 2018 17:40:24 +0200 Subject: [PATCH 01/13] Pmodules/libpbuild.bash: fixes in pbuild::get_source(); towwards Zip support in unpack --- Pmodules/libpbuild.bash | 46 ++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 97bd6f2..5de8909 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -172,6 +172,9 @@ pbuild::module_exists() { # 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 @@ -187,37 +190,35 @@ pbuild::get_source() { shift 2 dirs+=( "$@" ) - fname="${url##*/}" + local -r fname="$P-$V.${url##*.}" + 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 file ) - cp "${url/file:}" "output_fname" + cp "${url/file:}" "${dir}/${fname}" ;; 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 ;; esac - else - output_fname="${dir}/${fname}" fi - std::upvar "${var}" "${output_fname}" - [[ -r "${output_fname}" ]] + std::upvar "${var}" "${dir}/${fname}" + [[ -r "${dir}/${fname}" ]] } # @@ -259,15 +260,26 @@ pbuild::post_prep() { : } +# +# unpack file in given directory +# pbuild::unpack() { local -r file="$1" local -r dir="$2" ( - if [[ -n "${dir}" ]]; then - mkdir -p "${dir}" - cd "${dir}" - fi - tar -xv --strip-components 1 -f "${file}" + mkdir -p "${dir}" + cd "${dir}" + local -r file_extension="${file##*.}" + case "${file_extension}" in + "zip" ) + std::die 42 "Zip files are not supported" + ;; + * ) + # let's hope that tar supports + tar -xv --strip-components 1 -f "${file}" || \ + std::die 42 "${file}: Cannot untar file, maybe file format is not supported!" + ;; + esac ) } @@ -778,7 +790,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%/*} @@ -795,7 +807,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}' ..." From 2ab75e763652ae67951be3b213d755153fe7946a Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 16:29:32 +0200 Subject: [PATCH 02/13] 'Modules' renamed to 'modules' --- {Modules => modules}/build | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {Modules => modules}/build (100%) diff --git a/Modules/build b/modules/build similarity index 100% rename from Modules/build rename to modules/build From f06f3005989a44a495ffcb853e3621fa7825f05b Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 16:31:53 +0200 Subject: [PATCH 03/13] Pmodules/libpbuild.bash: fixes in get_source(), modulefile installation can be forced via command-line --- Pmodules/libpbuild.bash | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 5de8909..9225c36 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -189,8 +189,11 @@ pbuild::get_source() { local -r url="$2" shift 2 dirs+=( "$@" ) - - local -r fname="$P-$V.${url##*.}" + + local -r fname_in_url="${url##*/}" + local -r extension=$(echo ${fname_in_url} | sed 's/.*\(.tar.bz2\|.tbz2\|tar.gz\|.tgz\|.tar.xz\|.zip\)/\1/') + local -r fname="$P-$V.${extension}" + echo "fname=\"${fname}\"" local dir='' dirs+=( 'not found' ) for dir in "${dirs[@]}"; do @@ -876,8 +879,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 @@ -896,8 +897,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 From 6971f04b04f39688a401826a4c5da9c5279b7647 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 16:32:33 +0200 Subject: [PATCH 04/13] Pmodules/modbuild: modulefile installation can be forced via command-line --- Pmodules/modbuild | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Pmodules/modbuild b/Pmodules/modbuild index fe4e308..8ff35d4 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 ;; From 3e3bc0ed79e7f0c6cec9071652ae4fed424a0086 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 16:33:32 +0200 Subject: [PATCH 05/13] build: Modules renamed to modules --- build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..." } From 4a8f1c8589b5a7f8e8e10e1ed8b994dd05dafa1e Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 16:34:01 +0200 Subject: [PATCH 06/13] config/modbuild.conf: bugfix --- config/modbuild.conf | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/config/modbuild.conf b/config/modbuild.conf index aaaa12a..acdfdf3 100644 --- a/config/modbuild.conf +++ b/config/modbuild.conf @@ -4,14 +4,9 @@ # 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}} +: ${PMODULES_ROOT:=/cluster/project/psi/} +: ${PMODULES_DISTFILESDIR:=/cluster/project/psi/var/distfiles} +: ${PMODULES_TMPDIR:=/cluster/project/psi/var/tmp} declare -x PMODULES_CONFIG_DIR='config' declare -x PMODULES_MODULEFILES_DIR='modulefiles' @@ -22,6 +17,9 @@ 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 # From fa9845f1a1f24b683c4f83aae9b352d0b3cfb055 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 21:33:49 +0200 Subject: [PATCH 07/13] modbuild.conf removed --- config/modbuild.conf | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 config/modbuild.conf diff --git a/config/modbuild.conf b/config/modbuild.conf deleted file mode 100644 index acdfdf3..0000000 --- a/config/modbuild.conf +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# -# define PMODULES_ROOT only if it has not been passed as argument -# to build/install scripts -# -: ${PMODULES_ROOT:=/cluster/project/psi/} -: ${PMODULES_DISTFILESDIR:=/cluster/project/psi/var/distfiles} -: ${PMODULES_TMPDIR:=/cluster/project/psi/var/tmp} - -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 - From c0bb112a025926019dbe92a8261721f4f14c0ee5 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 22:12:23 +0200 Subject: [PATCH 08/13] bugfix in get_sources() --- Pmodules/libpbuild.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 9225c36..5305c59 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -191,8 +191,8 @@ pbuild::get_source() { dirs+=( "$@" ) local -r fname_in_url="${url##*/}" - local -r extension=$(echo ${fname_in_url} | sed 's/.*\(.tar.bz2\|.tbz2\|tar.gz\|.tgz\|.tar.xz\|.zip\)/\1/') - local -r fname="$P-$V.${extension}" + local -r extension=$(echo ${fname_in_url} | sed 's/.*\(.tar.bz2\|.tbz2\|.tar.gz\|.tgz\|.tar.xz\|.zip\)/\1/') + local -r fname="$P-$V${extension}" echo "fname=\"${fname}\"" local dir='' dirs+=( 'not found' ) From 7d9be47f1f0903c23630224ece73fbe589973123 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 22:13:02 +0200 Subject: [PATCH 09/13] download module package from AMAS web-site --- modules/build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/build b/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}" From 248c6f05682f728b8e9e64eac9a9b0374b38608e Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 13 Apr 2018 23:09:21 +0200 Subject: [PATCH 10/13] bugfix in profile.bash.in and some comments added --- Pmodules/profile.bash.in | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/Pmodules/profile.bash.in b/Pmodules/profile.bash.in index c0fdbe9..8306c55 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,18 +26,6 @@ # ${PMODULES_ROOT}/Tools/Pmodules/${PMODULES_VERSION} # -declare -x PMODULES_DEFAULT_GROUPS -declare -x PMODULES_DEFAULT_RELEASES -declare -x 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 ! # -############################################################################# - declare -x PMODULES_MODULEFILES_DIR='modulefiles' declare -x PMODULES_DEFINED_RELEASES=':unstable:stable:deprecated:' From b02ce8e6db374d409835a6448b7213bf4154b900 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 17 Apr 2018 00:13:11 +0200 Subject: [PATCH 11/13] Pmodules/libpbuild.bash: use filename derived from URL --- Pmodules/libpbuild.bash | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Pmodules/libpbuild.bash b/Pmodules/libpbuild.bash index 5305c59..e626609 100644 --- a/Pmodules/libpbuild.bash +++ b/Pmodules/libpbuild.bash @@ -190,9 +190,8 @@ pbuild::get_source() { shift 2 dirs+=( "$@" ) - local -r fname_in_url="${url##*/}" - local -r extension=$(echo ${fname_in_url} | sed 's/.*\(.tar.bz2\|.tbz2\|.tar.gz\|.tgz\|.tar.xz\|.zip\)/\1/') - local -r fname="$P-$V${extension}" + 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' ) From 233c0ba32ac253440b155b92451669a3ab5de49a Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 17 Apr 2018 17:05:21 +0200 Subject: [PATCH 12/13] ignore conf/modbuild.conf --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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 From 33dcb6366c35e733a1a40ee1b968506f7e05b190 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Tue, 17 Apr 2018 17:06:09 +0200 Subject: [PATCH 13/13] config/modbuild.conf.in: bugfix in exporting PMODULES_TMP and PMODULES_DISTFILESDIR --- config/modbuild.conf.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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