// Local build repo
struct pakfire_repo* repo;
+ // The result repository
+ struct pakfire_repo* result;
+
// Buildroot
char buildroot[PATH_MAX];
goto ERROR;
}
+ // Rescan the build repository to import all packages again
+ r = pakfire_repo_scan(build->result, 0);
+ if (r)
+ goto ERROR;
+
// Success
r = 0;
}
static void pakfire_build_free(struct pakfire_build* build) {
+ if (build->result) {
+ pakfire_repo_clean(build->result, PAKFIRE_REPO_CLEAN_FLAGS_DESTROY);
+ pakfire_repo_unref(build->result);
+ }
+
if (build->repo)
pakfire_repo_unref(build->repo);
return 0;
}
-static int pakfire_build_setup_repos(struct pakfire_build* build) {
+static int pakfire_build_setup_local_repo(struct pakfire_build* build) {
int r;
// Create a new repository
r = pakfire_repo_create(&build->repo, build->pakfire, PAKFIRE_REPO_LOCAL);
if (r) {
ERROR(build->pakfire, "Could not create repository %s: %m\n", PAKFIRE_REPO_LOCAL);
- return 1;
+ return r;
}
// Set description
return 0;
}
+static int pakfire_build_setup_result_repo(struct pakfire_build* build) {
+ char path[PATH_MAX] = "/var/tmp/.pakfire-build-repo.XXXXXX";
+ char url[PATH_MAX];
+ int r;
+
+ // Create a new repository
+ r = pakfire_repo_create(&build->result, build->pakfire, PAKFIRE_REPO_RESULT);
+ if (r) {
+ ERROR(build->pakfire, "Could not create repository %s: %m", PAKFIRE_REPO_RESULT);
+ return r;
+ }
+
+ // Set description
+ pakfire_repo_set_description(build->result, _("Build Repository"));
+
+ // Create a temporary directory
+ const char* p = pakfire_mkdtemp(path);
+ if (!p) {
+ ERROR(build->pakfire, "Could not create a the build repository: %m\n");
+ return 1;
+ }
+
+ // Format the URL
+ r = pakfire_string_format(url, "file://%s", path);
+ if (r)
+ return r;
+
+ // Set the URL
+ pakfire_repo_set_baseurl(build->result, url);
+
+ return r;
+}
+
+static int pakfire_build_setup_repos(struct pakfire_build* build) {
+ int r;
+
+ // Set up the local repository
+ r = pakfire_build_setup_local_repo(build);
+ if (r)
+ return r;
+
+ // Setup the result repository
+ r = pakfire_build_setup_result_repo(build);
+ if (r)
+ return r;
+
+ return 0;
+}
+
PAKFIRE_EXPORT int pakfire_build_create(struct pakfire_build** build,
struct pakfire* pakfire, const char* id, int flags) {
int r;