#include <pakfire/ctx.h>
#include <pakfire/deps.h>
#include <pakfire/dist.h>
+#include <pakfire/elf.h>
#include <pakfire/env.h>
#include <pakfire/file.h>
#include <pakfire/i18n.h>
return r;
}
+static int pakfire_build_find_elf_requires(
+ struct pakfire_ctx* ctx, struct pakfire_file* file, struct pakfire_find_deps_ctx* deps) {
+ struct pakfire_elf* elf = NULL;
+ int r;
+
+ // Try to open the ELF file
+ r = pakfire_elf_open_file(&elf, ctx, file);
+ if (r < 0) {
+ switch (-r) {
+ // This does not seem to be an ELF file
+ case ENOTSUP:
+ return 0;
+
+ // Raise any other errors
+ default:
+ goto ERROR;
+ }
+ }
+
+ // Fetch the interpreter
+ const char* interpreter = pakfire_elf_interpreter(elf);
+ if (interpreter) {
+ r = pakfire_package_add_dep(deps->pkg, PAKFIRE_PKG_REQUIRES, "%s", interpreter);
+ if (r < 0)
+ goto ERROR;
+ }
+
+ERROR:
+ if (elf)
+ pakfire_elf_unref(elf);
+
+ return r;
+}
+
static int __pakfire_build_find_requires(
struct pakfire_ctx* ctx, struct pakfire_file* file, void* data) {
struct pakfire_find_deps_ctx* deps = data;
const char* path = NULL;
+ int r;
// Fetch the file path
path = pakfire_file_get_path(file);
return 0;
// Handle pkg-config files
- if (pakfire_path_match("**.pc", path))
+ else if (pakfire_path_match("**.pc", path))
return pakfire_build_find_pkgconfig_requires(ctx, file, deps);
+ // Split certain file types differently
+ switch (pakfire_file_get_type(file)) {
+ // Regular files
+ case S_IFREG:
+ // Handle ELF files
+ r = pakfire_build_find_elf_requires(ctx, file, deps);
+ if (r < 0)
+ return r;
+ break;
+ }
+
return 0;
}