From: Michael Tremer Date: Fri, 3 Jan 2025 10:58:11 +0000 (+0000) Subject: build: Fix the Python ABI and store it as a requirement X-Git-Tag: 0.9.30~561 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ce95ef182f772c75e2f9842b91dfda364cd36da8;p=pakfire.git build: Fix the Python ABI and store it as a requirement Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/build.c b/src/pakfire/build.c index 14a1d5b5f..b58556b77 100644 --- a/src/pakfire/build.c +++ b/src/pakfire/build.c @@ -665,6 +665,30 @@ ERROR: return r; } +static int pakfire_build_find_python_abi_requires( + struct pakfire_ctx* ctx, struct pakfire_file* file, struct pakfire_find_deps_ctx* deps) { + char basename[PATH_MAX]; + int r; + + // Fetch the path + const char* path = pakfire_file_get_path(file); + if (!path) + return -EINVAL; + + // Take the basename + r = pakfire_path_basename(basename, path); + if (r < 0) + return r; + + // The basename must start with python + if (!pakfire_string_startswith(basename, "python")) + return -EINVAL; + + // Add the dependency + return pakfire_package_add_dep(deps->pkg, + PAKFIRE_PKG_REQUIRES, "python-abi = %s", basename + strlen("python")); +} + static int __pakfire_build_find_requires( struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) { struct pakfire_find_deps_ctx* deps = data; @@ -697,6 +721,17 @@ static int __pakfire_build_find_requires( if (r < 0) return r; break; + + // Directories + case S_IFDIR: + // Handle Python ABI + if (pakfire_path_match("/usr/lib*/python*", path)) { + r = pakfire_build_find_python_abi_requires(ctx, file, deps); + if (r < 0) + return r; + } + + break; } return 0; diff --git a/src/scripts/find-requires b/src/scripts/find-requires index eb454c0a5..8c46eaa73 100644 --- a/src/scripts/find-requires +++ b/src/scripts/find-requires @@ -101,27 +101,6 @@ main() { continue fi - # Process special files - case "${file}" in - # Python - /usr/lib*/python*/*) - # Fall through for all python files - ;; - - # Catch the module directory - /usr/lib*/python[0-9]\.[0-9]*) - # This will only get the python directory - file="$(basename "${file}")" - - # Strip the python version from the string - python_version="${file#python}" - - if [ -n "${python_version}" ]; then - echo "python-abi = ${python_version}" - fi - ;; - esac - # Skip anything that isn't a regular file if [ ! -f "${path}" ]; then continue