From: Michael Tremer Date: Mon, 24 May 2021 12:14:41 +0000 (+0000) Subject: build: Fetch package metadata from makefile X-Git-Tag: 0.9.28~1285^2~89 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c07774f65fef441c19465500867463a1c3efb24;p=pakfire.git build: Fetch package metadata from makefile Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index 58e8b6009..895faa8af 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -48,11 +49,13 @@ static const char* stages[] = { "\n" \ "exit 0\n" -static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile, const char* handle) { +static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile, const char* namespace) { + PakfireRepo repo = NULL; + PakfirePackage pkg = NULL; int r = 1; // Expand the handle into the package name - char* name = pakfire_parser_expand(makefile, "packages", handle); + char* name = pakfire_parser_expand(makefile, "packages", namespace); if (!name) { ERROR(pakfire, "Could not get package name: %s\n", strerror(errno)); goto ERROR; @@ -60,12 +63,39 @@ static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile, const INFO(pakfire, "Building package '%s'...\n", name); - // XXX actually do all the work + // Fetch build architecture + const char* arch = pakfire_get_arch(pakfire); + if (!arch) + goto ERROR; + + // Fetch the dummy repository + repo = pakfire_get_repo(pakfire, "@dummy"); + if (!repo) + goto ERROR; + + // Fetch package from makefile + r = pakfire_parser_create_package(makefile, &pkg, repo, namespace, arch); + if (r) { + ERROR(pakfire, "Could not create package from makefile: %s\n", strerror(errno)); + goto ERROR; + } + +#ifdef ENABLE_DEBUG + char* dump = pakfire_package_dump(pkg, 0); + if (dump) { + DEBUG(pakfire, "%s\n", dump); + free(dump); + } +#endif // Success r = 0; ERROR: + if (repo) + pakfire_repo_unref(repo); + if (pkg) + pakfire_package_unref(pkg); if (name) free(name); @@ -93,8 +123,7 @@ static int pakfire_build_packages(Pakfire pakfire, PakfireParser makefile) { // Build packages in reverse order for (int i = num_packages - 1; i >= 0; i--) { - r = pakfire_build_package(pakfire, makefile, - packages[i] + strlen("packages.package:")); + r = pakfire_build_package(pakfire, makefile, packages[i]); if (r) goto ERROR; }