]> git.ipfire.org Git - pakfire.git/commitdiff
build: Fetch package metadata from makefile
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 24 May 2021 12:14:41 +0000 (12:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 24 May 2021 12:14:41 +0000 (12:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index 58e8b600960aee0ebf17fc773788c7602070c798..895faa8af02f2a4c38359161491a39cad97b6b0d 100644 (file)
@@ -25,6 +25,7 @@
 #include <pakfire/execute.h>
 #include <pakfire/dist.h>
 #include <pakfire/logging.h>
+#include <pakfire/package.h>
 #include <pakfire/parser.h>
 #include <pakfire/private.h>
 #include <pakfire/types.h>
@@ -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;
        }