diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2012-10-04 08:29:01 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2012-10-04 08:29:01 +0000 |
commit | 64b6ed1cbd58cffcd09fa198e505207f3a7a4a20 (patch) | |
tree | 43188dcff68b1a3ca3adeacc1b8f1c3c4a717859 /main/apk-tools | |
parent | f3633b129534bf3eb502de242916fd4a612631ff (diff) | |
download | aports-64b6ed1cbd58cffcd09fa198e505207f3a7a4a20.tar.bz2 aports-64b6ed1cbd58cffcd09fa198e505207f3a7a4a20.tar.xz |
main/apk-tools: solver fixes from upstream
Diffstat (limited to 'main/apk-tools')
5 files changed, 306 insertions, 4 deletions
diff --git a/main/apk-tools/0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch b/main/apk-tools/0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch index f3554419b5..15436ca595 100644 --- a/main/apk-tools/0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch +++ b/main/apk-tools/0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch @@ -34,5 +34,5 @@ index efff29f..d1a8f1a 100644 if (fchownat(db->root_fd, dir->name, dir->uid, dir->gid, 0) != 0) -- -1.7.12 +1.7.12.2 diff --git a/main/apk-tools/0004-solver-fix-compile-with-Werror-on-64bit.patch b/main/apk-tools/0004-solver-fix-compile-with-Werror-on-64bit.patch new file mode 100644 index 0000000000..74043d60e7 --- /dev/null +++ b/main/apk-tools/0004-solver-fix-compile-with-Werror-on-64bit.patch @@ -0,0 +1,25 @@ +From 00958d92070c583e4fa9d01f5010bce12bcd1b40 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Wed, 3 Oct 2012 09:04:35 +0200 +Subject: [PATCH] solver: fix compile with -Werror on 64bit + +--- + src/solver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/solver.c b/src/solver.c +index ec44958..f9a2117 100644 +--- a/src/solver.c ++++ b/src/solver.c +@@ -1664,7 +1664,7 @@ static void update_progress(struct progress *prog, size_t percent) + draw_progress(percent); + if (prog->progress_fd != 0) { + char buf[8]; +- size_t n = snprintf(buf, sizeof(buf), "%d\n", percent); ++ size_t n = snprintf(buf, sizeof(buf), "%zu\n", percent); + write(prog->progress_fd, buf, n); + } + } +-- +1.7.12.2 + diff --git a/main/apk-tools/0005-solver-improve-assert-error-messages.patch b/main/apk-tools/0005-solver-improve-assert-error-messages.patch new file mode 100644 index 0000000000..0773efcf6a --- /dev/null +++ b/main/apk-tools/0005-solver-improve-assert-error-messages.patch @@ -0,0 +1,32 @@ +From 081155c438c0680b868175c95d160f1e3b519541 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Wed, 3 Oct 2012 09:16:28 +0200 +Subject: [PATCH] solver: improve assert error messages + +Print name of package and void double "ERROR" +--- + src/solver.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/solver.c b/src/solver.c +index f9a2117..edf1650 100644 +--- a/src/solver.c ++++ b/src/solver.c +@@ -927,11 +927,12 @@ static int next_branch(struct apk_solver_state *ss) + + #ifdef DEBUG_CHECKS + ASSERT(cmpscore(&d->saved_score, &ss->score) == 0, +- "ERROR! saved_score "SCORE_FMT" != score "SCORE_FMT, ++ "Saved_score "SCORE_FMT" != score "SCORE_FMT, + SCORE_PRINTF(&d->saved_score), + SCORE_PRINTF(&ss->score)); + ASSERT(d->saved_requirers == name->ss.requirers, +- "ERROR! requirers not restored between decisions"); ++ "Requirers not restored between decisions (%s)", ++ name->name); + #endif + + if (backup_until >= ss->num_decisions && +-- +1.7.12.2 + diff --git a/main/apk-tools/0006-solver-various-fixes.patch b/main/apk-tools/0006-solver-various-fixes.patch new file mode 100644 index 0000000000..8c11c53117 --- /dev/null +++ b/main/apk-tools/0006-solver-various-fixes.patch @@ -0,0 +1,239 @@ +From 4dd8c58df9aa2e7821a7d5bb50407033858ed1c3 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi> +Date: Wed, 3 Oct 2012 14:59:48 +0300 +Subject: [PATCH] solver: various fixes + + * push_decision expects to always get the package primary 'name' + as apk_name. ASSERT that and fix problem cases. + (though - this might need to be reverted, and store the non + primary name in apk_decision instead to accomodate for better + backtracking optimizations) + * fix error reporting of virtual package names + * make 'assign_name' errors soft. the incorrect packages just are + no longer consider instead of aborting whole calculation. + * fix backtracking of virtual packages that are not depended + directly +--- + src/solver.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++------------ + 1 file changed, 58 insertions(+), 14 deletions(-) + +diff --git a/src/solver.c b/src/solver.c +index edf1650..3fb7832 100644 +--- a/src/solver.c ++++ b/src/solver.c +@@ -706,10 +706,14 @@ static inline void assign_name( + struct apk_solver_state *ss, struct apk_name *name, struct apk_provider p) + { + if (p.version == &apk_null_blob) { +- ASSERT(!name->ss.locked || name->ss.chosen.version == &apk_null_blob, +- "Assigning locked name with version"); ++ /* Assigning locked name with version is a problem; ++ * generally package providing same name twice */ ++ if (name->ss.locked && name->ss.chosen.version != &apk_null_blob) ++ ss->impossible_state = 1; + } else { +- ASSERT(!name->ss.locked, "Assigning locked name"); ++ /* Similar to above */ ++ if (name->ss.locked) ++ ss->impossible_state = 1; + } + name->ss.chosen = p; + name->ss.locked++; +@@ -721,7 +725,7 @@ static inline void assign_name( + + static inline void unassign_name(struct apk_solver_state *ss, struct apk_name *name) + { +- ASSERT(name->ss.locked, "Unassigning unlocked name"); ++ ASSERT(name->ss.locked, "Unassigning unlocked name %s", name->name); + name->ss.locked--; + if (name->ss.locked == 0) { + name->ss.chosen = CHOSEN_NONE; +@@ -793,7 +797,7 @@ static solver_result_t apply_decision(struct apk_solver_state *ss, + addscore(&ss->score, &score); + + name->ss.chosen = CHOSEN_NONE; +- name->ss.locked = 1; ++ name->ss.locked++; + list_del(&name->ss.unsolved_list); + list_init(&name->ss.unsolved_list); + } else { +@@ -847,7 +851,7 @@ static void undo_decision(struct apk_solver_state *ss, + for (i = 0; i < pkg->provides->num; i++) + pkg->provides->item[i].name->ss.name_touched = 1; + +- if (name->ss.locked) { ++ if (d->type == DECISION_ASSIGN) { + if (ps->handle_install_if) + foreach_rinstall_if_pkg(ss, pkg, untrigger_install_if); + foreach_dependency(ss, pkg->depends, undo_constraint); +@@ -871,12 +875,12 @@ static void undo_decision(struct apk_solver_state *ss, + if (d->type == DECISION_ASSIGN) { + get_unassigned_score(name, &score); + subscore(&ss->score, &score); ++ name->ss.locked--; + } else { + name->ss.none_excluded = 0; + } + + /* Put back the name to unsolved list */ +- name->ss.locked = 0; + promote_name(ss, name); + } + } +@@ -890,6 +894,9 @@ static solver_result_t push_decision(struct apk_solver_state *ss, + { + struct apk_decision *d; + ++ ASSERT(pkg == NULL || pkg->name == name, ++ "push_decision got non-primary name: %s != %s", ++ pkg->name->name, name->name); + ASSERT(ss->num_decisions <= ss->max_decisions, + "Decision tree overflow."); + +@@ -897,6 +904,8 @@ static solver_result_t push_decision(struct apk_solver_state *ss, + d = &ss->decisions[ss->num_decisions]; + + #ifdef DEBUG_CHECKS ++ dbg_printf("Saving score ("SCORE_FMT") and requirers (%d) for %s\n", ++ SCORE_PRINTF(&ss->score), name->ss.requirers, name->name); + d->saved_score = ss->score; + d->saved_requirers = name->ss.requirers; + #endif +@@ -911,6 +920,12 @@ static solver_result_t push_decision(struct apk_solver_state *ss, + d->pkg = pkg; + d->no_package = 0; + } ++ /* FIXME: this is needed for virtual packages - should possible ++ * consider making backtracking information also keep the ++ * virtual apk_name causing the touched information to be more ++ * accurate */ ++ if (name->ss.last_touched_decision == 0) ++ name->ss.last_touched_decision = ss->num_decisions; + + return apply_decision(ss, d); + } +@@ -931,8 +946,8 @@ static int next_branch(struct apk_solver_state *ss) + SCORE_PRINTF(&d->saved_score), + SCORE_PRINTF(&ss->score)); + ASSERT(d->saved_requirers == name->ss.requirers, +- "Requirers not restored between decisions (%s)", +- name->name); ++ "Requirers not restored between decisions (%s), %d != %d", ++ name->name, d->saved_requirers, name->ss.requirers); + #endif + + if (backup_until >= ss->num_decisions && +@@ -940,6 +955,10 @@ static int next_branch(struct apk_solver_state *ss) + d->branching_point = BRANCH_NO; + d->type = (d->type == DECISION_ASSIGN) ? DECISION_EXCLUDE : DECISION_ASSIGN; + return apply_decision(ss, d); ++ } else { ++ if (d->branching_point == BRANCH_YES) ++ dbg_printf("skipping %s, %d < %d\n", ++ name->name, backup_until, ss->num_decisions); + } + + if (d->no_package && !d->found_solution) { +@@ -963,11 +982,15 @@ static void apply_constraint(struct apk_solver_state *ss, struct apk_dependency + if (ss->num_decisions > 0) { + requirer_name = decision_to_name(&ss->decisions[ss->num_decisions]); + requirer_pkg = decision_to_pkg(&ss->decisions[ss->num_decisions]); ++ /* FIXME: should probably take into account the requirer ++ * package's provided name's 'requirer strength' */ + strength = requirer_name->ss.requirers ?: 1; + } else { + strength = 1; + } + ++ dbg_printf("--->apply_constraint: %s (strength %d)\n", name->name, strength); ++ + if (name->ss.locked) { + if (name->ss.chosen.pkg) + dbg_printf("%s: locked to " PKG_VER_FMT " already\n", +@@ -1021,8 +1044,10 @@ static void apply_constraint(struct apk_solver_state *ss, struct apk_dependency + if (changed) + name->ss.last_touched_decision = ss->num_decisions; + +- if (!dep->conflict) ++ if (!dep->conflict) { ++ dbg_printf("%s requirers += %d\n", name->name, strength); + name->ss.requirers += strength; ++ } + + promote_name(ss, name); + } +@@ -1041,6 +1066,8 @@ static void undo_constraint(struct apk_solver_state *ss, struct apk_dependency * + strength = 1; + } + ++ dbg_printf("--->undo_constraint: %s (strength %d)\n", name->name, strength); ++ + if (name->ss.locked) { + if (name->ss.chosen.pkg != NULL) { + dbg_printf(PKG_VER_FMT " selected already for %s\n", +@@ -1091,8 +1118,16 @@ static void undo_constraint(struct apk_solver_state *ss, struct apk_dependency * + if (name->ss.last_touched_decision > ss->num_decisions) + name->ss.last_touched_decision = ss->num_decisions; + +- if (!dep->conflict) ++ if (requirer_name && requirer_name->ss.requirers != strength) { ++ dbg_printf("requirer %s, dependency %s: strength mismatch %d != %d\n", ++ requirer_name->name, name->name, ++ requirer_name->ss.requirers, strength); ++ } ++ ++ if (!dep->conflict) { + name->ss.requirers -= strength; ++ dbg_printf("%s requirers -= %d\n", name->name, strength); ++ } + + demote_name(ss, name); + } +@@ -1144,7 +1179,7 @@ static int reconsider_name(struct apk_solver_state *ss, struct apk_name *name) + + /* viable alternative? */ + if (cmpscore2(&ss->score, &pkg0_score, &ss->best_score) >= 0) +- return push_decision(ss, name, pkg0, DECISION_EXCLUDE, BRANCH_NO, FALSE); ++ return push_decision(ss, pkg0->name, pkg0, DECISION_EXCLUDE, BRANCH_NO, FALSE); + + if (cmpscore(&pkg0_score, &best_score) < 0) { + best_score = pkg0_score; +@@ -1169,9 +1204,10 @@ static int reconsider_name(struct apk_solver_state *ss, struct apk_name *name) + return SOLVERR_PRUNED; + return push_decision(ss, name, NULL, DECISION_ASSIGN, BRANCH_NO, FALSE); + } else if (options == 1 && score_locked && name->ss.none_excluded && name == next_p->pkg->name) { ++ struct apk_package *pkg0 = next_p->pkg; + dbg_printf("reconsider_name: %s: only one choice left with known score, locking.\n", + name->name); +- return push_decision(ss, name, next_p->pkg, DECISION_ASSIGN, BRANCH_NO, FALSE); ++ return push_decision(ss, pkg0->name, pkg0, DECISION_ASSIGN, BRANCH_NO, FALSE); + } + + name->ss.chosen = *next_p; +@@ -1916,7 +1952,10 @@ static void print_dep_errors(struct apk_database *db, char *label, + + for (i = 0; i < deps->num; i++) { + struct apk_dependency *dep = &deps->item[i]; +- struct apk_package *pkg = (struct apk_package*) dep->name->state_ptr; ++ struct apk_package *pkg = NULL; ++ ++ if (dep->name->state_int != 1) ++ pkg = (struct apk_package*) dep->name->state_ptr; + + if (apk_dep_is_materialized_or_provided(dep, pkg)) + continue; +@@ -1953,6 +1992,11 @@ void apk_solver_print_errors(struct apk_database *db, + for (i = 0; i < solution->num; i++) { + struct apk_package *pkg = solution->item[i].pkg; + pkg->name->state_ptr = pkg; ++ for (j = 0; j < pkg->provides->num; j++) { ++ if (pkg->provides->item[j].version == &apk_null_blob) ++ continue; ++ pkg->provides->item[j].name->state_ptr = pkg; ++ } + } + + print_dep_errors(db, "world", world, &names); +-- +1.7.12.2 + diff --git a/main/apk-tools/APKBUILD b/main/apk-tools/APKBUILD index 85946fcbe3..699b5d3cbf 100644 --- a/main/apk-tools/APKBUILD +++ b/main/apk-tools/APKBUILD @@ -1,7 +1,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=apk-tools pkgver=2.3.2 -pkgrel=2 +pkgrel=3 pkgdesc="Alpine Package Keeper - package manager for alpine" subpackages="$pkgname-static lua-apk:luaapk" depends= @@ -10,6 +10,9 @@ source="http://git.alpinelinux.org/cgit/$pkgname/snapshot/$pkgname-$pkgver.tar.b 0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch 0002-apk-implement-progress-fd-to-write-progress-to-a-spe.patch 0003-info-provides-alias-p-is-reserved-for-root-use-P.patch + 0004-solver-fix-compile-with-Werror-on-64bit.patch + 0005-solver-improve-assert-error-messages.patch + 0006-solver-various-fixes.patch " url="http://git.alpinelinux.org/cgit/apk-tools/" @@ -62,6 +65,9 @@ luaapk() { } md5sums="813b7c9fd7f6159972dc4fa5dfcc97c5 apk-tools-2.3.2.tar.bz2 -a5a635f510e6f69b1e2f6cadb45efe04 0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch +e755492397eba99b3fe698151e4241ff 0001-db-remove-AT_SYMLINK_NOFOLLOW-for-directory-permissi.patch 0a96443650fec545667b6eccc5d9ef1e 0002-apk-implement-progress-fd-to-write-progress-to-a-spe.patch -6718b405982c5bfeed3761a9d57cfce8 0003-info-provides-alias-p-is-reserved-for-root-use-P.patch" +6718b405982c5bfeed3761a9d57cfce8 0003-info-provides-alias-p-is-reserved-for-root-use-P.patch +c32124de6cee4b1bea2d5e2ac954d73a 0004-solver-fix-compile-with-Werror-on-64bit.patch +79188874b0a35983b182fa48b7c91643 0005-solver-improve-assert-error-messages.patch +b83138b13bf534046d6cb7c62be87a69 0006-solver-various-fixes.patch" |