// We allow only up to 2048 processes/threads for every build container
#define PAKFIRE_BUILD_PID_LIMIT (size_t)2048
+// A list of packages that is installed by default
+static const char* PAKFIRE_BUILD_PACKAGES[] = {
+ "build-essential",
+ NULL,
+};
+
struct pakfire_build {
struct pakfire* pakfire;
int nrefs;
int* snapshot_needs_update) {
int r;
- const char* packages[] = {
- "build-essential",
- NULL,
- };
-
int changed = 0;
// Install everything
- r = pakfire_install(build->pakfire, 0, 0, packages, NULL, 0,
+ r = pakfire_install(build->pakfire, 0, 0, PAKFIRE_BUILD_PACKAGES, NULL, 0,
&changed, NULL, NULL);
if (r) {
ERROR(build->pakfire, "Could not install build dependencies: %m\n");
/*
Initializes the build environment
*/
-static int pakfire_build_init(struct pakfire_build* build) {
+static int pakfire_build_setup_snapshot(struct pakfire_build* build) {
int r;
// Don't do it again
return 0;
}
+ // Nothing to do if we don't use the snapshot
+ if (pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_SNAPSHOT))
+ return 0;
+
// Tells us whether we need to (re-)create the snapshot
int snapshot_needs_update = 0;
// Extract snapshot
- if (!pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_SNAPSHOT)) {
- r = pakfire_snapshot_restore(build->pakfire);
- if (r)
- return r;
- }
+ r = pakfire_snapshot_restore(build->pakfire);
+ if (r)
+ return r;
// Install or update any build dependencies
r = pakfire_build_install_packages(build, &snapshot_needs_update);
return r;
// Update the snapshot if there were changes
- if (!pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_SNAPSHOT) && snapshot_needs_update) {
+ if (snapshot_needs_update) {
// Store the snapshot
r = pakfire_snapshot_store(build->pakfire);
if (r)
if (r)
goto ERROR;
+ // Install all essential packages
+ for (const char** p = PAKFIRE_BUILD_PACKAGES; *p; p++) {
+ r = pakfire_request_add(request, PAKFIRE_REQ_INSTALL, *p, PAKFIRE_REQUEST_ESSENTIAL);
+ if (r)
+ goto ERROR;
+ }
+
// Solve the request
r = pakfire_request_solve(request);
if (r)
INFO(build->pakfire, "Building %s...\n", nevra);
// Initialize the build environment
- r = pakfire_build_init(build);
+ r = pakfire_build_setup_snapshot(build);
if (r)
goto ERROR;
}
// Initialize the build environment
- r = pakfire_build_init(build);
+ r = pakfire_build_setup_snapshot(build);
if (r)
goto ERROR;