#include "pakfire.h"
#include "progressbar.h"
-static FILE* open_distro_config(const char* distro) {
- char path[PATH_MAX];
- FILE* f = NULL;
- int r;
-
- // XXX hard-coded path
-
- // Make the path
- r = snprintf(path, sizeof(path), "/etc/pakfire/distros/%s.conf", distro);
- if (r < 0)
- return NULL;
-
- // Open the configuration file
- f = fopen(path, "r");
- if (!f) {
- switch (errno) {
- case ENOENT:
- fprintf(stderr, "Could not find distro '%s': %m\n", distro);
- break;
-
- default:
- break;
- }
- }
-
- return f;
-}
-
static void cli_set_repo_enabled(struct pakfire* pakfire, const char* name, int enabled) {
struct pakfire_repo* repo = NULL;
if (r < 0)
goto ERROR;
- // Open the distro configuration
- if (config->distro) {
- f = open_distro_config(config->distro);
- if (!f) {
- r = 1;
- goto ERROR;
- }
-
// Open the regular configuration
- } else if (config->config) {
- f = fopen(config->config, "r");
- if (!f) {
- r = -errno;
+ if (config->config) {
+ r = pakfire_config_read_path(c, config->config);
+ if (r < 0)
goto ERROR;
- }
}
- // Read the configuration file
- r = pakfire_config_read(c, f);
- if (r < 0)
- goto ERROR;
-
// Initialize Pakfire
r = pakfire_create(&p, config->ctx, c, config->root, config->arch, config->flags);
if (r < 0) {