summaryrefslogtreecommitdiff
path: root/src/solver.c
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2015-01-30 15:53:11 +0200
committerTimo Teräs <timo.teras@iki.fi>2015-01-30 15:53:11 +0200
commitcab03b6912ba4dc85d72ad0abfcd99f4fd935876 (patch)
treebf281dc98957c13f369f9ad1b44a36311831d923 /src/solver.c
parentcd6786bc30ef4e6443dd45604863c9619a346681 (diff)
downloadapk-tools-cab03b6912ba4dc85d72ad0abfcd99f4fd935876.tar.gz
apk-tools-cab03b6912ba4dc85d72ad0abfcd99f4fd935876.tar.bz2
apk-tools-cab03b6912ba4dc85d72ad0abfcd99f4fd935876.tar.xz
apk-tools-cab03b6912ba4dc85d72ad0abfcd99f4fd935876.zip
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.
Diffstat (limited to 'src/solver.c')
-rw-r--r--src/solver.c8
1 files changed, 8 insertions, 0 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;