db: convert repository list to a string array
parent
010497cb5a
commit
b2af872fff
17
src/apk.c
17
src/apk.c
|
@ -63,16 +63,6 @@ static void version(void)
|
|||
);
|
||||
}
|
||||
|
||||
static struct apk_repository_list *apk_repository_new(const char *url)
|
||||
{
|
||||
struct apk_repository_list *r = calloc(1, sizeof(struct apk_repository_list));
|
||||
if (r) {
|
||||
r->url = url;
|
||||
list_init(&r->list);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
#define GLOBAL_OPTIONS(OPT) \
|
||||
OPT(OPT_GLOBAL_allow_untrusted, "allow-untrusted") \
|
||||
OPT(OPT_GLOBAL_arch, APK_OPT_ARG "arch") \
|
||||
|
@ -118,8 +108,6 @@ APK_OPT_GROUP(optiondesc_global, "Global", GLOBAL_OPTIONS);
|
|||
|
||||
static int option_parse_global(void *ctx, struct apk_db_options *dbopts, int opt, const char *optarg)
|
||||
{
|
||||
struct apk_repository_list *repo;
|
||||
|
||||
switch (opt) {
|
||||
case OPT_GLOBAL_help:
|
||||
return -EINVAL;
|
||||
|
@ -133,8 +121,7 @@ static int option_parse_global(void *ctx, struct apk_db_options *dbopts, int opt
|
|||
dbopts->repositories_file = optarg;
|
||||
break;
|
||||
case OPT_GLOBAL_repository:
|
||||
repo = apk_repository_new(optarg);
|
||||
if (repo) list_add(&repo->list, &dbopts->repository_list);
|
||||
*apk_string_array_add(&dbopts->repository_list) = (char*) optarg;
|
||||
break;
|
||||
case OPT_GLOBAL_quiet:
|
||||
apk_verbosity--;
|
||||
|
@ -471,7 +458,7 @@ int main(int argc, char **argv)
|
|||
apk_argv[argc+1] = NULL;
|
||||
|
||||
memset(&dbopts, 0, sizeof(dbopts));
|
||||
list_init(&dbopts.repository_list);
|
||||
apk_string_array_init(&dbopts.repository_list);
|
||||
apk_string_array_init(&dbopts.private_keys);
|
||||
umask(0);
|
||||
setup_terminal();
|
||||
|
|
|
@ -117,11 +117,6 @@ struct apk_repository {
|
|||
apk_blob_t description;
|
||||
};
|
||||
|
||||
struct apk_repository_list {
|
||||
struct list_head list;
|
||||
const char *url;
|
||||
};
|
||||
|
||||
struct apk_db_options {
|
||||
int lock_wait;
|
||||
unsigned int cache_max_age;
|
||||
|
@ -131,7 +126,7 @@ struct apk_db_options {
|
|||
const char *keys_dir;
|
||||
const char *cache_dir;
|
||||
const char *repositories_file;
|
||||
struct list_head repository_list;
|
||||
struct apk_string_array *repository_list;
|
||||
struct apk_string_array *private_keys;
|
||||
};
|
||||
|
||||
|
|
|
@ -1511,7 +1511,6 @@ void apk_db_init(struct apk_database *db)
|
|||
int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
|
||||
{
|
||||
const char *msg = NULL;
|
||||
struct apk_repository_list *repo = NULL;
|
||||
struct statfs stfs;
|
||||
apk_blob_t blob;
|
||||
int r, fd, write_arch = FALSE;
|
||||
|
@ -1695,8 +1694,10 @@ int apk_db_open(struct apk_database *db, struct apk_db_options *dbopts)
|
|||
}
|
||||
|
||||
if (!(dbopts->open_flags & APK_OPENF_NO_SYS_REPOS)) {
|
||||
list_for_each_entry(repo, &dbopts->repository_list, list)
|
||||
apk_db_add_repository(db, APK_BLOB_STR(repo->url));
|
||||
char **repo;
|
||||
|
||||
foreach_array_item(repo, dbopts->repository_list)
|
||||
apk_db_add_repository(db, APK_BLOB_STR(*repo));
|
||||
|
||||
if (dbopts->repositories_file == NULL) {
|
||||
add_repos_from_file(db, db->root_fd, "etc/apk/repositories");
|
||||
|
|
|
@ -170,7 +170,7 @@ static int Papk_db_open(lua_State *L)
|
|||
int r;
|
||||
|
||||
memset(&opts, 0, sizeof(opts));
|
||||
list_init(&opts.repository_list);
|
||||
apk_string_array_init(&opts.repository_list);
|
||||
if (lua_istable(L, 1))
|
||||
get_dbopts(L, 1, &opts);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue