diff --git a/src/apk.c b/src/apk.c index 6aaed879253d14ab5df7770c7287616453161f50..b4b9e9bd5e92d4c8aee3cddf24603b34fd4760ec 100644 --- a/src/apk.c +++ b/src/apk.c @@ -22,7 +22,7 @@ #include "apk_applet.h" const char *apk_root; -const char *apk_repository = NULL; +struct apk_repository_url apk_repository_list; int apk_verbosity = 1, apk_progress = 0, apk_upgrade = 0; int apk_cwd_fd; @@ -99,6 +99,17 @@ static struct apk_applet *deduce_applet(int argc, char **argv) return NULL; } +static struct apk_repository_url *apk_repository_new(const char *url) +{ + struct apk_repository_url *r = calloc(1, + sizeof(struct apk_repository_url)); + if (r) { + r->url = url; + list_init(&r->list); + } + return r; +} + #define NUM_GENERIC_OPTS 6 static struct option generic_options[32] = { { "root", required_argument, NULL, 'p' }, @@ -116,10 +127,12 @@ int main(int argc, char **argv) struct option *opt; int r, optindex; void *ctx = NULL; + struct apk_repository_url *repo = NULL; umask(0); apk_cwd_fd = open(".", O_RDONLY); apk_root = getenv("ROOT"); + list_init(&apk_repository_list.list); applet = deduce_applet(argc, argv); if (applet != NULL) { @@ -151,7 +164,9 @@ int main(int argc, char **argv) apk_root = optarg; break; case 'X': - apk_repository = optarg; + repo = apk_repository_new(optarg); + if (repo) + list_add(&repo->list, &apk_repository_list.list); break; case 'q': apk_verbosity--; diff --git a/src/apk_applet.h b/src/apk_applet.h index 4fdce0d81b4e7163effb562faa40d85d9cca86da..dba55899d0ae07b306940280dfecdc14cccf8c74 100644 --- a/src/apk_applet.h +++ b/src/apk_applet.h @@ -13,9 +13,16 @@ #define APK_APPLET_H #include +#include "apk_defines.h" extern const char *apk_root; -extern const char *apk_repository; + +struct apk_repository_url { + struct list_head list; + const char *url; +}; + +extern struct apk_repository_url apk_repository_list; struct apk_applet { const char *name; diff --git a/src/database.c b/src/database.c index 621c03c0fb9763669f9ea0f5a6234b732f1c258f..743fd83f450f120fa649f9a7670a7aae38e8fdf3 100644 --- a/src/database.c +++ b/src/database.c @@ -621,6 +621,7 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags) apk_blob_t blob; const char *apk_repos = getenv("APK_REPOS"), *msg; int r; + struct apk_repository_url *repo = NULL; memset(db, 0, sizeof(*db)); apk_hash_init(&db->available.names, &pkg_name_hash_ops, 1000); @@ -696,10 +697,10 @@ int apk_db_open(struct apk_database *db, const char *root, unsigned int flags) } } - if (apk_repository != NULL) { - r = apk_db_add_repository(db, APK_BLOB_STR(apk_repository)); + list_for_each_entry(repo, &apk_repository_list.list, list) { + r = apk_db_add_repository(db, APK_BLOB_STR(repo->url)); if (r != 0) { - msg = "Unable to load repositories"; + msg = repo->url; goto ret_r; } }