summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2023-04-12 10:14:09 +0300
committerTimo Teräs <timo.teras@iki.fi>2023-04-12 10:15:07 +0300
commit77fd338f902074de3f0e9225f2bdc3a466a3804c (patch)
treec41055532c49a64f1c1c894cea23afb50021fccd
parentf184a4a2425a6c81548ae2ec9576472f44201fff (diff)
downloadapk-tools-77fd338f902074de3f0e9225f2bdc3a466a3804c.tar.gz
apk-tools-77fd338f902074de3f0e9225f2bdc3a466a3804c.tar.bz2
apk-tools-77fd338f902074de3f0e9225f2bdc3a466a3804c.tar.xz
apk-tools-77fd338f902074de3f0e9225f2bdc3a466a3804c.zip
index: simplify pruning by origin
-rw-r--r--src/app_index.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/src/app_index.c b/src/app_index.c
index 4a5a7d3..80fd8e2 100644
--- a/src/app_index.c
+++ b/src/app_index.c
@@ -91,15 +91,6 @@ struct index_writer {
unsigned short index_flags;
};
-static int mark_origin(struct apk_database *db, struct apk_package *pkg, int mark)
-{
- struct apk_name *n;
- if (pkg->origin == NULL) return 0;
- n = apk_db_get_name(db, *pkg->origin);
- n->state_int |= mark;
- return n->state_int;
-}
-
static int index_write_entry(struct apk_database *db, const char *match, struct apk_package *pkg, void *ctx)
{
struct index_writer *iw = ctx;
@@ -108,7 +99,10 @@ static int index_write_entry(struct apk_database *db, const char *match, struct
case APK_INDEXF_MERGE:
break;
case APK_INDEXF_MERGE|APK_INDEXF_PRUNE_ORIGIN:
- if (mark_origin(db, pkg, 0) && !pkg->marked) return 0;
+ if (!pkg->marked && pkg->origin) {
+ struct apk_name *n = apk_db_query_name(db, *pkg->origin);
+ if (n && n->state_int) return 0;
+ }
break;
default:
if (!pkg->marked) return 0;
@@ -165,7 +159,7 @@ static void index_mark_package(struct apk_database *db, struct apk_package *pkg,
{
if (rewrite_arch) pkg->arch = rewrite_arch;
pkg->marked = 1;
- mark_origin(db, pkg, 1);
+ if (pkg->origin) apk_db_get_name(db, *pkg->origin)->state_int = 1;
}
static int index_main(void *ctx, struct apk_database *db, struct apk_string_array *args)