"offline",
"conf",
"build",
- "disable_ccache",
"confirm_callback",
NULL,
};
int interactive = 0;
int offline = 0;
int build = 0;
- int disable_ccache = 1;
- if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzOppzppO", kwlist,
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzOppzpO", kwlist,
&path, &arch, &self->callbacks.log, &interactive, &offline, &conf, &build,
- &disable_ccache, &self->callbacks.confirm))
+ &self->callbacks.confirm))
return -1;
// Check if log callback is callable
flags |= PAKFIRE_FLAGS_OFFLINE;
// Enable build mode
- if (build) {
+ if (build)
flags |= PAKFIRE_FLAGS_BUILD;
- if (disable_ccache)
- flags |= PAKFIRE_FLAGS_DISABLE_CCACHE;
- }
-
// Configure callbacks
if (self->callbacks.log)
Py_INCREF(self->callbacks.log);
"path",
"build_id",
"disable_snapshot",
+ "disable_ccache",
NULL,
};
const char* path = NULL;
const char* build_id = NULL;
int disable_snapshot = 0;
+ int disable_ccache = 0;
- if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zp", kwlist, &path, &build_id,
- &disable_snapshot))
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zpp", kwlist, &path, &build_id,
+ &disable_snapshot, &disable_ccache))
return NULL;
int flags = 0;
if (disable_snapshot)
flags |= PAKFIRE_BUILD_DISABLE_SNAPSHOT;
+ // Disable ccache if requested
+ if (disable_ccache)
+ flags |= PAKFIRE_BUILD_DISABLE_CCACHE;
+
// Run build
int r = pakfire_build(self->pakfire, path, NULL, build_id, flags);
#include <pakfire/snapshot.h>
#include <pakfire/util.h>
+#define CCACHE_DIR "/var/cache/ccache"
+
// We guarantee 2 GiB of memory to every build container
#define PAKFIRE_BUILD_GUARANTEED_MEMORY (size_t)2 * 1024 * 1024 * 1024
return 0;
}
+/*
+ Sets up the ccache for this build
+*/
+static int pakfire_build_setup_ccache(struct pakfire_build* build) {
+ char path[PATH_MAX];
+ int r;
+
+ // Check if we want a ccache
+ if (pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_CCACHE)) {
+ DEBUG(build->pakfire, "ccache usage has been disabled for this build\n");
+ return 0;
+ }
+
+ // Compose path
+ r = pakfire_make_cache_path(build->pakfire, path, "%s", "ccache");
+ if (r < 0) {
+ ERROR(build->pakfire, "Could not compose ccache path: %m\n");
+ return 1;
+ }
+
+ DEBUG(build->pakfire, "Mounting ccache from %s\n", path);
+
+ // Ensure path exists
+ r = pakfire_mkdir(path, 0755);
+ if (r && errno != EEXIST) {
+ ERROR(build->pakfire, "Could not create ccache directory %s: %m\n", path);
+ return r;
+ }
+
+ // Bind-mount the directory
+ r = pakfire_jail_bind(build->jail, path, CCACHE_DIR, MS_NOSUID|MS_NOEXEC|MS_NODEV);
+ if (r) {
+ ERROR(build->pakfire, "Could not mount ccache: %m\n");
+ return r;
+ }
+
+ return 0;
+}
+
PAKFIRE_EXPORT int pakfire_build_create(struct pakfire_build** build,
struct pakfire* pakfire, const char* id, int flags) {
int r;
if (r)
goto ERROR;
+ // Setup ccache
+ r = pakfire_build_setup_ccache(b);
+ if (r)
+ goto ERROR;
+
*build = b;
return 0;
enum pakfire_build_flags {
PAKFIRE_BUILD_DISABLE_SNAPSHOT = (1 << 0),
+ PAKFIRE_BUILD_DISABLE_CCACHE = (1 << 1),
};
int pakfire_build_create(struct pakfire_build** build,
PAKFIRE_FLAGS_INTERACTIVE = (1 << 0),
PAKFIRE_FLAGS_OFFLINE = (1 << 1),
PAKFIRE_FLAGS_BUILD = (1 << 2),
- PAKFIRE_FLAGS_DISABLE_CCACHE = (1 << 3),
};
// Callbacks
#define KEYSTORE_DIR "/etc/pakfire/trusted.keys.d"
#define LOCK_PATH PAKFIRE_PRIVATE_DIR "/.lock"
-#define CCACHE_DIR "/var/cache/ccache"
struct pakfire {
int nrefs;
if (pakfire->build_setup)
return 0;
- char path[PATH_MAX];
- int r;
-
- // Mount ccache
- if (!pakfire_has_flag(pakfire, PAKFIRE_FLAGS_DISABLE_CCACHE)) {
- r = pakfire_make_cache_path(pakfire, path, "%s", "ccache");
- if (r < 0)
- return r;
-
- // Ensure path exists
- r = pakfire_mkdir(path, 0755);
- if (r && errno != EEXIST) {
- ERROR(pakfire, "Could not create ccache directory %s: %m\n", path);
- return r;
- }
-
- r = pakfire_bind(pakfire, path, CCACHE_DIR, MS_NOSUID|MS_NOEXEC|MS_NODEV);
- if (r) {
- ERROR(pakfire, "Could not mount ccache: %m\n");
- return r;
- }
- }
-
// Build setup done
pakfire->build_setup = 1;
os.unlink(self.pakfire_conf)
# Run the build in a new thread
- thread = asyncio.to_thread(p.build, pkg, disable_snapshot=True, **kwargs)
+ thread = asyncio.to_thread(p.build, pkg,
+ disable_ccache=True, disable_snapshot=True, **kwargs)
# Return a task
return asyncio.create_task(thread)