X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fpkg_hash.c;h=f72ed26e52fc3845e9f29f1c1911605d3dd37cd6;hp=06a0ac5881e89a747ace685f63b18a82a78d6bce;hb=b4cebed6238b42ad45e79a6cf28749d0626658c6;hpb=2fdb3fc0b67757afd6fe7a244b6e14d2a546af0e diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index 06a0ac5..f72ed26 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -15,11 +15,7 @@ General Public License for more details. */ -#include "includes.h" -#include -#include -#include -#include +#include #include "hash_table.h" #include "pkg.h" @@ -28,6 +24,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 @@ -107,10 +105,10 @@ pkg_hash_add_from_file(const char *file_name, continue; } - if (!pkg->architecture) { + if (!pkg->architecture || !pkg->arch_priority) { char *version_str = pkg_version_str_alloc(pkg); - opkg_msg(ERROR, "Package %s version %s has no " - "architecture specified, ignoring.\n", + opkg_msg(NOTICE, "Package %s version %s has no " + "valid architecture, ignoring.\n", pkg->name, version_str); free(version_str); continue; @@ -126,6 +124,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) { @@ -137,7 +194,7 @@ pkg_hash_fetch_best_installation_candidate(abstract_pkg_t *apkg, int (*constraint_fcn)(pkg_t *pkg, void *cdata), void *cdata, int quiet) { - int i; + int i, j; int nprovides = 0; int nmatching = 0; int wrong_arch_found = 0; @@ -212,8 +269,8 @@ pkg_hash_fetch_best_installation_candidate(abstract_pkg_t *apkg, int max_count = 0; /* count packages matching max arch priority and keep track of last one */ - for (i = 0; i < vec->len; i++) { - pkg_t *maybe = vec->pkgs[i]; + for (j=0; jlen; j++) { + pkg_t *maybe = vec->pkgs[j]; opkg_msg(DEBUG, "%s arch=%s arch_priority=%d version=%s.\n", maybe->name, maybe->architecture, maybe->arch_priority, maybe->version); @@ -566,7 +623,14 @@ hash_insert_pkg(pkg_t *pkg, int set_status) pkg_t * file_hash_get_file_owner(const char *file_name) { - return hash_table_get(&conf->file_hash, file_name); + if (conf->offline_root) { + unsigned int len = strlen(conf->offline_root); + if (strncmp(file_name, conf->offline_root, len) == 0) { + file_name += len; + } + } + + return hash_table_get(&conf->file_hash, file_name); } void