From: Jo-Philipp Wich Date: Wed, 15 Feb 2017 23:24:29 +0000 (+0100) Subject: libopkg: allow passing common package state flags to pkg_hash_add_from_file() X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=commitdiff_plain;h=a65b6cb58937885c115059aa571c2b3a57d90888;hp=d79ee5c52f301aaa721f9061daf2c1d0c11e5615 libopkg: allow passing common package state flags to pkg_hash_add_from_file() Add a new parameter to pkg_hash_add_from_file() for passing package state flags that shall be applied to all pkg_t instances parsed from the given file and use it to mark all packages loaded from local status files with the SF_NEED_DETAIL flag. Signed-off-by: Jo-Philipp Wich --- diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index 821cc71..8c31aa9 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -79,7 +79,7 @@ int dist_hash_add_from_file(const char *lists_dir, pkg_src_t * dist) 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)) { + if (pkg_hash_add_from_file(list_file, dist, NULL, 0, 0)) { free(list_file); return -1; } @@ -95,7 +95,7 @@ int dist_hash_add_from_file(const char *lists_dir, pkg_src_t * dist) int pkg_hash_add_from_file(const char *file_name, - pkg_src_t * src, pkg_dest_t * dest, int is_status_file) + pkg_src_t * src, pkg_dest_t * dest, int is_status_file, int state_flags) { pkg_t *pkg; FILE *fp; @@ -121,6 +121,7 @@ pkg_hash_add_from_file(const char *file_name, pkg = pkg_new(); pkg->src = src; pkg->dest = dest; + pkg->state_flag |= state_flags; ret = parse_from_stream_nomalloc(pkg_parse_line, pkg, fp, 0, &buf, len); @@ -185,7 +186,7 @@ int pkg_hash_load_feeds(void) 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)) { + if (pkg_hash_add_from_file(list_file, src, NULL, 0, 0)) { free(list_file); return -1; } @@ -213,7 +214,7 @@ int pkg_hash_load_status_files(void) if (file_exists(dest->status_file_name)) { if (pkg_hash_add_from_file - (dest->status_file_name, NULL, dest, 1)) + (dest->status_file_name, NULL, dest, 1, SF_NEED_DETAIL)) return -1; } } diff --git a/libopkg/pkg_hash.h b/libopkg/pkg_hash.h index e72ffed..dcf69f5 100644 --- a/libopkg/pkg_hash.h +++ b/libopkg/pkg_hash.h @@ -30,7 +30,7 @@ void pkg_hash_fetch_available(pkg_vec_t * available); int dist_hash_add_from_file(const char *file_name, pkg_src_t * dist); int pkg_hash_add_from_file(const char *file_name, pkg_src_t * src, - pkg_dest_t * dest, int is_status_file); + pkg_dest_t * dest, int is_status_file, int state_flags); int pkg_hash_load_feeds(void); int pkg_hash_load_status_files(void);