#include <stdio.h>
#include "hash_table.h"
+#include "release.h"
#include "pkg.h"
#include "opkg_message.h"
#include "pkg_vec.h"
hash_table_deinit(&conf->pkg_hash);
}
+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)
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");
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)) {