From cab03b6912ba4dc85d72ad0abfcd99f4fd935876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timo=20Ter=C3=A4s?= Date: Fri, 30 Jan 2015 15:53:11 +0200 Subject: [PATCH] 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. --- src/solver.c | 8 ++++++++ test/installif1.test | 6 +++--- test/installif2.test | 12 ++++++------ test/installif3.test | 6 +++--- test/provides4.test | 4 ++-- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/solver.c b/src/solver.c index 2c507cb..8f9e724 100644 --- a/src/solver.c +++ b/src/solver.c @@ -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; diff --git a/test/installif1.test b/test/installif1.test index ca3aeeb..117e397 100644 --- a/test/installif1.test +++ b/test/installif1.test @@ -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 diff --git a/test/installif2.test b/test/installif2.test index 85f66dc..c5c10e9 100644 --- a/test/installif2.test +++ b/test/installif2.test @@ -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 diff --git a/test/installif3.test b/test/installif3.test index f5ac259..1141577 100644 --- a/test/installif3.test +++ b/test/installif3.test @@ -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 diff --git a/test/provides4.test b/test/provides4.test index 6588926..e118ade 100644 --- a/test/provides4.test +++ b/test/provides4.test @@ -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