]> git.ipfire.org Git - people/stevee/pakfire.git/commitdiff
build: Rename init routine and add marker
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Aug 2022 10:14:02 +0000 (10:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Aug 2022 10:14:02 +0000 (10:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index a11d11d429ec2cf195760eaea2d533d9763199c2..c47ed24409f8cb96d7a11682d75692ca97679555 100644 (file)
@@ -71,6 +71,9 @@ struct pakfire_build {
 
        // Local build repo
        struct pakfire_repo* repo;
+
+       // States
+       int init:1;
 };
 
 static const char* stages[] = {
@@ -1139,10 +1142,19 @@ ERROR:
        return r;
 }
 
-static int pakfire_build_extract_snapshot(struct pakfire_build* build) {
+/*
+       Initializes the build environment
+*/
+static int pakfire_build_init(struct pakfire_build* build) {
        char path[PATH_MAX];
        int r;
 
+       // Don't do it again
+       if (build->init) {
+               DEBUG(build->pakfire, "Build environment has already been initialized\n");
+               return 0;
+       }
+
        // Refresh the local repository
        if (build->repo) {
                r = pakfire_repo_refresh(build->repo, 0);
@@ -1201,6 +1213,9 @@ static int pakfire_build_extract_snapshot(struct pakfire_build* build) {
                        return r;
        }
 
+       // Mark as initialized
+       build->init = 1;
+
        return 0;
 }
 
@@ -1231,12 +1246,10 @@ PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* p
 
        INFO(build->pakfire, "Building %s...\n", nevra);
 
-       // Extract the snapshot
-       r = pakfire_build_extract_snapshot(build);
-       if (r) {
-               ERROR(build->pakfire, "Could not extract snapshot: %m\n");
+       // Initialize the build environment
+       r = pakfire_build_init(build);
+       if (r)
                goto ERROR;
-       }
 
        const char* packages[] = {
                path, NULL
@@ -1347,12 +1360,10 @@ PAKFIRE_EXPORT int pakfire_shell(struct pakfire* pakfire, const char** packages)
                goto ERROR;
        }
 
-       // Extract the snapshot
-       r = pakfire_build_extract_snapshot(build);
-       if (r) {
-               ERROR(build->pakfire, "Could not extract snapshot: %m\n");
-               return r;
-       }
+       // Initialize the build environment
+       r = pakfire_build_init(build);
+       if (r)
+               goto ERROR;
 
        // Install any additional packages
        if (packages) {