From e312c58db0d2c4c647a1bf64782965ad1f6560c1 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 16 Feb 2017 12:19:02 +0100 Subject: [PATCH] libopkg: implement pkg_hash_load_package_details() helper The purpose of this new function is to keep parsing feed lists until all package detail requests are satisified. Signed-off-by: Jo-Philipp Wich --- libopkg/pkg_hash.c | 40 ++++++++++++++++++++++++++++++++++++++++ libopkg/pkg_hash.h | 1 + 2 files changed, 41 insertions(+) diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index 99d8958..3b49301 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -222,6 +222,46 @@ int pkg_hash_load_status_files(void) return 0; } +static void +pkg_hash_load_package_details_helper(const char *pkg_name, void *entry, void *data) +{ + int *count = data; + abstract_pkg_t *ab_pkg = (abstract_pkg_t *) entry; + + if (ab_pkg->state_flag & SF_NEED_DETAIL) { + if (ab_pkg->state_flag & SF_MARKED) { + opkg_msg(DEBUG, "skipping already seen flagged abpkg %s\n", + ab_pkg->name); + return; + } + + opkg_msg(DEBUG, "found yet incomplete flagged abpkg %s\n", + ab_pkg->name); + + (*count)++; + ab_pkg->state_flag |= SF_MARKED; + } +} + +int pkg_hash_load_package_details(void) +{ + int n_need_detail; + + while (1) { + pkg_hash_load_feeds(0); + + n_need_detail = 0; + hash_table_foreach(&conf->pkg_hash, pkg_hash_load_package_details_helper, &n_need_detail); + + if (n_need_detail > 0) + opkg_msg(DEBUG, "Found %d packages requiring details, reloading feeds\n", n_need_detail); + else + break; + } + + return 0; +} + pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg, int (*constraint_fcn) (pkg_t * pkg, diff --git a/libopkg/pkg_hash.h b/libopkg/pkg_hash.h index 562eeaa..e849160 100644 --- a/libopkg/pkg_hash.h +++ b/libopkg/pkg_hash.h @@ -33,6 +33,7 @@ int pkg_hash_add_from_file(const char *file_name, pkg_src_t * src, pkg_dest_t * dest, int is_status_file, int state_flags); int pkg_hash_load_feeds(int state_flags); int pkg_hash_load_status_files(void); +int pkg_hash_load_package_details(void); void hash_insert_pkg(pkg_t * pkg, int set_status); -- 2.25.1