int cli_shell(void* data, int argc, char* argv[]) {
struct pakfire* pakfire = NULL;
+ struct pakfire_build* build = NULL;
int r;
struct cli_config* cli_config = data;
struct config config = {
- .flags = 0,
+ .flags = PAKFIRE_BUILD_INTERACTIVE,
.packages = {},
.num_packages = 0,
};
if (r)
goto ERROR;
- // Run the shell
- r = pakfire_shell(pakfire, config.packages, config.flags);
- if (r)
+ // Setup the build environment
+ r = pakfire_build_create(&build, pakfire, NULL, config.flags);
+ if (r) {
+ fprintf(stderr, "Could not setup the build environment: %m\n");
goto ERROR;
+ }
+
+ // Install any additional packages
+ if (config.num_packages) {
+ r = pakfire_build_install(build, config.packages);
+ if (r)
+ goto ERROR;
+ }
+
+ // Run shell
+ r = pakfire_build_shell(build);
ERROR:
+ if (build)
+ pakfire_build_unref(build);
if (pakfire)
pakfire_unref(pakfire);
return pakfire_repo_walk(build->pakfire, __pakfire_build_setup_repo, build);
}
-/*
- Drops the user into a shell
-*/
-static int pakfire_build_shell(struct pakfire_build* build) {
- int r;
-
- // Export local repository if running in interactive mode
- r = pakfire_build_enable_repos(build);
- if (r)
- return r;
-
- // Run shell
- return pakfire_jail_shell(build->jail);
-}
-
static int pakfire_build_read_script(struct pakfire_build* build,
const char* filename, char** buffer, size_t* length) {
char path[PATH_MAX];
return r;
}
-static int pakfire_build_install(struct pakfire_build* build, const char** packages) {
+PAKFIRE_EXPORT int pakfire_build_install(struct pakfire_build* build, const char** packages) {
struct pakfire_transaction* transaction = NULL;
char* problems = NULL;
int r;
}
/*
- This is a convenience function that sets up a build environment and
- then drops the user into an interactive shell.
+ Drops the user into a shell
*/
-PAKFIRE_EXPORT int pakfire_shell(struct pakfire* pakfire, const char** packages, int flags) {
- struct pakfire_build* build = NULL;
+PAKFIRE_EXPORT int pakfire_build_shell(struct pakfire_build* build) {
int r;
- // Fetch the context
- struct pakfire_ctx* ctx = pakfire_ctx(pakfire);
-
- // Shells are always interactive
- flags |= PAKFIRE_BUILD_INTERACTIVE;
-
- // Create a new build environment
- r = pakfire_build_create(&build, pakfire, NULL, flags);
- if (r) {
- CTX_ERROR(ctx, "Could not create build: %m\n");
- goto ERROR;
- }
-
// Initialize the build environment
r = pakfire_build_init(build);
if (r)
- goto ERROR;
+ return r;
- // Install any additional packages
- if (packages) {
- r = pakfire_build_install(build, packages);
- if (r)
- goto ERROR;
- }
+ // Export local repository if running in interactive mode
+ r = pakfire_build_enable_repos(build);
+ if (r)
+ return r;
// Run shell
- r = pakfire_build_shell(build);
-
-ERROR:
- if (build)
- pakfire_build_unref(build);
- if (ctx)
- pakfire_ctx_unref(ctx);
-
- return r;
+ return pakfire_jail_shell(build->jail);
}
int pakfire_build_set_ccache_path(struct pakfire_build* build, const char* path);
int pakfire_build_set_target(struct pakfire_build* build, const char* target);
+int pakfire_build_shell(struct pakfire_build* build);
+
int pakfire_build_exec(struct pakfire_build* build, const char* path);
int pakfire_build_mkimage(struct pakfire_build* build,
int pakfire_build_clean(struct pakfire* pakfire, int flags);
-int pakfire_shell(struct pakfire* pakfire, const char** packages, int flags);
+int pakfire_build_install(struct pakfire_build* build, const char** packages);
#endif /* PAKFIRE_BUILD_H */