// Jail
struct pakfire_jail* jail;
- // Local build repo
- struct pakfire_repo* repo;
-
// The result repository
struct pakfire_repo* result;
a pakfire instance running inside the chroot.
*/
static int pakfire_build_enable_repos(struct pakfire_build* build) {
- FILE* f = NULL;
- char repopath[PATH_MAX];
- int r = 1;
-
- const char* path = pakfire_repo_get_path(build->repo);
-
- // Make sure the source directory exists
- r = pakfire_mkdir(path, 0700);
- if (r && errno != EEXIST) {
- ERROR(build->pakfire, "Could not create repository directory %s: %m\n", path);
- goto ERROR;
- }
-
- // Bind-mount the repository data read-only
- r = pakfire_jail_bind(build->jail, path, path, MS_RDONLY);
- if (r) {
- ERROR(build->pakfire, "Could not bind-mount the repository at %s: %m\n", path);
- goto ERROR;
- }
-
- // Make path for configuration file
- r = pakfire_path(build->pakfire, repopath,
- "%s", PAKFIRE_CONFIG_DIR "/repos/" PAKFIRE_REPO_LOCAL ".repo");
- if (r)
- goto ERROR;
-
- // Open the repository configuration
- f = fopen(repopath, "w");
- if (!f) {
- ERROR(build->pakfire, "Could not open %s: %m\n", repopath);
- goto ERROR;
- }
-
- // Write repository configuration
- r = pakfire_repo_write_config(build->repo, f);
- if (r) {
- ERROR(build->pakfire, "Could not write repository configuration: %m\n");
- goto ERROR;
- }
-
-ERROR:
- if (f)
- fclose(f);
-
- return r;
+ return 0;
}
/*
pakfire_repo_unref(build->result);
}
- if (build->repo)
- pakfire_repo_unref(build->repo);
-
if (build->jail)
pakfire_jail_unref(build->jail);
Sets the default target
*/
static int pakfire_build_set_default_target(struct pakfire_build* build) {
- // Look for the "local" repository
- if (build->repo) {
- const char* target = pakfire_repo_get_path(build->repo);
- if (target)
- pakfire_string_set(build->target, target);
- }
-
// Default to the current working directory
if (!*build->target) {
char* cwd = getcwd(build->target, sizeof(build->target));
return 0;
}
-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 r;
- }
-
- // Set description
- pakfire_repo_set_description(build->repo, _("Locally Built Packages"));
-
- // Set path
- pakfire_repo_set_baseurl(build->repo, PAKFIRE_REPO_LOCAL_PATH);
-
- // Set priority
- pakfire_repo_set_priority(build->repo, PAKFIRE_REPO_LOCAL_PRIORITY);
-
- return 0;
-}
-
-static int pakfire_build_setup_result_repo(struct pakfire_build* build) {
+static int pakfire_build_setup_repo(struct pakfire_build* build) {
char path[PATH_MAX] = "/var/tmp/.pakfire-build-repo.XXXXXX";
char url[PATH_MAX];
int r;
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;
if (r)
goto ERROR;
- // Setup repos
- r = pakfire_build_setup_repos(b);
+ // Setup repo
+ r = pakfire_build_setup_repo(b);
if (r)
goto ERROR;
return 0;
}
- // Refresh the local repository
- if (build->repo) {
- r = pakfire_repo_refresh(build->repo, 0);
- if (r) {
- ERROR(build->pakfire, "Could not refresh the local repository: %m\n");
- return 1;
- }
- }
-
// Compose path for snapshot
r = pakfire_cache_path(build->pakfire, path, "%s", "snapshot.tar.zst");
if (r) {