]> git.ipfire.org Git - pakfire.git/commitdiff
build: Unroll loop for build stages
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Aug 2022 21:48:22 +0000 (21:48 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 17 Aug 2022 21:48:22 +0000 (21:48 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/build.c

index 455b91dbe74849da1361f57e8756e3d620822321..e587d7fd86db506d8fc39d3b04b8c2c5d2c00854 100644 (file)
@@ -79,14 +79,6 @@ struct pakfire_build {
        int init:1;
 };
 
-static const char* stages[] = {
-       "prepare",
-       "build",
-       "test",
-       "install",
-       NULL,
-};
-
 #define TEMPLATE \
        "#!/bin/bash --login\n" \
        "\n" \
@@ -1197,20 +1189,40 @@ static int pakfire_build_perform(struct pakfire_build* build,
                struct pakfire_parser* makefile) {
        int r;
 
-       // Run through all build stages
-       for (const char** stage = stages; *stage; stage++) {
-               r = pakfire_build_stage(build, makefile, *stage);
-               if (r) {
-                       // Drop to a shell for debugging
-                       if (pakfire_has_flag(build->pakfire, PAKFIRE_BUILD_INTERACTIVE))
-                               pakfire_build_shell(build);
+       // Prepare the build
+       r = pakfire_build_stage(build, makefile, "prepare");
+       if (r)
+               goto ERROR;
 
-                       return r;
-               }
-       }
+       // Perform the build
+       r = pakfire_build_stage(build, makefile, "build");
+       if (r)
+               goto ERROR;
+
+       // Test the build
+       r = pakfire_build_stage(build, makefile, "test");
+       if (r)
+               goto ERROR;
+
+       // Install everything
+       r = pakfire_build_stage(build, makefile, "install");
+       if (r)
+               goto ERROR;
 
        // Run post build scripts
-       return pakfire_build_run_post_build_scripts(build);
+       r = pakfire_build_run_post_build_scripts(build);
+       if (r)
+               goto ERROR;
+
+       // Done!
+       return 0;
+
+ERROR:
+       // Drop to a shell for debugging
+       if (pakfire_has_flag(build->pakfire, PAKFIRE_BUILD_INTERACTIVE))
+               pakfire_build_shell(build);
+
+       return r;
 }
 
 PAKFIRE_EXPORT int pakfire_build_exec(struct pakfire_build* build, const char* path) {