From 8dbb69f93e28810a5fbd7b980b7e2cff47f971ca Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Wed, 17 Aug 2022 10:14:02 +0000 Subject: [PATCH] build: Rename init routine and add marker Signed-off-by: Michael Tremer --- src/libpakfire/build.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/libpakfire/build.c b/src/libpakfire/build.c index a11d11d4..c47ed244 100644 --- a/src/libpakfire/build.c +++ b/src/libpakfire/build.c @@ -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) { -- 2.47.3