mirror of
https://github.com/Pmodules/Pmodules.git
synced 2026-06-27 18:13:08 +02:00
build-system: installation of modulefile and config files reviewed
This commit is contained in:
+178
-167
@@ -1260,28 +1260,6 @@ _build_module() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#..............................................................
|
|
||||||
# post-install: write file with required modules
|
|
||||||
write_runtime_dependencies() {
|
|
||||||
local -r fname="$1"
|
|
||||||
shift
|
|
||||||
std::info \
|
|
||||||
"%s " \
|
|
||||||
"${module_name}/${module_version}:" \
|
|
||||||
"writing run-time dependencies to ${fname} ..."
|
|
||||||
local dep
|
|
||||||
echo -n "" > "${fname}"
|
|
||||||
for dep in "$@"; do
|
|
||||||
[[ -z $dep ]] && continue
|
|
||||||
if [[ ! $dep == */* ]]; then
|
|
||||||
# no version given: derive the version
|
|
||||||
# from the currently loaded module
|
|
||||||
dep=$( "${modulecmd}" bash list -t 2>&1 1>/dev/null \
|
|
||||||
| grep "^${dep}/" )
|
|
||||||
fi
|
|
||||||
echo "${dep}" >> "${fname}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
patch_elf_exe_and_libs(){
|
patch_elf_exe_and_libs(){
|
||||||
local -- libdir="${OverlayInfo[${ol_name}:install_root]}/lib64"
|
local -- libdir="${OverlayInfo[${ol_name}:install_root]}/lib64"
|
||||||
[[ -d "${libdir}" ]] || return 0
|
[[ -d "${libdir}" ]] || return 0
|
||||||
@@ -1328,18 +1306,6 @@ _build_module() {
|
|||||||
cd "${BUILD_DIR}"
|
cd "${BUILD_DIR}"
|
||||||
[[ "${KernelName}" == "Linux" ]] && post_install_linux
|
[[ "${KernelName}" == "Linux" ]] && post_install_linux
|
||||||
install_doc
|
install_doc
|
||||||
if (( ${#runtime_dependencies[@]} > 0 )); then
|
|
||||||
write_runtime_dependencies \
|
|
||||||
"${PREFIX}/${FNAME_RDEPS}" \
|
|
||||||
"${runtime_dependencies[@]}"
|
|
||||||
fi
|
|
||||||
if (( ${#install_dependencies[@]} > 0 )); then
|
|
||||||
write_runtime_dependencies \
|
|
||||||
"${PREFIX}/${FNAME_IDEPS}" \
|
|
||||||
"${install_dependencies[@]}"
|
|
||||||
fi
|
|
||||||
install_modulefile
|
|
||||||
install_release_file
|
|
||||||
cleanup_build
|
cleanup_build
|
||||||
cleanup_src
|
cleanup_src
|
||||||
std::info \
|
std::info \
|
||||||
@@ -1349,59 +1315,186 @@ _build_module() {
|
|||||||
return 0
|
return 0
|
||||||
} # post_install
|
} # post_install
|
||||||
|
|
||||||
#......................................................................
|
|
||||||
# Install modulefile in ${ol_modulefiles_root}/${GROUP}/modulefiles/...
|
|
||||||
# The modulefiles in the build-block 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
|
|
||||||
# none
|
|
||||||
#
|
|
||||||
# Used gloabal variables:
|
|
||||||
# VERSIONS
|
|
||||||
# BUILDBLOCK_DIR
|
|
||||||
# modulefile_name
|
|
||||||
#
|
|
||||||
install_modulefile() {
|
|
||||||
#..............................................................
|
|
||||||
# Select the modulefile to install.
|
|
||||||
#
|
#
|
||||||
# Arguments:
|
# write modulefile, configuration and dependencies
|
||||||
# $1 upvar to return the filename
|
#
|
||||||
|
install_module_config(){
|
||||||
|
|
||||||
|
#......................................................................
|
||||||
|
# Install modulefile in ${ol_modulefiles_root}/${GROUP}/modulefiles/...
|
||||||
|
# The modulefiles in the build-block can be
|
||||||
|
# versioned like
|
||||||
|
# modulefile-10.2.0
|
||||||
|
# modulefile-10.2
|
||||||
|
# modulefile-10
|
||||||
|
# modulefile
|
||||||
#
|
#
|
||||||
find_modulefile() {
|
# Arguments
|
||||||
local -n _modulefile="$1"
|
# none
|
||||||
local fname=''
|
#
|
||||||
for fname in "${VERSIONS[@]/#/modulefile-}" 'modulefile'; do
|
# Used gloabal variables:
|
||||||
if [[ -r "${BUILDBLOCK_DIR}/${fname}" ]]; then
|
# VERSIONS
|
||||||
_modulefile="${BUILDBLOCK_DIR}/${fname}"
|
# BUILDBLOCK_DIR
|
||||||
break;
|
# modulefile_name
|
||||||
fi
|
#
|
||||||
done
|
install_modulefile() {
|
||||||
[[ -n "${_modulefile}" ]]
|
#..............................................................
|
||||||
}
|
# Select the modulefile to install.
|
||||||
[[ "${is_subpkg}" == 'yes' ]] && return 0
|
#
|
||||||
local src=''
|
# Arguments:
|
||||||
if ! find_modulefile src; then
|
# $1 upvar to return the filename
|
||||||
|
#
|
||||||
|
find_modulefile() {
|
||||||
|
local -n _modulefile="$1"
|
||||||
|
local fname=''
|
||||||
|
for fname in "${VERSIONS[@]/#/modulefile-}" 'modulefile'; do
|
||||||
|
if [[ -r "${BUILDBLOCK_DIR}/${fname}" ]]; then
|
||||||
|
_modulefile="${BUILDBLOCK_DIR}/${fname}"
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
[[ -n "${_modulefile}" ]]
|
||||||
|
}
|
||||||
|
[[ "${is_subpkg}" == 'yes' ]] && return 0
|
||||||
|
local src=''
|
||||||
|
if ! find_modulefile src; then
|
||||||
|
std::info \
|
||||||
|
"%s " \
|
||||||
|
"${module_name}/${module_version}:" \
|
||||||
|
"skipping modulefile installation ..."
|
||||||
|
return
|
||||||
|
fi
|
||||||
std::info \
|
std::info \
|
||||||
"%s " \
|
"%s " \
|
||||||
"${module_name}/${module_version}:" \
|
"${module_name}/${module_version}:" \
|
||||||
"skipping modulefile installation ..."
|
"adding modulefile to overlay '${ol_name}' ..."
|
||||||
return
|
${mkdir} -p "${modulefile_dir}"
|
||||||
|
${install} -m 0644 "${src}" "${modulefile_name}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#..............................................................
|
||||||
|
# post-install: write file with required modules
|
||||||
|
install_runtime_dependencies() {
|
||||||
|
_write_file(){
|
||||||
|
local -r fname="$1"
|
||||||
|
shift
|
||||||
|
std::info \
|
||||||
|
"%s " \
|
||||||
|
"${module_name}/${module_version}:" \
|
||||||
|
"writing run-time dependencies to ${fname} ..."
|
||||||
|
local dep
|
||||||
|
echo -n "" > "${fname}"
|
||||||
|
for dep in "$@"; do
|
||||||
|
[[ -z $dep ]] && continue
|
||||||
|
if [[ ! $dep == */* ]]; then
|
||||||
|
# no version given: derive the version
|
||||||
|
# from the currently loaded module
|
||||||
|
dep=$( "${modulecmd}" bash list -t 2>&1 1>/dev/null \
|
||||||
|
| grep "^${dep}/" )
|
||||||
|
fi
|
||||||
|
echo "${dep}" >> "${fname}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
if (( ${#runtime_dependencies[@]} > 0 )); then
|
||||||
|
if [[ "${ol_name}" == 'base' ]]; then
|
||||||
|
_write_file \
|
||||||
|
"${PREFIX}/${FNAME_RDEPS}" \
|
||||||
|
"${runtime_dependencies[@]}"
|
||||||
|
fi
|
||||||
|
_write_file \
|
||||||
|
"${modulefile_dir}/.deps-${module_version}" \
|
||||||
|
"${runtime_dependencies[@]}"
|
||||||
|
fi
|
||||||
|
if (( ${#install_dependencies[@]} > 0 )); then
|
||||||
|
_write_file \
|
||||||
|
"${PREFIX}/${FNAME_IDEPS}" \
|
||||||
|
"${install_dependencies[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
install_config_file() {
|
||||||
|
[[ "${is_subpkg}" == 'yes' ]] && return 0
|
||||||
|
|
||||||
|
local -r legacy_config_file="${modulefile_dir}/.release-${module_version}"
|
||||||
|
local -- status_legay_config_file='unchanged'
|
||||||
|
local -- relstage_legacy=''
|
||||||
|
if [[ -r "${legacy_config_file}" ]]; then
|
||||||
|
read -r relstage_legacy < "${legacy_config_file}"
|
||||||
|
if [[ "${relstage_legacy}" != "${module_release}" ]]; then
|
||||||
|
status_legay_config_file='changed'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
status_legay_config_file='new'
|
||||||
|
fi
|
||||||
|
${mkdir} -p "${modulefile_dir}"
|
||||||
|
if [[ "${status_legay_config_file}" != 'unchanged' ]]; then
|
||||||
|
echo "${module_release}" > "${legacy_config_file}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
local -r yaml_config_file="${modulefile_dir}/.config-${module_version}"
|
||||||
|
local -- status_yaml_config_file='unchanged'
|
||||||
|
if [[ -r "${yaml_config_file}" ]]; then
|
||||||
|
while read -r key value; do
|
||||||
|
local -n ref="${key:0:-1}"
|
||||||
|
ref="${value}"
|
||||||
|
done < "${yaml_config_file}"
|
||||||
|
if [[ "${relstage}" != "${module_release}" ]]; then
|
||||||
|
status_yaml_config_file='changed'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
status_yaml_config_file='new'
|
||||||
|
fi
|
||||||
|
if [[ "${status_yaml_config_file}" != 'unchanged' ]]; then
|
||||||
|
echo "relstage: ${module_release}" > "${yaml_config_file}"
|
||||||
|
if (( ${#Systems[@]} > 0 )); then
|
||||||
|
echo -n "systems: [${Systems[0]}" >> "${yaml_config_file}"
|
||||||
|
for system in "${Systems[@]:1}"; do
|
||||||
|
echo -n ", ${system}" >> "${yaml_config_file}"
|
||||||
|
done
|
||||||
|
echo "]" >> "${yaml_config_file}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
case ${status_yaml_config_file},${status_legay_config_file} in
|
||||||
|
unchanged,unchanged | new,unchanged)
|
||||||
|
:
|
||||||
|
;;
|
||||||
|
unchanged,changed )
|
||||||
|
std::info \
|
||||||
|
"%s " \
|
||||||
|
"${module_name}/${module_version}:" \
|
||||||
|
"changing release stage from" \
|
||||||
|
"'${relstage_legacy}' to '${module_release}' in legacy config file ..."
|
||||||
|
;;
|
||||||
|
unchanged,new )
|
||||||
|
std::info \
|
||||||
|
"%s " \
|
||||||
|
"${module_name}/${module_version}:" \
|
||||||
|
"setting release stage to '${module_release}' in legacy config file ..."
|
||||||
|
;;
|
||||||
|
changed,unchanged | changed,changed | changed,new | new,changed )
|
||||||
|
std::info \
|
||||||
|
"%s " \
|
||||||
|
"${module_name}/${module_version}:" \
|
||||||
|
"changing release stage from" \
|
||||||
|
"'${relstage_legacy}' to '${module_release}' ..."
|
||||||
|
;;
|
||||||
|
new,new )
|
||||||
|
std::info \
|
||||||
|
"%s " \
|
||||||
|
"${module_name}/${module_version}:" \
|
||||||
|
"setting release stage to '${module_release}' ..."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${opt_update_modulefiles}" == "yes" ]] || \
|
||||||
|
[[ ! -e "${modulefile_name}" ]]; then
|
||||||
|
install_modulefile
|
||||||
fi
|
fi
|
||||||
std::info \
|
install_runtime_dependencies
|
||||||
"%s " \
|
install_config_file
|
||||||
"${module_name}/${module_version}:" \
|
|
||||||
"adding modulefile to overlay '${ol_name}' ..."
|
|
||||||
${mkdir} -p "${modulefile_dir}"
|
|
||||||
${install} -m 0644 "${src}" "${modulefile_name}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup_modulefiles(){
|
cleanup_modulefiles(){
|
||||||
@@ -1435,82 +1528,6 @@ _build_module() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
install_release_file() {
|
|
||||||
[[ "${is_subpkg}" == 'yes' ]] && return 0
|
|
||||||
|
|
||||||
local -r legacy_config_file="${modulefile_dir}/.release-${module_version}"
|
|
||||||
local -- status_legay_config_file='unchanged'
|
|
||||||
local -- relstage_legacy=''
|
|
||||||
if [[ -r "${legacy_config_file}" ]]; then
|
|
||||||
read -r relstage_legacy < "${legacy_config_file}"
|
|
||||||
if [[ "${relstage_legacy}" != "${module_release}" ]]; then
|
|
||||||
status_legay_config_file='changed'
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
status_legay_config_file='new'
|
|
||||||
fi
|
|
||||||
${mkdir} -p "${modulefile_dir}"
|
|
||||||
if [[ "${status_legay_config_file}" != 'unchanged' ]]; then
|
|
||||||
echo "${module_release}" > "${legacy_config_file}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
local -r yaml_config_file="${modulefile_dir}/.config-${module_version}"
|
|
||||||
local -- status_yaml_config_file='unchanged'
|
|
||||||
if [[ -r "${yaml_config_file}" ]]; then
|
|
||||||
while read -r key value; do
|
|
||||||
local -n ref="${key:0:-1}"
|
|
||||||
ref="${value}"
|
|
||||||
done < "${yaml_config_file}"
|
|
||||||
if [[ "${relstage}" != "${module_release}" ]]; then
|
|
||||||
status_yaml_config_file='changed'
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
status_yaml_config_file='new'
|
|
||||||
fi
|
|
||||||
if [[ "${status_yaml_config_file}" != 'unchanged' ]]; then
|
|
||||||
echo "relstage: ${module_release}" > "${yaml_config_file}"
|
|
||||||
if (( ${#Systems[@]} > 0 )); then
|
|
||||||
echo -n "systems: [${Systems[0]}" >> "${yaml_config_file}"
|
|
||||||
for system in "${Systems[@]:1}"; do
|
|
||||||
echo -n ", ${system}" >> "${yaml_config_file}"
|
|
||||||
done
|
|
||||||
echo "]" >> "${yaml_config_file}"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
case ${status_yaml_config_file},${status_legay_config_file} in
|
|
||||||
unchanged,unchanged | new,unchanged)
|
|
||||||
:
|
|
||||||
;;
|
|
||||||
unchanged,changed )
|
|
||||||
std::info \
|
|
||||||
"%s " \
|
|
||||||
"${module_name}/${module_version}:" \
|
|
||||||
"changing release stage from" \
|
|
||||||
"'${relstage_legacy}' to '${module_release}' in legacy config file ..."
|
|
||||||
;;
|
|
||||||
unchanged,new )
|
|
||||||
std::info \
|
|
||||||
"%s " \
|
|
||||||
"${module_name}/${module_version}:" \
|
|
||||||
"setting release stage to '${module_release}' in legacy config file ..."
|
|
||||||
;;
|
|
||||||
changed,unchanged | changed,changed | changed,new | new,changed )
|
|
||||||
std::info \
|
|
||||||
"%s " \
|
|
||||||
"${module_name}/${module_version}:" \
|
|
||||||
"changing release stage from" \
|
|
||||||
"'${relstage_legacy}' to '${module_release}' ..."
|
|
||||||
;;
|
|
||||||
new,new )
|
|
||||||
std::info \
|
|
||||||
"%s " \
|
|
||||||
"${module_name}/${module_version}:" \
|
|
||||||
"setting release stage to '${module_release}' ..."
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup_build() {
|
cleanup_build() {
|
||||||
[[ ${enable_cleanup_build} != 'yes' ]] && return 0
|
[[ ${enable_cleanup_build} != 'yes' ]] && return 0
|
||||||
[[ "${BUILD_DIR}" == "${SRC_DIR}" ]] && return 0
|
[[ "${BUILD_DIR}" == "${SRC_DIR}" ]] && return 0
|
||||||
@@ -1674,7 +1691,7 @@ _build_module() {
|
|||||||
"%s " \
|
"%s " \
|
||||||
"${module_name}/${module_version}:" \
|
"${module_name}/${module_version}:" \
|
||||||
"is deprecated, skiping!"
|
"is deprecated, skiping!"
|
||||||
install_release_file
|
install_module_config
|
||||||
}
|
}
|
||||||
|
|
||||||
std::info \
|
std::info \
|
||||||
@@ -1732,21 +1749,14 @@ _build_module() {
|
|||||||
|
|
||||||
if [[ "${module_release}" == 'remove' ]]; then
|
if [[ "${module_release}" == 'remove' ]]; then
|
||||||
remove_module
|
remove_module
|
||||||
cleanup_modulefiles
|
|
||||||
elif [[ "${module_release}" == 'deprecated' ]]; then
|
elif [[ "${module_release}" == 'deprecated' ]]; then
|
||||||
deprecate_module
|
deprecate_module
|
||||||
cleanup_modulefiles
|
|
||||||
elif [[ -d "${PREFIX}" || "${is_subpkg}" == 'yes' ]] && [[ "${force_rebuild}" == 'no' ]]; then
|
elif [[ -d "${PREFIX}" || "${is_subpkg}" == 'yes' ]] && [[ "${force_rebuild}" == 'no' ]]; then
|
||||||
std::info \
|
std::info \
|
||||||
"%s " \
|
"%s " \
|
||||||
"${module_name}/${module_version}:" \
|
"${module_name}/${module_version}:" \
|
||||||
"already exists, not rebuilding ..."
|
"already exists, not rebuilding ..."
|
||||||
if [[ "${opt_update_modulefiles}" == "yes" ]] || \
|
install_module_config
|
||||||
[[ ! -e "${modulefile_name}" ]]; then
|
|
||||||
install_modulefile
|
|
||||||
fi
|
|
||||||
install_release_file
|
|
||||||
cleanup_modulefiles
|
|
||||||
else
|
else
|
||||||
if [[ "${opt_clean_install,,}" == 'yes' ]]; then
|
if [[ "${opt_clean_install,,}" == 'yes' ]]; then
|
||||||
std::info \
|
std::info \
|
||||||
@@ -1763,8 +1773,9 @@ _build_module() {
|
|||||||
cleanup_src
|
cleanup_src
|
||||||
compile_and_install
|
compile_and_install
|
||||||
post_install
|
post_install
|
||||||
cleanup_modulefiles
|
install_module_config
|
||||||
fi
|
fi
|
||||||
|
cleanup_modulefiles
|
||||||
std::info "* * * * *\n"
|
std::info "* * * * *\n"
|
||||||
}
|
}
|
||||||
readonly -f _build_module
|
readonly -f _build_module
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ BUILD-STEPS OPTIONS:
|
|||||||
--all
|
--all
|
||||||
Run throu all steps including cleanup.
|
Run throu all steps including cleanup.
|
||||||
|
|
||||||
-update-modulefiles
|
--update-modulefiles
|
||||||
Only install the modulefile and set the release.
|
Only install the modulefile and set the release.
|
||||||
|
|
||||||
MISCELLANEOUS OPTIONS:
|
MISCELLANEOUS OPTIONS:
|
||||||
|
|||||||
Reference in New Issue
Block a user