return r;
}
-static int __pakfire_build_find_pkgconfig_requires(struct pakfire_ctx* ctx,
- void* data, const char* line, const size_t length) {
- struct pakfire_find_deps_ctx* deps = data;
+static int pakfire_build_process_pkgconfig_dep(struct pakfire_package* pkg,
+ const enum pakfire_package_key key, const char* line, const size_t length) {
char buffer[PATH_MAX];
int r;
// Add everything if we have all the information
if (name && op && version) {
- r = pakfire_package_add_dep(deps->pkg, PAKFIRE_PKG_REQUIRES,
- "pkgconfig(%s) %s %s", name, op, version);
+ r = pakfire_package_add_dep(pkg, key, "pkgconfig(%s) %s %s", name, op, version);
if (r < 0)
return r;
// Otherwise we add the entire buffer and hope for the best
} else {
- r = pakfire_package_add_dep(deps->pkg, PAKFIRE_PKG_REQUIRES,
- "pkgconfig(%s)", buffer);
+ r = pakfire_package_add_dep(pkg, key, "pkgconfig(%s)", buffer);
if (r < 0)
return r;
}
return length;
}
+static int pakfire_build_process_pkgconfig_provides(
+ struct pakfire_ctx* ctx, void* data, const char* line, const size_t length) {
+ struct pakfire_find_deps_ctx* deps = data;
+
+ return pakfire_build_process_pkgconfig_dep(deps->pkg, PAKFIRE_PKG_PROVIDES, line, length);
+}
+
+static int pakfire_build_process_pkgconfig_requires(
+ struct pakfire_ctx* ctx, void* data, const char* line, const size_t length) {
+ struct pakfire_find_deps_ctx* deps = data;
+
+ return pakfire_build_process_pkgconfig_dep(deps->pkg, PAKFIRE_PKG_REQUIRES, line, length);
+}
+
+static int pakfire_build_find_pkgconfig_provides(
+ struct pakfire_ctx* ctx, struct pakfire_file* file, struct pakfire_find_deps_ctx* deps) {
+ const char* buildroot = NULL;
+ int r;
+
+ // Fetch the absolute path
+ const char* path = pakfire_file_get_abspath(file);
+ if (!path)
+ return -EINVAL;
+
+ // Fetch the path to the buildroot
+ buildroot = pakfire_relpath(deps->build->pakfire, deps->build->buildroot);
+ if (!buildroot)
+ return -EINVAL;
+
+ const char* argv[] = {
+ "pkg-config",
+ "--print-provides",
+ pakfire_relpath(deps->build->pakfire, path),
+ NULL,
+ };
+
+ // Run pkg-config and process the output
+ r = pakfire_jail_communicate(deps->build->jail, argv, NULL, 0, NULL, NULL,
+ pakfire_build_process_pkgconfig_provides, deps);
+ if (r < 0)
+ return r;
+
+ return 0;
+}
+
static int pakfire_build_find_pkgconfig_requires(
struct pakfire_ctx* ctx, struct pakfire_file* file, struct pakfire_find_deps_ctx* deps) {
struct pakfire_env* env = NULL;
// Run pkg-config and process the output
r = pakfire_jail_communicate(deps->build->jail, argv, env, 0, NULL, NULL,
- __pakfire_build_find_pkgconfig_requires, deps);
+ pakfire_build_process_pkgconfig_requires, deps);
if (r < 0)
goto ERROR;
PAKFIRE_PKG_REQUIRES, "python-abi = %s", basename + strlen("python"));
}
-static int __pakfire_build_find_requires(
+static int pakfire_build_find_provides(
+ 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);
+ if (!path)
+ return -EINVAL;
+
+ // Skip debug files
+ if (pakfire_path_match("/usr/lib/debug/**", path))
+ return 0;
+
+ // Skip debug sources
+ else if (pakfire_path_match("/usr/src/debug/**", path))
+ return 0;
+
+ // Handle pkg-config files
+ else if (pakfire_path_match("**.pc", path))
+ return pakfire_build_find_pkgconfig_provides(ctx, file, deps);
+
+#if 0
+ // Split certain file types differently
+ switch (pakfire_file_get_type(file)) {
+ // Regular files
+ case S_IFREG:
+ // Handle ELF files
+ r = pakfire_build_find_elf_provides(ctx, file, deps);
+ if (r < 0)
+ return r;
+ break;
+ }
+#endif
+
+ return 0;
+}
+
+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;
return 0;
}
-static int pakfire_build_find_requires(struct pakfire_build* build,
- struct pakfire_package* pkg, struct pakfire_filelist* filelist) {
- struct pakfire_find_deps_ctx deps = {
- .build = build,
- .pkg = pkg,
- };
-
- return pakfire_filelist_walk(filelist, __pakfire_build_find_requires, &deps, 0, NULL);
-}
-
/*
This function is a special way to run a script.
char* filter_requires = NULL;
int r;
+ struct pakfire_find_deps_ctx deps = {
+ .build = build,
+ .pkg = pkg,
+ };
+
// Fetch the provides filter
filter_provides = pakfire_parser_get(makefile, namespace, "filter_provides");
if (filter_provides) {
}
// Find all provides
+ r = pakfire_filelist_walk(filelist, pakfire_build_find_provides, &deps, 0, NULL);
+ if (r < 0)
+ goto ERROR;
+
+ // XXX LEGACY CODE
r = pakfire_build_find_deps(build, pkg,
PAKFIRE_PKG_PROVIDES, "find-provides", filelist, 0);
if (r)
goto ERROR;
// Find all requires
- r = pakfire_build_find_requires(build, pkg, filelist);
+ r = pakfire_filelist_walk(filelist, pakfire_build_find_requires, &deps, 0, NULL);
if (r < 0)
goto ERROR;