// ccache path
char ccache_path[PATH_MAX];
-
- // State
- enum pakfire_build_states {
- PAKFIRE_BUILD_INIT = 0,
- PAKFIRE_BUILD_READY,
- } state;
};
#define TEMPLATE \
return pakfire_string_set(build->target, target);
}
-static int pakfire_build_install_packages(struct pakfire_build* build) {
- struct pakfire_transaction* transaction = NULL;
- char* problems = NULL;
- int r;
-
- // Create a new transaction
- r = pakfire_transaction_create(&transaction, build->pakfire, 0);
- if (r)
- goto ERROR;
-
- // Install all build dependencies
- for (const char** p = PAKFIRE_BUILD_PACKAGES; *p; p++) {
- r = pakfire_transaction_request(transaction,
- PAKFIRE_JOB_INSTALL, *p, PAKFIRE_JOB_ESSENTIAL);
- if (r)
- goto ERROR;
- }
-
- // Also update everything that has already been installed
- r = pakfire_transaction_request(transaction, PAKFIRE_JOB_SYNC, NULL, 0);
- if (r)
- goto ERROR;
-
- // Solve the transaction
- r = pakfire_transaction_solve(transaction, 0, &problems);
- if (r) {
- ERROR(build->ctx, "Could not install build dependencies:\n%s\n", problems);
- goto ERROR;
- }
-
- // Run the transaction
- r = pakfire_transaction_run(transaction);
- if (r)
- goto ERROR;
-
-ERROR:
- if (transaction)
- pakfire_transaction_unref(transaction);
- if (problems)
- free(problems);
-
- return r;
-}
-
-/*
- Initializes the build environment
-*/
-static int pakfire_build_init(struct pakfire_build* build) {
- int r;
-
- // Don't do it again
- if (build->state != PAKFIRE_BUILD_INIT) {
- DEBUG(build->ctx, "Build environment has already been initialized\n");
- return 0;
- }
-
- // Install or update any build dependencies
- r = pakfire_build_install_packages(build);
- if (r)
- return r;
-
- // Mark as ready
- build->state = PAKFIRE_BUILD_READY;
-
- return 0;
-}
-
static int pakfire_build_read_makefile(struct pakfire_build* build,
struct pakfire_parser** parser, struct pakfire_package* package) {
char path[PATH_MAX];
return r;
}
-static int pakfire_build_install_source_package(
- struct pakfire_build* build, struct pakfire_package* package) {
+static int pakfire_build_init(struct pakfire_build* build, struct pakfire_package* package) {
struct pakfire_transaction* transaction = NULL;
char* problems = NULL;
int r;
goto ERROR;
}
- // Add the source package
- r = pakfire_transaction_request_package(transaction,
- PAKFIRE_JOB_INSTALL, package, PAKFIRE_JOB_ESSENTIAL);
+ // Add the source package (if any)
+ if (package) {
+ r = pakfire_transaction_request_package(transaction,
+ PAKFIRE_JOB_INSTALL, package, PAKFIRE_JOB_ESSENTIAL);
+ if (r)
+ goto ERROR;
+ }
+
+ // Also update everything that has already been installed
+ r = pakfire_transaction_request(transaction, PAKFIRE_JOB_SYNC, NULL, 0);
if (r)
goto ERROR;
goto ERROR;
}
- // Initialize the build environment
- r = pakfire_build_init(build);
- if (r)
- goto ERROR;
-
- // Install the source package
- r = pakfire_build_install_source_package(build, package);
+ // Install everything we need and the source package, too
+ r = pakfire_build_init(build, package);
if (r) {
ERROR(build->ctx, "Could not install the source package: %m\n");
goto ERROR;
if (r)
goto ERROR;
- // Initialize the build environment
- r = pakfire_build_init(build);
+ // Install all packages
+ r = pakfire_build_install(build, NULL);
if (r)
goto ERROR;
int r;
// Initialize the build environment
- r = pakfire_build_init(build);
+ r = pakfire_build_init(build, NULL);
if (r)
return r;