X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fpkg_hash.c;h=c6d7158032cb8a860171cebc796e44f566e1c672;hp=7f76da130d0c5f20be22e4fe203c1a2574ad99bc;hb=d6025a6d1c91f80368f301029784cf2c5dd3273e;hpb=4a97d5bab9f2369e8af32617da3c780b59a817f2 diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index 7f76da1..c6d7158 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -18,7 +18,6 @@ #include #include "hash_table.h" -#include "release.h" #include "pkg.h" #include "opkg_message.h" #include "pkg_vec.h" @@ -29,6 +28,7 @@ #include "sprintf_alloc.h" #include "file_util.h" #include "libbb/libbb.h" +#include "libbb/gzip.h" void pkg_hash_init(void) @@ -106,8 +106,15 @@ pkg_hash_add_from_file(const char *file_name, char *buf; const size_t len = 4096; int ret = 0; + struct gzip_handle zh; + + if (src && src->gzip) { + fp = gzip_fdopen(&zh, file_name); + } + else { + fp = fopen(file_name, "r"); + } - fp = fopen(file_name, "r"); if (fp == NULL) { opkg_perror(ERROR, "Failed to open %s", file_name); return -1; @@ -155,6 +162,9 @@ pkg_hash_add_from_file(const char *file_name, free(buf); fclose(fp); + if (src && src->gzip) + gzip_close(&zh); + return ret; } @@ -173,40 +183,6 @@ 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)) {