diff options
-rw-r--r-- | libopkg/pkg_hash.c | 63 | ||||
-rw-r--r-- | libopkg/pkg_hash.h | 1 |
2 files changed, 63 insertions, 1 deletions
diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index b7f1573..2a76be8 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -18,6 +18,7 @@ #include <stdio.h> #include "hash_table.h" +#include "release.h" #include "pkg.h" #include "opkg_message.h" #include "pkg_vec.h" @@ -70,6 +71,32 @@ pkg_hash_deinit(void) } int +dist_hash_add_from_file(const char *lists_dir, pkg_src_t *dist) +{ + nv_pair_list_elt_t *l; + char *list_file, *subname; + + list_for_each_entry(l , &conf->arch_list.head, node) { + nv_pair_t *nv = (nv_pair_t *)l->data; + sprintf_alloc(&subname, "%s-%s", dist->name, nv->name); + sprintf_alloc(&list_file, "%s/%s", lists_dir, subname); + + if (file_exists(list_file)) { + if (pkg_hash_add_from_file(list_file, dist, NULL, 0)) { + free(list_file); + return -1; + } + pkg_src_list_append (&conf->pkg_src_list, subname, dist->value, "__dummy__", 0); + } + + free(list_file); + } + + return 0; +} + + +int pkg_hash_add_from_file(const char *file_name, pkg_src_t *src, pkg_dest_t *dest, int is_status_file) { @@ -131,7 +158,7 @@ int pkg_hash_load_feeds(void) { pkg_src_list_elt_t *iter; - pkg_src_t *src; + pkg_src_t *src, *subdist; char *list_file, *lists_dir; opkg_msg(INFO, "\n"); @@ -139,6 +166,40 @@ pkg_hash_load_feeds(void) lists_dir = conf->restrict_to_default_dest ? conf->default_dest->lists_dir : conf->lists_dir; + for (iter = void_list_first(&conf->dist_src_list); iter; + iter = void_list_next(&conf->dist_src_list, iter)) { + + src = (pkg_src_t *)iter->data; + + sprintf_alloc(&list_file, "%s/%s", lists_dir, src->name); + + if (file_exists(list_file)) { + int i; + release_t *release = release_new(); + if(release_init_from_file(release, list_file)) { + free(list_file); + return -1; + } + + unsigned int ncomp; + const char **comps = release_comps(release, &ncomp); + subdist = (pkg_src_t *) xmalloc(sizeof(pkg_src_t)); + memcpy(subdist, src, sizeof(pkg_src_t)); + + for(i = 0; i < ncomp; i++){ + subdist->name = NULL; + sprintf_alloc(&subdist->name, "%s-%s", src->name, comps[i]); + if (dist_hash_add_from_file(lists_dir, subdist)) { + free(subdist->name); free(subdist); + free(list_file); + return -1; + } + } + free(subdist->name); free(subdist); + } + free(list_file); + } + for (iter = void_list_first(&conf->pkg_src_list); iter; iter = void_list_next(&conf->pkg_src_list, iter)) { diff --git a/libopkg/pkg_hash.h b/libopkg/pkg_hash.h index 1165d83..b3cf3d1 100644 --- a/libopkg/pkg_hash.h +++ b/libopkg/pkg_hash.h @@ -29,6 +29,7 @@ void pkg_hash_deinit(void); void pkg_hash_fetch_available(pkg_vec_t *available); +int dist_hash_add_from_file(const char *file_name, pkg_src_t *dist); int pkg_hash_add_from_file(const char *file_name, pkg_src_t *src, pkg_dest_t *dest, int is_status_file); int pkg_hash_load_feeds(void); |