From: Michael Tremer Date: Sun, 23 May 2021 15:10:17 +0000 (+0000) Subject: build: Add scaffolding to build packages X-Git-Tag: 0.9.28~1285^2~92 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a50bde9c177c1652c04ae13bac4095ae79150ba4;p=pakfire.git build: Add scaffolding to build packages Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index ca658f483..58e8b6009 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -48,6 +48,67 @@ static const char* stages[] = { "\n" \ "exit 0\n" +static int pakfire_build_package(Pakfire pakfire, PakfireParser makefile, const char* handle) { + int r = 1; + + // Expand the handle into the package name + char* name = pakfire_parser_expand(makefile, "packages", handle); + if (!name) { + ERROR(pakfire, "Could not get package name: %s\n", strerror(errno)); + goto ERROR; + } + + INFO(pakfire, "Building package '%s'...\n", name); + + // XXX actually do all the work + + // Success + r = 0; + +ERROR: + if (name) + free(name); + + return r; +} + +static int pakfire_build_packages(Pakfire pakfire, PakfireParser makefile) { + DEBUG(pakfire, "Creating packages..."); + int r = 1; + + // Fetch a list all all packages + char** packages = pakfire_parser_list_namespaces(makefile, "packages.package:*"); + if (!packages) { + ERROR(pakfire, "Could not find any packages: %s\n", strerror(errno)); + goto ERROR; + } + + unsigned int num_packages = 0; + + // Count how many packages we have + for (char** package = packages; *package; package++) + num_packages++; + + DEBUG(pakfire, "Found %d package(s)\n", num_packages); + + // 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:")); + if (r) + goto ERROR; + } + + // Success + r = 0; + +ERROR: + if (packages) + free(packages); + + return r; +} + static int pakfire_build_stage(Pakfire pakfire, PakfireParser makefile, const char* stage, pakfire_execute_logging_callback logging_callback, void* data) { char template[1024]; @@ -113,7 +174,12 @@ PAKFIRE_EXPORT int pakfire_build(Pakfire pakfire, const char* path, } } - // XXX Create the packages + // Create the packages + r = pakfire_build_packages(pakfire, makefile); + if (r) { + ERROR(pakfire, "Could not create packages: %s\n", strerror(errno)); + goto ERROR; + } ERROR: if (makefile)