Commit cab03b69 authored by Timo Teräs's avatar Timo Teräs

sort world dependencies alphabetically

this makes 'lbu diff' and aaudit diffs nice when a world
dependency is added or removed. sorting also makes the ordering
more deterministic as the world targets constraints are always
applied in the same order. test suite updated accordingly.
parent cd6786bc
......@@ -897,6 +897,12 @@ static int free_package(apk_hash_item item, void *ctx)
return 0;
}
static int cmp_pkgname(const void *p1, const void *p2)
{
const struct apk_dependency *d1 = p1, *d2 = p2;
return strcmp(d1->name->name, d2->name->name);
}
int apk_solver_solve(struct apk_database *db,
unsigned short solver_flags,
struct apk_dependency_array *world,
......@@ -907,6 +913,8 @@ int apk_solver_solve(struct apk_database *db,
struct apk_solver_state ss_data, *ss = &ss_data;
struct apk_dependency *d;
qsort(world->item, world->num, sizeof(world->item[0]), cmp_pkgname);
restart:
memset(ss, 0, sizeof(*ss));
ss->db = db;
......
......@@ -2,8 +2,8 @@
--test-repo installif1.repo
add foo app
@EXPECT
(1/4) Installing foo (1)
(2/4) Installing lib (1)
(3/4) Installing app (1)
(1/4) Installing lib (1)
(2/4) Installing app (1)
(3/4) Installing foo (1)
(4/4) Installing appiif1 (1)
OK: 0 MiB in 0 packages
......@@ -2,10 +2,10 @@
--test-repo installif1.repo
add foo app bar
@EXPECT
(1/6) Installing foo (1)
(2/6) Installing lib (1)
(3/6) Installing app (1)
(4/6) Installing appiif1 (1)
(5/6) Installing bar (1)
(6/6) Installing appiif2 (1)
(1/6) Installing lib (1)
(2/6) Installing app (1)
(3/6) Installing bar (1)
(4/6) Installing appiif2 (1)
(5/6) Installing foo (1)
(6/6) Installing appiif1 (1)
OK: 0 MiB in 0 packages
......@@ -3,8 +3,8 @@
--test-repo installif2.repo
add foo app
@EXPECT
(1/4) Installing foo (1)
(2/4) Installing lib (1)
(3/4) Installing app (1)
(1/4) Installing lib (1)
(2/4) Installing app (1)
(3/4) Installing foo (1)
(4/4) Installing appiif1 (1)
OK: 0 MiB in 0 packages
......@@ -2,6 +2,6 @@
--test-repo provides.repo
add mymailreader mailreadplus
@EXPECT
(1/2) Installing mymailreader (1)
(2/2) Installing mailreadplus (1)
(1/2) Installing mailreadplus (1)
(2/2) Installing mymailreader (1)
OK: 0 MiB in 0 packages
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment