]> git.ipfire.org Git - pakfire.git/commitdiff
build: Fix the Python ABI and store it as a requirement
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Jan 2025 10:58:11 +0000 (10:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 3 Jan 2025 10:58:11 +0000 (10:58 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/build.c
src/scripts/find-requires

index 14a1d5b5f8d8ee3db75072c495a6fe0191e23bfe..b58556b771360efa08e7fb33b06f7bfceab1a711 100644 (file)
@@ -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;
index eb454c0a56387887c177a0c84bf12eef6a0de747..8c46eaa73a26869d931934f4f4b4f875162b7525 100644 (file)
@@ -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