From: Michael Tremer Date: Sat, 4 Jan 2025 13:56:19 +0000 (+0000) Subject: build: Implement symlink dependencies X-Git-Tag: 0.9.30~542 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a1f9f8a543b3af12245171493026a11dd117940b;p=pakfire.git build: Implement symlink dependencies Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/build.c b/src/pakfire/build.c index 798149aef..8a3c659b6 100644 --- a/src/pakfire/build.c +++ b/src/pakfire/build.c @@ -710,6 +710,36 @@ static int pakfire_build_find_python_abi_requires( PAKFIRE_PKG_REQUIRES, "python-abi = %s", basename + strlen("python")); } +static int pakfire_build_find_symlink_destinations( + struct pakfire_ctx* ctx, struct pakfire_file* file, struct pakfire_find_deps_ctx* deps) { + const char* symlink = NULL; + const char* path = NULL; + char buffer[PATH_MAX]; + int r; + + // Fetch the path + path = pakfire_file_get_path(file); + if (!path) + return -EINVAL; + + // Fetch the destination + symlink = pakfire_file_get_symlink(file); + if (!symlink) + return -EINVAL; + + // Resolve the symlink + r = pakfire_path_merge(buffer, path, symlink); + if (r < 0) + return r; + + // Ignore if the destination is also part of this package + if (pakfire_filelist_contains(deps->filelist, buffer)) + return 0; + + // Otherwise add it as dependency + return pakfire_package_add_dep(deps->pkg, PAKFIRE_PKG_REQUIRES, "%s", buffer); +} + static int pakfire_build_find_provides( struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) { struct pakfire_find_deps_ctx* deps = data; @@ -776,7 +806,13 @@ static int pakfire_build_find_requires( if (r < 0) return r; } + break; + // Symlinks + case S_IFLNK: + r = pakfire_build_find_symlink_destinations(ctx, file, deps); + if (r < 0) + return r; break; } @@ -834,8 +870,9 @@ static int pakfire_build_find_dependencies(struct pakfire_build* build, int r; struct pakfire_find_deps_ctx deps = { - .build = build, - .pkg = pkg, + .build = build, + .pkg = pkg, + .filelist = filelist, }; // Fetch the provides filter