diff options
author | Timo Teräs <timo.teras@iki.fi> | 2022-12-25 14:57:47 +0200 |
---|---|---|
committer | Timo Teräs <timo.teras@iki.fi> | 2022-12-25 15:01:13 +0200 |
commit | 3448f3148f37bd246643be6669434c6c7f588c90 (patch) | |
tree | 1448d7f8d0a383600a8bdf1a322d934eb81f26fb | |
parent | 1b02534c9d8350e1d3c32ef78f822039fb5c1215 (diff) | |
download | apk-tools-3448f3148f37bd246643be6669434c6c7f588c90.tar.gz apk-tools-3448f3148f37bd246643be6669434c6c7f588c90.tar.bz2 apk-tools-3448f3148f37bd246643be6669434c6c7f588c90.tar.xz apk-tools-3448f3148f37bd246643be6669434c6c7f588c90.zip |
solver: prioritize user specified action on mentioned packages
Force preference on the user specified action on commandline.
This allows upgrading packages which would otherwise be kept back
due to partial update preferring to keep top level dependency on
the installed version.
fixes #7531
-rw-r--r-- | src/apk_database.h | 1 | ||||
-rw-r--r-- | src/solver.c | 4 | ||||
-rw-r--r-- | test/basic17.installed | 13 | ||||
-rw-r--r-- | test/basic17.repo | 26 | ||||
-rw-r--r-- | test/basic17.test | 9 | ||||
-rw-r--r-- | test/basic18.test | 9 |
6 files changed, 62 insertions, 0 deletions
diff --git a/src/apk_database.h b/src/apk_database.h index f0f6ba5..5b495d8 100644 --- a/src/apk_database.h +++ b/src/apk_database.h @@ -102,6 +102,7 @@ struct apk_name { unsigned auto_select_virtual: 1; unsigned priority : 2; unsigned layer : 4; + unsigned solver_flags_set : 1; unsigned int foreach_genid; union { struct apk_solver_name_state ss; diff --git a/src/solver.c b/src/solver.c index 13dd8c6..7327b71 100644 --- a/src/solver.c +++ b/src/solver.c @@ -51,6 +51,7 @@ void apk_solver_set_name_flags(struct apk_name *name, { struct apk_provider *p; + name->solver_flags_set = 1; foreach_array_item(p, name->providers) { struct apk_package *pkg = p->pkg; dbg_printf("marking '" PKG_VER_FMT "' = 0x%04x / 0x%04x\n", @@ -1031,6 +1032,9 @@ static int compare_name_dequeue(const struct apk_name *a, const struct apk_name { int r; + r = !!(a->solver_flags_set) - !!(b->solver_flags_set); + if (r) return -r; + r = (int)a->priority - (int)b->priority; if (r) return r; diff --git a/test/basic17.installed b/test/basic17.installed new file mode 100644 index 0000000..ce66f47 --- /dev/null +++ b/test/basic17.installed @@ -0,0 +1,13 @@ +C:Q1EyN5AdpAOBJWKMR89pp/C66o+OE= +P:a +V:1 +S:1 +I:1 +D:b=1 + +C:Q1C4uoV7SdMdDhYg4OCVmI71D8HIA= +P:b +V:1 +S:1 +I:1 + diff --git a/test/basic17.repo b/test/basic17.repo new file mode 100644 index 0000000..cac8d9e --- /dev/null +++ b/test/basic17.repo @@ -0,0 +1,26 @@ +C:Q1EyN5AdpAOBJWKMR89pp/C66o+OE= +P:a +V:1 +S:1 +I:1 +D:b=1 + +C:Q1eVpkasfqZAukAXFYbgwt4xAMZWU= +P:a +V:2 +S:1 +I:1 +D:b=2 + +C:Q1C4uoV7SdMdDhYg4OCVmI71D8HIA= +P:b +V:1 +S:1 +I:1 + +C:Q1hdUpqRv5mYgJEqW52UmVsvmyysE= +P:b +V:2 +S:1 +I:1 + diff --git a/test/basic17.test b/test/basic17.test new file mode 100644 index 0000000..3d0b7fc --- /dev/null +++ b/test/basic17.test @@ -0,0 +1,9 @@ +@ARGS +--test-repo basic17.repo +--test-instdb basic17.installed +--test-world b +add --upgrade a +@EXPECT +(1/2) Upgrading b (1 -> 2) +(2/2) Upgrading a (1 -> 2) +OK: 0 MiB in 2 packages diff --git a/test/basic18.test b/test/basic18.test new file mode 100644 index 0000000..ff8d6b8 --- /dev/null +++ b/test/basic18.test @@ -0,0 +1,9 @@ +@ARGS +--test-repo basic17.repo +--test-instdb basic17.installed +--test-world a +add --latest b +@EXPECT +(1/2) Upgrading b (1 -> 2) +(2/2) Upgrading a (1 -> 2) +OK: 0 MiB in 2 packages |