#include <ctype.h>
#include <errno.h>
+#include <fts.h>
#include <linux/limits.h>
#include <stddef.h>
#include <stdio.h>
return 0;
}
+static int pakfire_read_repo_config(Pakfire pakfire) {
+ char* path = pakfire_make_path(pakfire, PAKFIRE_CONFIG_PATH "/repos");
+ if (!path)
+ return ENOMEM;
+
+ int r = 0;
+ char* paths[2] = {
+ path, NULL,
+ };
+
+ FTS* d = fts_open(paths, FTS_NOCHDIR|FTS_NOSTAT, NULL);
+ if (!d)
+ goto ERROR;
+
+ for (;;) {
+ FTSENT* fent = fts_read(d);
+ if (!fent)
+ break;
+
+ // Only handle files
+ if (fent->fts_info & FTS_F) {
+ // Skip everything that doesn't end in .repo
+ if (!pakfire_string_endswith(fent->fts_name, ".repo"))
+ continue;
+
+ DEBUG(pakfire, "Reading %s\n", fent->fts_path);
+
+ FILE* f = fopen(fent->fts_path, "r");
+ if (!f)
+ goto ERROR;
+
+ // Parse the configuration file
+ r = pakfire_config_read(pakfire->config, f);
+ fclose(f);
+
+ if (r)
+ goto ERROR;
+ }
+ }
+
+ERROR:
+ if (d)
+ fts_close(d);
+ free(path);
+
+ return r;
+}
+
static int pakfire_config_import_distro(Pakfire pakfire) {
// Nothing to do if there is no distro section
if (!pakfire_config_has_section(pakfire->config, "distro"))
if (r)
goto ERROR;
+ // Read repository configuration
+ r = pakfire_read_repo_config(pakfire);
+ if (r)
+ goto ERROR;
+
ERROR:
fclose(f);