From 1b9aca3c22de8abf6e35214d447a6869ed684ea4 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Sat, 15 Nov 2025 08:21:36 -0500 Subject: [PATCH] common/hooks/pre-pkg/03-restrict-py3-version: new hook This hook ensures that any package installing files under ${py3_sitelib} contain a python3 dependency that is bound to the correct minor version. --- .../hooks/pre-pkg/03-restrict-py3-version.sh | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 common/hooks/pre-pkg/03-restrict-py3-version.sh diff --git a/common/hooks/pre-pkg/03-restrict-py3-version.sh b/common/hooks/pre-pkg/03-restrict-py3-version.sh new file mode 100644 index 00000000000..1e4b167f235 --- /dev/null +++ b/common/hooks/pre-pkg/03-restrict-py3-version.sh @@ -0,0 +1,31 @@ +# vim: set ts=4 sw=4 et: +# +# This hook performs the following task: +# - Identifies any python3 runtime dependencies +# - If any are found, ensures that the base python3 package is included +# - Restricts the python3 version to the same minor specified in $py3_ver + +hook() { + [ -d "${PKGDESTDIR}/${py3_lib}" ] || return 0 + [ "${pkgname}" = python3 ] && return 0 + + local dep rdeps + for dep in ${run_depends}; do + case "${dep}" in + python3 | "python3>"* | "python3<"* | "python3-${py3_ver}"* ) ;; + *) rdeps+=( "${dep}" ) ;; + esac + done + + local minor next_minor + + minor="${py3_ver#3.}" + next_minor="$(( "${minor}" + 1 ))" >/dev/null 2>&1 || next_minor= + + if ! [ "${next_minor}" -gt "${minor}" ]; then + msg_error 'unable to determine python3 minor bounds from $py3_ver\n' + fi + + rdeps+=( "python3>=3.${minor}.0_1<3.${next_minor}.0_1" ) + run_depends="${rdeps[*]}" +}