#include "build.h"
#include "color.h"
#include "command.h"
-#include "config.h"
#include "pakfire.h"
#include <pakfire/build.h>
BUILD_ENABLE_SNAPSHOT |
BUILD_ENABLE_TESTS,
};
- struct pakfire_config* config = NULL;
struct pakfire_build* build = NULL;
- int build_flags = 0;
+ int flags = 0;
int r;
// Parse the command line
// Use the snapshot?
if (local_args.flags & BUILD_ENABLE_SNAPSHOT)
- build_flags |= PAKFIRE_BUILD_ENABLE_SNAPSHOT;
+ flags |= PAKFIRE_BUILD_ENABLE_SNAPSHOT;
// Is the build interactive?
if (local_args.flags & BUILD_INTERACTIVE)
- build_flags |= PAKFIRE_BUILD_INTERACTIVE;
+ flags |= PAKFIRE_BUILD_INTERACTIVE;
// Enable ccache?
if (!(local_args.flags & BUILD_ENABLE_CCACHE))
- build_flags |= PAKFIRE_BUILD_DISABLE_CCACHE;
+ flags |= PAKFIRE_BUILD_DISABLE_CCACHE;
// Enable tests?
if (!(local_args.flags & BUILD_ENABLE_TESTS))
- build_flags |= PAKFIRE_BUILD_DISABLE_TESTS;
-
- // Read configuration
- r = cli_setup_config(&config, global_args);
- if (r < 0)
- goto ERROR;
+ flags |= PAKFIRE_BUILD_DISABLE_TESTS;
// Setup the build environment
- r = pakfire_build_create(&build, global_args->ctx, config, global_args->arch, local_args.id, build_flags);
- if (r) {
- fprintf(stderr, "Could not setup the build environment: %m\n");
+ r = cli_setup_build(&build, global_args, flags);
+ if (r < 0)
goto ERROR;
- }
// Set target
if (local_args.target) {
ERROR:
if (build)
pakfire_build_unref(build);
- if (config)
- pakfire_config_unref(config);
return r;
}
#include <pakfire/pakfire.h>
#include "command.h"
-#include "config.h"
#include "image_create.h"
#include "pakfire.h"
int cli_image_create(void* data, int argc, char* argv[]) {
struct cli_global_args* global_args = data;
struct cli_local_args local_args = {};
- struct pakfire_config* config = NULL;
struct pakfire_build* build = NULL;
FILE* f = NULL;
int r;
if (r)
goto ERROR;
- // Read configuration
- r = cli_setup_config(&config, global_args);
- if (r < 0)
- goto ERROR;
-
f = fopen(local_args.path, "w");
if (!f) {
fprintf(stderr, "Could not open %s: %m\n", local_args.path);
}
// Setup the build environment
- r = pakfire_build_create(&build, global_args->ctx, config, global_args->arch, NULL, 0);
- if (r)
+ r = cli_setup_build(&build, global_args, 0);
+ if (r < 0)
goto ERROR;
// Create the image
ERROR:
if (build)
pakfire_build_unref(build);
- if (config)
- pakfire_config_unref(config);
if (f)
fclose(f);
#include <errno.h>
#include <limits.h>
+#include <pakfire/build.h>
#include <pakfire/config.h>
#include <pakfire/pakfire.h>
#include <pakfire/repo.h>
#include "config.h"
#include "pakfire.h"
-#include "progressbar.h"
static void cli_set_repo_enabled(struct pakfire* pakfire, const char* name, int enabled) {
struct pakfire_repo* repo = NULL;
return r;
}
+
+int cli_setup_build(struct pakfire_build** build, struct cli_global_args* args, int flags) {
+ struct pakfire_config* config = NULL;
+ struct pakfire_build* b = NULL;
+ int r;
+
+ // Setup the configuration
+ r = cli_setup_config(&config, args);
+ if (r < 0)
+ goto ERROR;
+
+ // Setup the build environment
+ r = pakfire_build_create(&b, args->ctx, config, args->arch, NULL, flags);
+ if (r < 0) {
+ fprintf(stderr, "Could not setup the build environment: %s\n", strerror(-r));
+ goto ERROR;
+ }
+
+ // Return pointer
+ *build = b;
+
+ERROR:
+ if (config)
+ pakfire_config_unref(config);
+
+ return r;
+}
#ifndef PAKFIRE_CLI_PAKFIRE_H
#define PAKFIRE_CLI_PAKFIRE_H
+#include <pakfire/build.h>
#include <pakfire/config.h>
#include <pakfire/ctx.h>
#include <pakfire/pakfire.h>
int cli_setup_config(struct pakfire_config** config, struct cli_global_args* args);
int cli_setup_pakfire(struct pakfire** pakfire, struct cli_global_args* args);
+int cli_setup_build(struct pakfire_build** build, struct cli_global_args* args, int flags);
#endif /* PAKFIRE_CLI_PAKFIRE_H */
#include <argp.h>
#include "command.h"
-#include "config.h"
#include "pakfire.h"
#include "shell.h"
.packages = {},
.num_packages = 0,
};
- struct pakfire_config* config = NULL;
struct pakfire_build* build = NULL;
- int build_flags = PAKFIRE_BUILD_INTERACTIVE;
+ int flags = PAKFIRE_BUILD_INTERACTIVE;
int r;
// Parse the command line
// Enable snapshots?
if (local_args.flags & SHELL_ENABLE_SNAPSHOT)
- build_flags |= PAKFIRE_BUILD_ENABLE_SNAPSHOT;
-
- // Read configuration
- r = cli_setup_config(&config, global_args);
- if (r < 0)
- goto ERROR;
+ flags |= PAKFIRE_BUILD_ENABLE_SNAPSHOT;
// Setup the build environment
- r = pakfire_build_create(&build, global_args->ctx, config, global_args->arch, NULL, build_flags);
- if (r) {
- fprintf(stderr, "Could not setup the build environment: %m\n");
+ r = cli_setup_build(&build, global_args, flags);
+ if (r < 0)
goto ERROR;
- }
// Install any additional packages
if (local_args.num_packages) {
ERROR:
if (build)
pakfire_build_unref(build);
- if (config)
- pakfire_config_unref(config);
return r;
}