libopkg: allow passing common package state flags to pkg_hash_add_from_file()
authorJo-Philipp Wich <jo@mein.io>
Wed, 15 Feb 2017 23:24:29 +0000 (00:24 +0100)
committerJo-Philipp Wich <jo@mein.io>
Thu, 16 Feb 2017 16:02:30 +0000 (17:02 +0100)
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 <jo@mein.io>
libopkg/pkg_hash.c
libopkg/pkg_hash.h

index 821cc71886e735e7f70a0446b73e4e8f8416e848..8c31aa99f0f8a26ac248c4d7ddb8e7324fcce62b 100644 (file)
@@ -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;
                }
        }
index e72ffed88460a5c58d8af79a0e29258b4e88f52b..dcf69f5ebcb4c8f3a10dcde806b527fb76ab7fcc 100644 (file)
@@ -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);