#include "opkg_message.h"
#include "pkg_vec.h"
#include "pkg_hash.h"
+#include "parse_util.h"
#include "pkg_parse.h"
#include "opkg_utils.h"
#include "sprintf_alloc.h"
#include "file_util.h"
#include "libbb/libbb.h"
+#include "libbb/gzip.h"
void
pkg_hash_init(void)
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)
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;
pkg->src = src;
pkg->dest = dest;
- ret = pkg_parse_from_stream_nomalloc(pkg, fp, 0,
+ ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, 0,
&buf, len);
+
+ if (pkg->name == NULL) {
+ /* probably just a blank line */
+ ret = 1;
+ }
+
if (ret) {
pkg_deinit (pkg);
free(pkg);
free(buf);
fclose(fp);
+ if (src && src->gzip)
+ gzip_close(&zh);
+
return ret;
}
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");