#include <pakfire/scriptlet.h>
#include <pakfire/util.h>
+struct pakfire_build {
+ struct pakfire* pakfire;
+ int nrefs;
+
+ // Flags
+ int flags;
+
+ // Build ID
+ uuid_t id;
+};
+
static const char* stages[] = {
"prepare",
"build",
return r;
}
+static void pakfire_build_free(struct pakfire_build* build) {
+ pakfire_unref(build->pakfire);
+ free(build);
+}
+
+static int pakfire_build_parse_id(struct pakfire_build* build, const char* id) {
+ int r;
+
+ // Try parsing the Build ID
+ if (id) {
+ r = uuid_parse(id, build->id);
+ if (r) {
+ ERROR(build->pakfire, "Could not parse build ID '%s'\n", id);
+ return r;
+ }
+
+ // Otherwise initialize the Build ID with something random
+ } else {
+ uuid_generate_random(build->id);
+ }
+
+ return 0;
+}
+
+PAKFIRE_EXPORT int pakfire_build_create(struct pakfire_build** build,
+ struct pakfire* pakfire, const char* id, int flags) {
+ int r;
+
+ // Allocate build object
+ struct pakfire_build* b = calloc(1, sizeof(*b));
+ if (!b)
+ return 1;
+
+ // Reference pakfire
+ b->pakfire = pakfire_ref(pakfire);
+
+ // Initialize reference counter
+ b->nrefs = 1;
+
+ // Copy flags
+ b->flags = flags;
+
+ // Parse ID
+ r = pakfire_build_parse_id(b, id);
+ if (r)
+ goto ERROR;
+
+ *build = b;
+ return 0;
+
+ERROR:
+ pakfire_build_free(b);
+ return r;
+}
+
+struct pakfire_build* pakfire_build_ref(struct pakfire_build* build) {
+ ++build->nrefs;
+
+ return build;
+}
+
+struct pakfire_build* pakfire_build_unref(struct pakfire_build* build) {
+ if (--build->nrefs > 0)
+ return build;
+
+ pakfire_build_free(build);
+ return NULL;
+}
+
PAKFIRE_EXPORT int pakfire_build(struct pakfire* pakfire, const char* path,
const char* target, const char* id, int flags) {
char makefiles[PATH_MAX];
#include <pakfire/pakfire.h>
+struct pakfire_build;
+
+int pakfire_build_create(struct pakfire_build** build,
+ struct pakfire* pakfire, const char* id, int flags);
+
+struct pakfire_build* pakfire_build_ref(struct pakfire_build* build);
+struct pakfire_build* pakfire_build_unref(struct pakfire_build* build);
+
int pakfire_build(struct pakfire* pakfire, const char* path, const char* target,
const char* id, int flags);
int pakfire_shell(struct pakfire* pakfire, const char** packages);