summaryrefslogtreecommitdiffstats
path: root/libopkg/pkg_hash.c
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-10 22:04:35 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-10 22:04:35 (EST)
commit993e14cd113fccd973c35fd1322625804d5e5142 (patch)
tree782f9a8ddb595a238ee1e1a907fc76fe1b860421 /libopkg/pkg_hash.c
parent307864afe92e3b941d66bb334b32979eac2b41ab (diff)
Move loading of feeds and status files out of opkg_conf_init().
git-svn-id: http://opkg.googlecode.com/svn/trunk@483 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/pkg_hash.c')
-rw-r--r--libopkg/pkg_hash.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c
index 5b4fe4b..f5d4782 100644
--- a/libopkg/pkg_hash.c
+++ b/libopkg/pkg_hash.c
@@ -28,6 +28,8 @@
#include "pkg_hash.h"
#include "pkg_parse.h"
#include "opkg_utils.h"
+#include "sprintf_alloc.h"
+#include "file_util.h"
#include "libbb/libbb.h"
void
@@ -126,6 +128,65 @@ pkg_hash_add_from_file(const char *file_name,
return ret;
}
+/*
+ * Load in feed files from the cached "src" and/or "src/gz" locations.
+ */
+int
+pkg_hash_load_feeds(void)
+{
+ pkg_src_list_elt_t *iter;
+ pkg_src_t *src;
+ 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->pkg_src_list); iter;
+ iter = void_list_next(&conf->pkg_src_list, iter)) {
+
+ src = (pkg_src_t *)iter->data;
+
+ sprintf_alloc(&list_file, "%s/%s", lists_dir, src->name);
+
+ if (file_exists(list_file)) {
+ if (pkg_hash_add_from_file(list_file, src, NULL, 0)) {
+ free(list_file);
+ return -1;
+ }
+ }
+ free(list_file);
+ }
+
+ return 0;
+}
+
+/*
+ * Load in status files from the configured "dest"s.
+ */
+int
+pkg_hash_load_status_files(void)
+{
+ pkg_dest_list_elt_t *iter;
+ pkg_dest_t *dest;
+
+ opkg_msg(INFO, "\n");
+
+ for (iter = void_list_first(&conf->pkg_dest_list); iter;
+ iter = void_list_next(&conf->pkg_dest_list, iter)) {
+
+ dest = (pkg_dest_t *)iter->data;
+
+ if (file_exists(dest->status_file_name)) {
+ if (pkg_hash_add_from_file(dest->status_file_name, NULL, dest, 1))
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
static abstract_pkg_t *
abstract_pkg_fetch_by_name(const char * pkg_name)
{