}
int cli_setup_pakfire(struct pakfire** pakfire, struct cli_config* config) {
- struct pakfire_ctx* ctx = NULL;
struct pakfire* p = NULL;
FILE* f = NULL;
int r;
}
}
- // Create a new context
- r = pakfire_ctx_create(&ctx);
- if (r)
- goto ERROR;
-
// Initialize Pakfire
- r = pakfire_create(&p, ctx, config->root, config->arch, f, config->flags);
+ r = pakfire_create(&p, config->ctx, config->root, config->arch, f, config->flags);
if (r)
goto ERROR;
*pakfire = p;
ERROR:
- if (ctx)
- pakfire_ctx_unref(ctx);
if (f)
fclose(f);
#ifndef PAKFIRE_CLI_PAKFIRE_H
#define PAKFIRE_CLI_PAKFIRE_H
+#include <pakfire/ctx.h>
#include <pakfire/pakfire.h>
#define MAX_REPOS 16
struct cli_config {
+ struct pakfire_ctx* ctx;
+
const char* distro;
const char* config;
const char* arch;
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
+#include <syslog.h>
#include <unistd.h>
#include <pakfire/pakfire.h>
break;
case OPT_DEBUG:
- config->flags |= PAKFIRE_FLAGS_DEBUG;
+ pakfire_ctx_set_log_level(config->ctx, LOG_DEBUG);
break;
case OPT_DISTRO:
}
int main(int argc, char* argv[]) {
+ struct pakfire_ctx* ctx = NULL;
+ int r;
+
+ // Setup the context
+ r = pakfire_ctx_create(&ctx);
+ if (r)
+ goto ERROR;
+
struct cli_config config = {
+ .ctx = ctx,
// XXX hard-coded distro
.distro = "ipfire3",
.arch = NULL,
};
// Parse the command line and run any commands
- return cli_parse(options, commands, args_doc, NULL, parse, argc, argv, &config);
+ r = cli_parse(options, commands, args_doc, NULL, parse, argc, argv, &config);
+
+ERROR:
+ if (ctx)
+ pakfire_ctx_unref(ctx);
+
+ return r;
}
#############################################################################*/
#include <argp.h>
+#include <syslog.h>
#include "lib/clean.h"
#include "lib/command.h"
break;
case OPT_DEBUG:
- config->flags |= PAKFIRE_FLAGS_DEBUG;
+ pakfire_ctx_set_log_level(config->ctx, LOG_DEBUG);
break;
case OPT_OFFLINE:
int main(int argc, char* argv[]) {
+ struct pakfire_ctx* ctx = NULL;
+ int r;
+
+ // Setup the context
+ r = pakfire_ctx_create(&ctx);
+ if (r)
+ goto ERROR;
+
struct cli_config config = {
+ .ctx = ctx,
// XXX hard-coded path
.config = "/etc/pakfire/general.conf",
.arch = NULL,
};
// Parse the command line and run any commands
- return cli_parse(options, commands, args_doc, NULL, parse, argc, argv, &config);
+ r = cli_parse(options, commands, args_doc, NULL, parse, argc, argv, &config);
+
+ERROR:
+ if (ctx)
+ pakfire_ctx_unref(ctx);
+
+ return r;
}