build-system: installation of modulefile and config files reviewed

This commit is contained in:
2024-08-29 14:52:12 +02:00
parent 09b4ec55e9
commit 73ccb05afd
2 changed files with 179 additions and 168 deletions
+83 -72
View File
@@ -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,6 +1315,11 @@ _build_module() {
return 0 return 0
} # post_install } # post_install
#
# write modulefile, configuration and dependencies
#
install_module_config(){
#...................................................................... #......................................................................
# Install modulefile in ${ol_modulefiles_root}/${GROUP}/modulefiles/... # Install modulefile in ${ol_modulefiles_root}/${GROUP}/modulefiles/...
# The modulefiles in the build-block can be # The modulefiles in the build-block can be
@@ -1357,9 +1328,6 @@ _build_module() {
# modulefile-10.2 # modulefile-10.2
# modulefile-10 # modulefile-10
# modulefile # modulefile
# the most specific modulefile will be selected. Example:
# For a version 10.2.1 the file moduelfile-10.2 would be
# selected.
# #
# Arguments # Arguments
# none # none
@@ -1404,38 +1372,48 @@ _build_module() {
${install} -m 0644 "${src}" "${modulefile_name}" ${install} -m 0644 "${src}" "${modulefile_name}"
} }
cleanup_modulefiles(){ #..............................................................
# # post-install: write file with required modules
# FIXME: Can it happen, that we remove module-/config-files which install_runtime_dependencies() {
# we shouldn't remove? _write_file(){
# For now we exclude removing from the overlay 'base' only. local -r fname="$1"
# shift
[[ "${is_subpkg}" == 'yes' ]] && return 0
local ol=''
for ol in "${Overlays[@]}"; do
[[ "${ol}" == "${ol_name}" ]] && continue
[[ "${ol}" == 'base' ]] && continue
local modulefiles_root="${OverlayInfo[${ol}:modulefiles_root]}"
local dir="${modulefile_dir/${ol_modulefiles_root}/${modulefiles_root}}"
local fname="${dir}/${module_version}"
if [[ -e "${fname}" ]]; then
std::info "%s "\
"${module_name}/${module_version}:" \
"removing modulefile from overlay '${ol}' ..."
${rm} -f "${fname}"
fi
fname="${dir}/.release-${module_version}"
if [[ -e "${fname}" ]]; then
std::info \ std::info \
"%s " \ "%s " \
"${module_name}/${module_version}:" \ "${module_name}/${module_version}:" \
"removing release file from overlay '${ol}' ..." "writing run-time dependencies to ${fname} ..."
${rm} -f "${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 fi
echo "${dep}" >> "${fname}"
done 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_release_file() { }
install_config_file() {
[[ "${is_subpkg}" == 'yes' ]] && return 0 [[ "${is_subpkg}" == 'yes' ]] && return 0
local -r legacy_config_file="${modulefile_dir}/.release-${module_version}" local -r legacy_config_file="${modulefile_dir}/.release-${module_version}"
@@ -1511,6 +1489,45 @@ _build_module() {
esac esac
} }
if [[ "${opt_update_modulefiles}" == "yes" ]] || \
[[ ! -e "${modulefile_name}" ]]; then
install_modulefile
fi
install_runtime_dependencies
install_config_file
}
cleanup_modulefiles(){
#
# FIXME: Can it happen, that we remove module-/config-files which
# we shouldn't remove?
# For now we exclude removing from the overlay 'base' only.
#
[[ "${is_subpkg}" == 'yes' ]] && return 0
local ol=''
for ol in "${Overlays[@]}"; do
[[ "${ol}" == "${ol_name}" ]] && continue
[[ "${ol}" == 'base' ]] && continue
local modulefiles_root="${OverlayInfo[${ol}:modulefiles_root]}"
local dir="${modulefile_dir/${ol_modulefiles_root}/${modulefiles_root}}"
local fname="${dir}/${module_version}"
if [[ -e "${fname}" ]]; then
std::info "%s "\
"${module_name}/${module_version}:" \
"removing modulefile from overlay '${ol}' ..."
${rm} -f "${fname}"
fi
fname="${dir}/.release-${module_version}"
if [[ -e "${fname}" ]]; then
std::info \
"%s " \
"${module_name}/${module_version}:" \
"removing release file from overlay '${ol}' ..."
${rm} -f "${fname}"
fi
done
}
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
+1 -1
View File
@@ -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: