#define MAX_MAKEFILES 32
-struct config {
+struct cli_local_args {
const char* distro;
const char* id;
const char* target;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_DISTRO:
- config->distro = arg;
+ args->distro = arg;
break;
case OPT_DISABLE_CCACHE:
- config->flags &= ~BUILD_ENABLE_CCACHE;
+ args->flags &= ~BUILD_ENABLE_CCACHE;
break;
case OPT_DISABLE_SNAPSHOT:
- config->flags &= ~BUILD_ENABLE_SNAPSHOT;
+ args->flags &= ~BUILD_ENABLE_SNAPSHOT;
break;
case OPT_DISABLE_TESTS:
- config->flags &= ~BUILD_ENABLE_TESTS;
+ args->flags &= ~BUILD_ENABLE_TESTS;
break;
case OPT_ID:
- config->id = arg;
+ args->id = arg;
break;
case OPT_NON_INTERACTIVE:
- config->flags &= ~BUILD_INTERACTIVE;
+ args->flags &= ~BUILD_INTERACTIVE;
break;
case OPT_TARGET:
- config->target = arg;
+ args->target = arg;
break;
case ARGP_KEY_ARG:
- if (config->num_makefiles >= MAX_MAKEFILES)
+ if (args->num_makefiles >= MAX_MAKEFILES)
return -ENOBUFS;
- config->makefiles[config->num_makefiles++] = arg;
+ args->makefiles[args->num_makefiles++] = arg;
break;
default:
}
int cli_build(void* data, int argc, char* argv[]) {
- struct cli_config* cli_config = data;
- struct pakfire_build* build = NULL;
- struct pakfire_config* c = NULL;
- struct config config = {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {
.distro = NULL,
.id = NULL,
.target = NULL,
BUILD_ENABLE_SNAPSHOT |
BUILD_ENABLE_TESTS,
};
+ struct pakfire_config* config = NULL;
+ struct pakfire_build* build = NULL;
int build_flags = 0;
int r;
// Parse the command line
- r = cli_parse(options, NULL, NULL, NULL, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, NULL, NULL, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Replace the logger
- pakfire_ctx_set_log_callback(cli_config->ctx, log_callback, NULL);
+ pakfire_ctx_set_log_callback(global_args->ctx, log_callback, NULL);
// Use the snapshot?
- if (config.flags & BUILD_ENABLE_SNAPSHOT)
+ if (local_args.flags & BUILD_ENABLE_SNAPSHOT)
build_flags |= PAKFIRE_BUILD_ENABLE_SNAPSHOT;
// Is the build interactive?
- if (config.flags & BUILD_INTERACTIVE)
+ if (local_args.flags & BUILD_INTERACTIVE)
build_flags |= PAKFIRE_BUILD_INTERACTIVE;
// Enable ccache?
- if (!(config.flags & BUILD_ENABLE_CCACHE))
+ if (!(local_args.flags & BUILD_ENABLE_CCACHE))
build_flags |= PAKFIRE_BUILD_DISABLE_CCACHE;
// Enable tests?
- if (!(config.flags & BUILD_ENABLE_TESTS))
+ if (!(local_args.flags & BUILD_ENABLE_TESTS))
build_flags |= PAKFIRE_BUILD_DISABLE_TESTS;
// Read distro configuration
- r = cli_read_distro_config(&c, cli_config->ctx, config.distro);
+ r = cli_read_distro_config(&config, global_args->ctx, local_args.distro);
if (r < 0)
goto ERROR;
// Setup the build environment
- r = pakfire_build_create(&build, cli_config->ctx, c, cli_config->arch, config.id, build_flags);
+ 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");
goto ERROR;
}
// Set target
- if (config.target) {
- r = pakfire_build_set_target(build, config.target);
+ if (local_args.target) {
+ r = pakfire_build_set_target(build, local_args.target);
if (r) {
- fprintf(stderr, "Could not set target directory %s: %m\n", config.target);
+ fprintf(stderr, "Could not set target directory %s: %m\n", local_args.target);
goto ERROR;
}
}
// Process all packages
- for (unsigned int i = 0; i < config.num_makefiles; i++) {
+ for (unsigned int i = 0; i < local_args.num_makefiles; i++) {
// Run the build
- r = pakfire_build_exec(build, config.makefiles[i]);
+ r = pakfire_build_exec(build, local_args.makefiles[i]);
if (r) {
- fprintf(stderr, "Could not build %s\n", config.makefiles[i]);
+ fprintf(stderr, "Could not build %s\n", local_args.makefiles[i]);
goto ERROR;
}
}
ERROR:
if (build)
pakfire_build_unref(build);
- if (c)
- pakfire_config_unref(c);
+ if (config)
+ pakfire_config_unref(config);
return r;
}
" previous builds.";
int cli_clean(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
struct pakfire* pakfire = NULL;
int r;
- struct cli_config* config = data;
-
// Parse the command line
r = cli_parse(NULL, NULL, NULL, doc, NULL, 0, argc, argv, NULL);
if (r)
goto ERROR;
// Setup Pakfire
- r = cli_setup_pakfire(&pakfire, config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
#define MAX_PACKAGES 32
#define MAX_MAKEFILES 32
-struct config {
+struct cli_local_args {
const char* repo;
int flags;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_ARCH:
- if (config->num_arches >= MAX_ARCHES)
+ if (args->num_arches >= MAX_ARCHES)
return -ENOBUFS;
- config->arches[config->num_arches++] = arg;
+ args->arches[args->num_arches++] = arg;
break;
case OPT_DISABLE_TESTS:
- config->flags |= PAKFIRE_BUILD_DISABLE_TESTS;
+ args->flags |= PAKFIRE_BUILD_DISABLE_TESTS;
break;
case OPT_REPO:
- config->repo = arg;
+ args->repo = arg;
break;
case ARGP_KEY_ARG:
- if (config->num_packages >= MAX_PACKAGES)
+ if (args->num_packages >= MAX_PACKAGES)
return -ENOBUFS;
- config->packages[config->num_packages++] = arg;
+ args->packages[args->num_packages++] = arg;
break;
default:
}
int cli_client_build(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire_buildservice* service = NULL;
- struct config config = {};
char* upload = NULL;
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, global_args->ctx);
if (r)
goto ERROR;
// Upload all packages
- for (unsigned int i = 0; i < config.num_packages; i++) {
- r = pakfire_buildservice_upload(service, config.packages[i], NULL, &upload);
+ for (unsigned int i = 0; i < local_args.num_packages; i++) {
+ r = pakfire_buildservice_upload(service, local_args.packages[i], NULL, &upload);
if (r)
goto ERROR;
// Store the upload ID
- config.uploads[config.num_uploads++] = upload;
+ local_args.uploads[local_args.num_uploads++] = upload;
}
// No uploads
- if (!config.num_uploads)
+ if (!local_args.num_uploads)
goto ERROR;
// Build all the things
- for (unsigned int i = 0; i < config.num_uploads; i++) {
- r = pakfire_buildservice_build(service, config.uploads[i], config.repo,
- config.arches, config.flags);
+ for (unsigned int i = 0; i < local_args.num_uploads; i++) {
+ r = pakfire_buildservice_build(service, local_args.uploads[i], local_args.repo,
+ local_args.arches, local_args.flags);
if (r)
goto ERROR;
// Free the upload
- free(config.uploads[i]);
- config.uploads[i] = NULL;
+ free(local_args.uploads[i]);
+ local_args.uploads[i] = NULL;
}
ERROR:
// Delete & free all uploads that could not be processed
- for (unsigned int i = 0; i < config.num_uploads; i++) {
- if (config.uploads[i]) {
- pakfire_buildservice_delete_upload(service, config.uploads[i]);
- free(config.uploads[i]);
+ for (unsigned int i = 0; i < local_args.num_uploads; i++) {
+ if (local_args.uploads[i]) {
+ pakfire_buildservice_delete_upload(service, local_args.uploads[i]);
+ free(local_args.uploads[i]);
}
}
if (service)
#define MAX_MAKEFILES 32
-struct config {
+struct cli_local_args {
const char* resultdir;
// Makefiles
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (config->num_makefiles >= MAX_MAKEFILES)
+ if (args->num_makefiles >= MAX_MAKEFILES)
return -ENOBUFS;
- config->makefiles[config->num_makefiles++] = arg;
+ args->makefiles[args->num_makefiles++] = arg;
break;
default:
}
int cli_dist(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
- struct config config = {
- .resultdir = NULL,
- };
char cwd[PATH_MAX];
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Set result directory to PWD
- if (!config.resultdir)
- config.resultdir = getcwd(cwd, sizeof(cwd));
+ if (!local_args.resultdir)
+ local_args.resultdir = getcwd(cwd, sizeof(cwd));
// Setup pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
// Process all packages
- for (unsigned int i = 0; i < config.num_makefiles; i++) {
- r = pakfire_dist(pakfire, config.makefiles[i], config.resultdir, NULL);
+ for (unsigned int i = 0; i < local_args.num_makefiles; i++) {
+ r = pakfire_dist(pakfire, local_args.makefiles[i], local_args.resultdir, NULL);
if (r) {
- fprintf(stderr, "Could not dist %s\n", config.makefiles[i]);
+ fprintf(stderr, "Could not dist %s\n", local_args.makefiles[i]);
goto ERROR;
}
}
#include "image_create.h"
#include "pakfire.h"
-struct config {
+struct cli_local_args {
const char* distro;
const char* type;
const char* path;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_DISTRO:
- config->distro = arg;
+ args->distro = arg;
break;
case ARGP_KEY_ARG:
- if (!config->type)
- config->type = arg;
+ if (!args->type)
+ args->type = arg;
- else if (!config->path)
- config->path = arg;
+ else if (!args->path)
+ args->path = arg;
break;
}
int cli_image_create(void* data, int argc, char* argv[]) {
- struct cli_config* cli_config = data;
- struct pakfire_config* c = NULL;
- struct pakfire_build* build = NULL;
- FILE* f = NULL;
- int r;
-
- struct config config = {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {
.type = NULL,
.path = NULL,
};
+ struct pakfire_config* config = NULL;
+ struct pakfire_build* build = NULL;
+ FILE* f = NULL;
+ int r;
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Read the distro configuration
- r = cli_read_distro_config(&c, cli_config->ctx, config.distro);
+ r = cli_read_distro_config(&config, global_args->ctx, local_args.distro);
if (r < 0)
goto ERROR;
- f = fopen(config.path, "w");
+ f = fopen(local_args.path, "w");
if (!f) {
- fprintf(stderr, "Could not open %s: %m\n", config.path);
+ fprintf(stderr, "Could not open %s: %m\n", local_args.path);
r = -errno;
goto ERROR;
}
// Setup the build environment
- r = pakfire_build_create(&build, cli_config->ctx, c, cli_config->arch, NULL, 0);
+ r = pakfire_build_create(&build, global_args->ctx, config, global_args->arch, NULL, 0);
if (r)
goto ERROR;
// Create the image
- r = pakfire_build_mkimage(build, config.type, f);
+ r = pakfire_build_mkimage(build, local_args.type, f);
if (r)
goto ERROR;
ERROR:
if (build)
pakfire_build_unref(build);
- if (c)
- pakfire_config_unref(c);
+ if (config)
+ pakfire_config_unref(config);
if (f)
fclose(f);
#define MAX_PACKAGES 128
-struct config {
+struct cli_local_args {
int dump_flags;
// Packages
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_DEVEL:
- config->dump_flags |= PAKFIRE_PKG_DUMP_LONG;
+ args->dump_flags |= PAKFIRE_PKG_DUMP_LONG;
break;
case OPT_FILELIST:
- config->dump_flags |= PAKFIRE_PKG_DUMP_FILELIST;
+ args->dump_flags |= PAKFIRE_PKG_DUMP_FILELIST;
break;
case ARGP_KEY_ARG:
- if (config->num_packages >= MAX_PACKAGES)
+ if (args->num_packages >= MAX_PACKAGES)
return -ENOBUFS;
- config->packages[config->num_packages++] = arg;
+ args->packages[args->num_packages++] = arg;
break;
default:
}
int cli_info(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
struct pakfire_packagelist* list = NULL;
- struct config config = {
- .dump_flags = 0,
- };
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup Pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
// Allocate a new packagelist
- r = pakfire_packagelist_create(&list, cli_config->ctx);
+ r = pakfire_packagelist_create(&list, global_args->ctx);
if (r)
goto ERROR;
// Perform search
- for (unsigned int i = 0; i < config.num_packages; i++) {
- r = pakfire_search(pakfire, config.packages[i], PAKFIRE_SEARCH_NAME_ONLY, list);
+ for (unsigned int i = 0; i < local_args.num_packages; i++) {
+ r = pakfire_search(pakfire, local_args.packages[i], PAKFIRE_SEARCH_NAME_ONLY, list);
if (r)
goto ERROR;
}
// Dump the packagelist
- r = cli_dump_packagelist(list, config.dump_flags);
+ r = cli_dump_packagelist(list, local_args.dump_flags);
ERROR:
if (list)
#define MAX_PACKAGES 128
-struct config {
+struct cli_local_args {
int transaction_flags;
int job_flags;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_BEST:
- config->job_flags |= PAKFIRE_JOB_BEST;
+ args->job_flags |= PAKFIRE_JOB_BEST;
break;
case OPT_ALLOW_DOWNGRADE:
- config->transaction_flags |= PAKFIRE_TRANSACTION_ALLOW_DOWNGRADE;
+ args->transaction_flags |= PAKFIRE_TRANSACTION_ALLOW_DOWNGRADE;
break;
case OPT_ALLOW_UNINSTALL:
- config->transaction_flags |= PAKFIRE_TRANSACTION_ALLOW_UNINSTALL;
+ args->transaction_flags |= PAKFIRE_TRANSACTION_ALLOW_UNINSTALL;
break;
case OPT_WITHOUT_RECOMMENDED:
- config->transaction_flags |= PAKFIRE_TRANSACTION_WITHOUT_RECOMMENDED;
+ args->transaction_flags |= PAKFIRE_TRANSACTION_WITHOUT_RECOMMENDED;
break;
case ARGP_KEY_ARG:
- if (config->num_packages >= MAX_PACKAGES)
+ if (args->num_packages >= MAX_PACKAGES)
return -ENOBUFS;
- config->packages[config->num_packages++] = arg;
+ args->packages[args->num_packages++] = arg;
break;
default:
}
static int __cli_install(struct pakfire_transaction* transaction, int argc, char* argv[], void* data) {
- struct config* config = (struct config*)data;
+ struct cli_local_args* args = data;
int r;
// Add the remaining command line options as packages
- for (unsigned int i = 0; i < config->num_packages; i++) {
+ for (unsigned int i = 0; i < args->num_packages; i++) {
r = pakfire_transaction_request(transaction,
- PAKFIRE_JOB_INSTALL, config->packages[i], config->job_flags);
+ PAKFIRE_JOB_INSTALL, args->packages[i], args->job_flags);
if (r) {
fprintf(stderr, "Could not find '%s': %m\n", argv[i]);
return r;
}
int cli_install(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup Pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
- r = cli_transaction(pakfire, argc, argv, config.transaction_flags, __cli_install, &config);
+ r = cli_transaction(pakfire, argc, argv, local_args.transaction_flags, __cli_install, &local_args);
ERROR:
if (pakfire)
#define MAX_ARCHIVES 128
-struct config {
+struct cli_local_args {
// Archives
char* archives[MAX_ARCHIVES];
unsigned int num_archives;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (config->num_archives >= MAX_ARCHIVES)
+ if (args->num_archives >= MAX_ARCHIVES)
return -ENOBUFS;
- config->archives[config->num_archives++] = arg;
+ args->archives[args->num_archives++] = arg;
break;
default:
}
int cli_lint(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
int r;
- struct cli_config* cli_config = data;
-
- struct config config = {};
-
// Parse the command line
- r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup Pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
// Lint all archives
- for (unsigned int i = 0; i < config.num_archives; i++) {
- r = do_lint(pakfire, config.archives[i]);
+ for (unsigned int i = 0; i < local_args.num_archives; i++) {
+ r = do_lint(pakfire, local_args.archives[i]);
if (r < 0)
goto ERROR;
}
pakfire_repo_unref(repo);
}
-int cli_setup_pakfire(struct pakfire** pakfire, struct cli_config* config) {
- struct pakfire_config* c = NULL;
+int cli_setup_pakfire(struct pakfire** pakfire, struct cli_global_args* args) {
+ struct pakfire_config* config = NULL;
struct pakfire* p = NULL;
FILE* f = NULL;
int r;
// Create a new config object
- r = pakfire_config_create(&c);
+ r = pakfire_config_create(&config);
if (r < 0)
goto ERROR;
// Open the regular configuration
- if (config->config) {
- r = pakfire_config_read_path(c, config->config);
+ if (args->config) {
+ r = pakfire_config_read_path(config, args->config);
if (r < 0)
goto ERROR;
}
// Initialize Pakfire
- r = pakfire_create(&p, config->ctx, c, config->root, config->arch, config->flags);
+ r = pakfire_create(&p, args->ctx, config, args->root, args->arch, args->flags);
if (r < 0) {
fprintf(stderr, "Could not initialize Pakfire: %s\n", strerror(-r));
goto ERROR;
}
// Enable repositories
- for (unsigned int i = 0; i < config->num_enable_repos; i++)
- cli_set_repo_enabled(p, config->enable_repos[i], 1);
+ for (unsigned int i = 0; i < args->num_enable_repos; i++)
+ cli_set_repo_enabled(p, args->enable_repos[i], 1);
// Disable repositories
- for (unsigned int i = 0; i < config->num_disable_repos; i++)
- cli_set_repo_enabled(p, config->disable_repos[i], 0);
+ for (unsigned int i = 0; i < args->num_disable_repos; i++)
+ cli_set_repo_enabled(p, args->disable_repos[i], 0);
// Return pointer
*pakfire = p;
ERROR:
- if (c)
- pakfire_config_unref(c);
+ if (config)
+ pakfire_config_unref(config);
if (f)
fclose(f);
#define MAX_REPOS 16
-struct cli_config {
+struct cli_global_args {
struct pakfire_ctx* ctx;
const char* distro;
unsigned int num_disable_repos;
};
-int cli_setup_pakfire(struct pakfire** pakfire, struct cli_config* config);
+int cli_setup_pakfire(struct pakfire** pakfire, struct cli_global_args* args);
#endif /* PAKFIRE_CLI_PAKFIRE_H */
#define MAX_PATTERNS 256
-struct config {
+struct cli_local_args {
char* patterns[MAX_PATTERNS];
unsigned int num_patterns;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (config->num_patterns >= MAX_PATTERNS)
+ if (args->num_patterns >= MAX_PATTERNS)
return -ENOBUFS;
- config->patterns[config->num_patterns++] = arg;
+ args->patterns[args->num_patterns++] = arg;
break;
default:
}
int cli_provides(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
struct pakfire_packagelist* list = NULL;
int r;
- struct cli_config* cli_config = data;
-
- struct config config = {};
-
// Parse the command line
- r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
// Allocate a new packagelist
- r = pakfire_packagelist_create(&list, cli_config->ctx);
+ r = pakfire_packagelist_create(&list, global_args->ctx);
if (r)
goto ERROR;
// Perform search
- for (unsigned int i = 0; i < config.num_patterns; i++) {
- r = pakfire_whatprovides(pakfire, config.patterns[i], 0, list);
+ for (unsigned int i = 0; i < local_args.num_patterns; i++) {
+ r = pakfire_whatprovides(pakfire, local_args.patterns[i], 0, list);
if (r)
goto ERROR;
}
#define MAX_PACKAGES 128
-struct config {
+struct cli_local_args {
int job_flags;
// Packages
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_KEEP_DEPENDENCIES:
- config->job_flags |= PAKFIRE_JOB_KEEP_DEPS;
+ args->job_flags |= PAKFIRE_JOB_KEEP_DEPS;
break;
case ARGP_KEY_ARG:
- if (config->num_packages >= MAX_PACKAGES)
+ if (args->num_packages >= MAX_PACKAGES)
return -ENOBUFS;
- config->packages[config->num_packages++] = arg;
+ args->packages[args->num_packages++] = arg;
break;
default:
}
static int __cli_remove(struct pakfire_transaction* transaction, int argc, char* argv[], void* data) {
- struct config* config = (struct config*)data;
+ struct cli_local_args* args = data;
int r;
- for (unsigned int i = 0; i < config->num_packages; i++) {
+ for (unsigned int i = 0; i < args->num_packages; i++) {
r = pakfire_transaction_request(transaction,
- PAKFIRE_JOB_ERASE, config->packages[i], config->job_flags);
+ PAKFIRE_JOB_ERASE, args->packages[i], args->job_flags);
if (r) {
fprintf(stderr, "Could not find '%s': %m\n", argv[i]);
return r;
}
int cli_remove(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup Pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
- r = cli_transaction(pakfire, argc, argv, 0, __cli_remove, &config);
+ r = cli_transaction(pakfire, argc, argv, 0, __cli_remove, &local_args);
ERROR:
if (pakfire)
#define MAX_PACKAGES 1024
-struct config {
+struct cli_local_args {
const char* path;
const char* key;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_KEY:
- config->key = arg;
+ args->key = arg;
break;
case ARGP_KEY_ARG:
- if (!config->path)
- config->path = arg;
+ if (!args->path)
+ args->path = arg;
- else if (config->num_packages >= MAX_PACKAGES)
+ else if (args->num_packages >= MAX_PACKAGES)
return -ENOBUFS;
else
- config->packages[config->num_packages++] = arg;
+ args->packages[args->num_packages++] = arg;
break;
default:
}
int cli_repo_compose(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
struct pakfire_key* key = NULL;
int r;
- struct cli_config* cli_config = data;
-
- struct config config = {
- .path = NULL,
- .key = NULL,
- };
-
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
// Read the key (if any)
- if (config.key) {
- r = cli_import_key(&key, cli_config->ctx, config.key);
+ if (local_args.key) {
+ r = cli_import_key(&key, global_args->ctx, local_args.key);
if (r)
goto ERROR;
}
// Write the repository
- r = pakfire_repo_compose(pakfire, config.path, key, (const char**)config.packages);
+ r = pakfire_repo_compose(pakfire, local_args.path, key, (const char**)local_args.packages);
ERROR:
if (key)
static const char* doc = "Create a new repository";
-struct config {
+struct cli_local_args {
const char* distro;
const char* name;
const char* description;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_DESCRIPTION:
- config->description = arg;
+ args->description = arg;
break;
case ARGP_KEY_ARG:
- if (!config->distro)
- config->distro = arg;
+ if (!args->distro)
+ args->distro = arg;
- else if (!config->name)
- config->name = arg;
+ else if (!args->name)
+ args->name = arg;
else
argp_usage(state);
}
int cli_repo_create(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire_buildservice* service = NULL;
struct json_object* repo = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, global_args->ctx);
if (r)
goto ERROR;
// List repos
r = pakfire_buildservice_create_repo(service,
- config.distro, config.name, config.description, &repo);
+ local_args.distro, local_args.name, local_args.description, &repo);
if (r)
goto ERROR;
static const char* doc = "Delete a repository";
-struct config {
+struct cli_local_args {
const char* distro;
const char* name;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (!config->distro)
- config->distro = arg;
+ if (!args->distro)
+ args->distro = arg;
- else if (!config->name)
- config->name = arg;
+ else if (!args->name)
+ args->name = arg;
else
argp_usage(state);
}
int cli_repo_delete(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire_buildservice* service = NULL;
struct json_object* repo = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, global_args->ctx);
if (r)
goto ERROR;
// Delete the repository
- r = pakfire_buildservice_delete_repo(service, config.distro, config.name);
+ r = pakfire_buildservice_delete_repo(service, local_args.distro, local_args.name);
if (r)
goto ERROR;
static const char* doc = "Lists all repositories";
-struct config {
+struct cli_local_args {
const char* distro;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (!config->distro)
- config->distro = arg;
+ if (!args->distro)
+ args->distro = arg;
else
argp_usage(state);
}
int cli_repo_list(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire_buildservice* service = NULL;
struct json_object* repos = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(NULL, NULL, NULL, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, NULL, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, global_args->ctx);
if (r)
goto ERROR;
// List repos
- r = pakfire_buildservice_list_repos(service, config.distro, &repos);
+ r = pakfire_buildservice_list_repos(service, local_args.distro, &repos);
if (r)
goto ERROR;
static const char* doc = "Lists all repositories";
-struct config {
+struct cli_local_args {
const char* distro;
const char* name;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (!config->distro)
- config->distro = arg;
+ if (!args->distro)
+ args->distro = arg;
- else if (!config->name)
- config->name = arg;
+ else if (!args->name)
+ args->name = arg;
else
argp_usage(state);
}
int cli_repo_show(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire_buildservice* service = NULL;
struct json_object* repo = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(NULL, NULL, NULL, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, NULL, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, global_args->ctx);
if (r)
goto ERROR;
// List repos
- r = pakfire_buildservice_get_repo(service, config.distro, config.name, &repo);
+ r = pakfire_buildservice_get_repo(service, local_args.distro, local_args.name, &repo);
if (r)
goto ERROR;
static const char* doc = "List all available repositories";
int cli_repolist(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
struct pakfire* pakfire = NULL;
struct pakfire_repolist* list = NULL;
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
r = cli_parse(NULL, NULL, NULL, doc, NULL, 0, argc, argv, NULL);
if (r)
goto ERROR;
// Setup Pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
#define MAX_PATTERNS 256
-struct config {
+struct cli_local_args {
char* patterns[MAX_PATTERNS];
unsigned int num_patterns;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (config->num_patterns >= MAX_PATTERNS)
+ if (args->num_patterns >= MAX_PATTERNS)
return -ENOBUFS;
- config->patterns[config->num_patterns++] = arg;
+ args->patterns[args->num_patterns++] = arg;
break;
default:
}
int cli_requires(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
struct pakfire_packagelist* list = NULL;
int r;
- struct cli_config* cli_config = data;
-
- struct config config = {};
-
// Parse the command line
- r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
// Allocate a new packagelist
- r = pakfire_packagelist_create(&list, cli_config->ctx);
+ r = pakfire_packagelist_create(&list, global_args->ctx);
if (r)
goto ERROR;
// Perform search
- for (unsigned int i = 0; i < config.num_patterns; i++) {
- r = pakfire_whatrequires(pakfire, config.patterns[i], 0, list);
+ for (unsigned int i = 0; i < local_args.num_patterns; i++) {
+ r = pakfire_whatrequires(pakfire, local_args.patterns[i], 0, list);
if (r)
goto ERROR;
}
#define MAX_PATTERNS 256
-struct config {
+struct cli_local_args {
char* patterns[MAX_PATTERNS];
unsigned int num_patterns;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (config->num_patterns >= MAX_PATTERNS)
+ if (args->num_patterns >= MAX_PATTERNS)
return -ENOBUFS;
- config->patterns[config->num_patterns++] = arg;
+ args->patterns[args->num_patterns++] = arg;
break;
default:
}
int cli_search(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
struct pakfire_packagelist* list = NULL;
int r;
- struct cli_config* cli_config = data;
-
- struct config config = {};
-
// Parse the command line
- r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
// Allocate a new packagelist
- r = pakfire_packagelist_create(&list, cli_config->ctx);
+ r = pakfire_packagelist_create(&list, global_args->ctx);
if (r)
goto ERROR;
// Perform search
- for (unsigned int i = 0; i < config.num_patterns; i++) {
- r = pakfire_search(pakfire, config.patterns[i], 0, list);
+ for (unsigned int i = 0; i < local_args.num_patterns; i++) {
+ r = pakfire_search(pakfire, local_args.patterns[i], 0, list);
if (r)
goto ERROR;
}
#define MAX_ARGS 128
#define MAX_PACKAGES 128
-struct config {
+struct cli_local_args {
const char* distro;
enum {
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_DISTRO:
- config->distro = arg;
+ args->distro = arg;
break;
case OPT_DISABLE_SNAPSHOT:
- config->flags &= ~SHELL_ENABLE_SNAPSHOT;
+ args->flags &= ~SHELL_ENABLE_SNAPSHOT;
break;
case OPT_INSTALL:
- if (config->num_packages >= MAX_PACKAGES)
+ if (args->num_packages >= MAX_PACKAGES)
return -ENOBUFS;
- config->packages[config->num_packages++] = arg;
+ args->packages[args->num_packages++] = arg;
break;
case ARGP_KEY_ARG:
- if (config->argc >= MAX_ARGS)
+ if (args->argc >= MAX_ARGS)
return -ENOBUFS;
- config->argv[config->argc++] = arg;
+ args->argv[args->argc++] = arg;
break;
default:
}
int cli_shell(void* data, int argc, char* argv[]) {
- struct cli_config* cli_config = data;
- struct pakfire_config* c = NULL;
- struct pakfire_build* build = NULL;
- int build_flags = PAKFIRE_BUILD_INTERACTIVE;
- int r;
-
- struct config config = {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {
.flags = SHELL_ENABLE_SNAPSHOT,
.argv = {},
.argc = 0,
.packages = {},
.num_packages = 0,
};
+ struct pakfire_config* config = NULL;
+ struct pakfire_build* build = NULL;
+ int build_flags = PAKFIRE_BUILD_INTERACTIVE;
+ int r;
// Parse the command line
- r = cli_parse(options, NULL, NULL, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, NULL, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Enable snapshots?
- if (config.flags & SHELL_ENABLE_SNAPSHOT)
+ if (local_args.flags & SHELL_ENABLE_SNAPSHOT)
build_flags |= PAKFIRE_BUILD_ENABLE_SNAPSHOT;
// Read distro configuration
- r = cli_read_distro_config(&c, cli_config->ctx, config.distro);
+ r = cli_read_distro_config(&config, global_args->ctx, local_args.distro);
if (r < 0)
goto ERROR;
// Setup the build environment
- r = pakfire_build_create(&build, cli_config->ctx, c, cli_config->arch, NULL, build_flags);
+ 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");
goto ERROR;
}
// Install any additional packages
- if (config.num_packages) {
- r = pakfire_build_install(build, config.packages);
+ if (local_args.num_packages) {
+ r = pakfire_build_install(build, local_args.packages);
if (r)
goto ERROR;
}
// Run the command
- r = pakfire_build_shell(build, (config.argc) ? config.argv : NULL);
+ r = pakfire_build_shell(build, (local_args.argc) ? local_args.argv : NULL);
ERROR:
if (build)
pakfire_build_unref(build);
- if (c)
- pakfire_config_unref(c);
+ if (config)
+ pakfire_config_unref(config);
return r;
}
static const char* doc = "Update the snapshot";
int cli_snapshot_update(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
struct pakfire* pakfire = NULL;
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
r = cli_parse(NULL, NULL, NULL, doc, NULL, 0, argc, argv, NULL);
if (r)
goto ERROR;
// Setup pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
static const char* doc = "Synchronize packages";
-struct config {
+struct cli_local_args {
int job_flags;
};
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_KEEP_ORPHANED:
- config->job_flags |= PAKFIRE_JOB_KEEP_ORPHANED;
+ args->job_flags |= PAKFIRE_JOB_KEEP_ORPHANED;
break;
default:
}
static int __cli_sync(struct pakfire_transaction* transaction, int argc, char* argv[], void* data) {
- struct config* config = (struct config*)data;
+ struct cli_local_args* args = data;
int r;
// Request sync
- r = pakfire_transaction_request(transaction, PAKFIRE_JOB_SYNC, NULL, config->job_flags);
+ r = pakfire_transaction_request(transaction, PAKFIRE_JOB_SYNC, NULL, args->job_flags);
if (r) {
fprintf(stderr, "Could not request job: %m\n");
return r;
}
int cli_sync(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup Pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
- r = cli_transaction(pakfire, argc, argv, 0, __cli_sync, &config);
+ r = cli_transaction(pakfire, argc, argv, 0, __cli_sync, &local_args);
ERROR:
if (pakfire)
#define MAX_EXCLUDES 128
#define MAX_PACKAGES 128
-struct config {
+struct cli_local_args {
int transaction_flags;
// Excludes
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case OPT_ALLOW_DOWNGRADE:
- config->transaction_flags |= PAKFIRE_TRANSACTION_ALLOW_DOWNGRADE;
+ args->transaction_flags |= PAKFIRE_TRANSACTION_ALLOW_DOWNGRADE;
break;
case OPT_ALLOW_UNINSTALL:
- config->transaction_flags |= PAKFIRE_TRANSACTION_ALLOW_UNINSTALL;
+ args->transaction_flags |= PAKFIRE_TRANSACTION_ALLOW_UNINSTALL;
break;
case 'x':
- if (config->num_excludes >= MAX_EXCLUDES)
+ if (args->num_excludes >= MAX_EXCLUDES)
return -ENOBUFS;
- config->excludes[config->num_excludes++] = arg;
+ args->excludes[args->num_excludes++] = arg;
break;
case ARGP_KEY_ARG:
- if (config->num_packages >= MAX_PACKAGES)
+ if (args->num_packages >= MAX_PACKAGES)
return -ENOBUFS;
- config->packages[config->num_packages++] = arg;
+ args->packages[args->num_packages++] = arg;
break;
default:
}
static int __cli_update(struct pakfire_transaction* transaction, int argc, char* argv[], void* data) {
- struct config* config = (struct config*)data;
+ struct cli_local_args* args = data;
int r;
// Exclude any packages
- for (unsigned int i = 0; i < config->num_excludes; i++) {
- r = pakfire_transaction_request(transaction, PAKFIRE_JOB_LOCK, config->excludes[i], 0);
+ for (unsigned int i = 0; i < args->num_excludes; i++) {
+ r = pakfire_transaction_request(transaction, PAKFIRE_JOB_LOCK, args->excludes[i], 0);
if (r)
return r;
}
// Did the user pass any packages?
if (argc) {
// Add the remaining command line options as packages
- for (unsigned int i = 0; i < config->num_packages; i++) {
+ for (unsigned int i = 0; i < args->num_packages; i++) {
r = pakfire_transaction_request(transaction,
- PAKFIRE_JOB_UPDATE, config->packages[i], 0);
+ PAKFIRE_JOB_UPDATE, args->packages[i], 0);
if (r) {
fprintf(stderr, "Could not find '%s': %m\n", argv[i]);
return r;
}
int cli_update(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire* pakfire = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(options, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Setup Pakfire
- r = cli_setup_pakfire(&pakfire, cli_config);
+ r = cli_setup_pakfire(&pakfire, global_args);
if (r)
goto ERROR;
- r = cli_transaction(pakfire, argc, argv, config.transaction_flags, __cli_update, &config);
+ r = cli_transaction(pakfire, argc, argv, local_args.transaction_flags, __cli_update, &local_args);
ERROR:
if (pakfire)
#define MAX_FILES 32
-struct config {
+struct cli_local_args {
const char* files[MAX_FILES];
unsigned int num_files;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (config->num_files >= MAX_FILES)
+ if (args->num_files >= MAX_FILES)
return -ENOBUFS;
- config->files[config->num_files++] = arg;
+ args->files[args->num_files++] = arg;
break;
default:
}
int cli_upload_create(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire_buildservice* service = NULL;
- struct config config = {};
char* uuid = NULL;
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, global_args->ctx);
if (r)
goto ERROR;
// List uploads
- for (unsigned int i = 0; i < config.num_files; i++) {
- r = pakfire_buildservice_upload(service, config.files[i], NULL, &uuid);
+ for (unsigned int i = 0; i < local_args.num_files; i++) {
+ r = pakfire_buildservice_upload(service, local_args.files[i], NULL, &uuid);
if (r)
goto ERROR;
if (uuid) {
- printf("Uploaded %s as %s\n", config.files[i], uuid);
+ printf("Uploaded %s as %s\n", local_args.files[i], uuid);
free(uuid);
}
}
#define MAX_UPLOADS 32
-struct config {
+struct cli_local_args {
const char* uploads[MAX_UPLOADS];
unsigned int num_uploads;
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct config* config = data;
+ struct cli_local_args* args = data;
switch (key) {
case ARGP_KEY_ARG:
- if (config->num_uploads >= MAX_UPLOADS)
+ if (args->num_uploads >= MAX_UPLOADS)
return -ENOBUFS;
// Validate the UUID
if (!pakfire_uuid_is_valid(arg))
argp_error(state, "Invalid UUID");
- config->uploads[config->num_uploads++] = arg;
+ args->uploads[args->num_uploads++] = arg;
break;
default:
}
int cli_upload_delete(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
+ struct cli_local_args local_args = {};
struct pakfire_buildservice* service = NULL;
- struct config config = {};
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
- r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &config);
+ r = cli_parse(NULL, NULL, args_doc, doc, parse, 0, argc, argv, &local_args);
if (r)
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, global_args->ctx);
if (r)
goto ERROR;
// Delete uploads
- for (unsigned int i = 0; i < config.num_uploads; i++) {
- r = pakfire_buildservice_delete_upload(service, config.uploads[i]);
+ for (unsigned int i = 0; i < local_args.num_uploads; i++) {
+ r = pakfire_buildservice_delete_upload(service, local_args.uploads[i]);
if (r)
goto ERROR;
}
static const char* doc = "Lists all uploads";
int cli_upload_list(void* data, int argc, char* argv[]) {
+ struct cli_global_args* global_args = data;
struct pakfire_buildservice* service = NULL;
struct json_object* uploads = NULL;
int r;
- struct cli_config* cli_config = data;
-
// Parse the command line
r = cli_parse(NULL, NULL, NULL, doc, NULL, 0, argc, argv, NULL);
if (r)
goto ERROR;
// Connect to the build service
- r = pakfire_buildservice_create(&service, cli_config->ctx);
+ r = pakfire_buildservice_create(&service, global_args->ctx);
if (r)
goto ERROR;
"snapshot [COMMAND...]";
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct cli_config* config = data;
+ struct cli_global_args* args = data;
switch (key) {
case OPT_ARCH:
if (!pakfire_arch_is_supported_by_host(arg))
argp_failure(state, EXIT_FAILURE, 0, "Unsupported architecture: %s", arg);
- config->arch = arg;
+ args->arch = arg;
break;
case OPT_DEBUG:
- pakfire_ctx_set_log_level(config->ctx, LOG_DEBUG);
+ pakfire_ctx_set_log_level(args->ctx, LOG_DEBUG);
break;
case OPT_DISTRO:
- config->distro = arg;
+ args->distro = arg;
break;
// Enable/Disable Repositories
case OPT_ENABLE_REPO:
- if (config->num_enable_repos >= MAX_REPOS)
+ if (args->num_enable_repos >= MAX_REPOS)
return -ENOBUFS;
- config->enable_repos[config->num_enable_repos++] = arg;
+ args->enable_repos[args->num_enable_repos++] = arg;
break;
case OPT_DISABLE_REPO:
- if (config->num_disable_repos >= MAX_REPOS)
+ if (args->num_disable_repos >= MAX_REPOS)
return -ENOBUFS;
- config->disable_repos[config->num_disable_repos++] = arg;
+ args->disable_repos[args->num_disable_repos++] = arg;
break;
default:
if (r)
goto ERROR;
- struct cli_config config = {
+ struct cli_global_args args = {
.ctx = ctx,
.distro = cli_get_default_distro(ctx),
.arch = NULL,
// Parse the command line and run any commands
r = cli_parse(options, commands, args_doc, NULL,
- parse, CLI_REQUIRE_ROOT, argc, argv, &config);
+ parse, CLI_REQUIRE_ROOT, argc, argv, &args);
ERROR:
if (ctx)
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct cli_config* config = data;
+ struct cli_global_args* args = data;
switch (key) {
case OPT_DEBUG:
- pakfire_ctx_set_log_level(config->ctx, LOG_DEBUG);
+ pakfire_ctx_set_log_level(args->ctx, LOG_DEBUG);
break;
case OPT_DISTRO:
- config->distro = arg;
+ args->distro = arg;
break;
default:
// Setup progress callback
pakfire_ctx_set_progress_callback(ctx, cli_setup_progressbar, NULL);
- struct cli_config config = {
+ struct cli_global_args args = {
.ctx = ctx,
.distro = cli_get_default_distro(ctx),
};
// Parse the command line and run any commands
r = cli_parse(options, commands, args_doc, doc,
- parse, 0, argc, argv, &config);
+ parse, 0, argc, argv, &args);
ERROR:
if (ctx)
};
static error_t parse(int key, char* arg, struct argp_state* state, void* data) {
- struct cli_config* config = data;
+ struct cli_global_args* args = data;
switch (key) {
case OPT_CONFIG:
- config->config = arg;
+ args->config = arg;
break;
case OPT_DEBUG:
- pakfire_ctx_set_log_level(config->ctx, LOG_DEBUG);
+ pakfire_ctx_set_log_level(args->ctx, LOG_DEBUG);
break;
case OPT_OFFLINE:
- pakfire_ctx_set_flag(config->ctx, PAKFIRE_CTX_OFFLINE);
+ pakfire_ctx_set_flag(args->ctx, PAKFIRE_CTX_OFFLINE);
break;
case OPT_ROOT:
- config->root = arg;
+ args->root = arg;
break;
case OPT_YES:
- pakfire_ctx_set_confirm_callback(config->ctx, cli_term_confirm_yes, NULL);
+ pakfire_ctx_set_confirm_callback(args->ctx, cli_term_confirm_yes, NULL);
break;
// Enable/Disable Repositories
case OPT_ENABLE_REPO:
- if (config->num_enable_repos >= MAX_REPOS)
+ if (args->num_enable_repos >= MAX_REPOS)
return -ENOBUFS;
- config->enable_repos[config->num_enable_repos++] = arg;
+ args->enable_repos[args->num_enable_repos++] = arg;
break;
case OPT_DISABLE_REPO:
- if (config->num_disable_repos >= MAX_REPOS)
+ if (args->num_disable_repos >= MAX_REPOS)
return -ENOBUFS;
- config->disable_repos[config->num_disable_repos++] = arg;
+ args->disable_repos[args->num_disable_repos++] = arg;
break;
default:
// Setup pick solution callback
pakfire_ctx_set_pick_solution_callback(ctx, cli_term_pick_solution, NULL);
- struct cli_config config = {
+ struct cli_global_args args = {
.ctx = ctx,
// XXX hard-coded path
.config = "/etc/pakfire/general.conf",
// Parse the command line and run any commands
r = cli_parse(options, commands, args_doc, NULL, parse,
- CLI_REQUIRE_ROOT, argc, argv, &config);
+ CLI_REQUIRE_ROOT, argc, argv, &args);
ERROR:
if (ctx)