summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2020-11-03 04:09:21 +0000
committerDaniel Golle2020-11-03 04:37:36 +0000
commitda9746aaa28fdc63a6e062bf00b25eba52bc8e5f (patch)
tree558f66b6fc206e3a08219dbe84e779d19d927dd6
parent383748952eb927737de89a5791599a0ca8f96c4d (diff)
downloadopkg-lede-da9746aaa28fdc63a6e062bf00b25eba52bc8e5f.tar.gz
libopkg: clean up handling of unresolved dependencies
Drastically improves performance, back to the level seen before the previous commit. Fixes: 3837489 ("libopkg: work-around yet another dependency checking problem") Signed-off-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Paul Spooren <mail@aparcar.org>
-rw-r--r--libopkg/opkg.c2
-rw-r--r--libopkg/opkg_install.c2
-rw-r--r--libopkg/pkg.h4
-rw-r--r--libopkg/pkg_depends.c21
-rw-r--r--libopkg/pkg_depends.h2
-rw-r--r--libopkg/pkg_hash.c32
6 files changed, 30 insertions, 33 deletions
diff --git a/libopkg/opkg.c b/libopkg/opkg.c
index 3583488..85ab5a0 100644
--- a/libopkg/opkg.c
+++ b/libopkg/opkg.c
@@ -238,7 +238,7 @@ opkg_install_package(const char *package_name,
/* find dependancies and download them */
deps = pkg_vec_alloc();
/* this function does not return the original package, so we insert it later */
- pkg_hash_fetch_unsatisfied_dependencies(new, deps, &unresolved);
+ pkg_hash_fetch_unsatisfied_dependencies(new, deps, &unresolved, 0);
if (unresolved) {
char **tmp = unresolved;
opkg_msg(ERROR, "Couldn't satisfy the following dependencies"
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c
index 27c9484..62db965 100644
--- a/libopkg/opkg_install.c
+++ b/libopkg/opkg_install.c
@@ -49,7 +49,7 @@ static int satisfy_dependencies_for(pkg_t * pkg)
int ndepends;
ndepends = pkg_hash_fetch_unsatisfied_dependencies(pkg, depends,
- &unresolved);
+ &unresolved, 0);
if (unresolved) {
opkg_msg(ERROR,
diff --git a/libopkg/pkg.h b/libopkg/pkg.h
index 28998f3..bc0e030 100644
--- a/libopkg/pkg.h
+++ b/libopkg/pkg.h
@@ -113,8 +113,8 @@ struct abstract_pkg {
abstract_pkg_vec_t *provided_by;
abstract_pkg_vec_t *replaced_by;
- int dependencies_checked:2;
- int prev_dependencies_checked:2;
+ char dependencies_checked;
+ char pre_dependencies_checked;
pkg_state_status_t state_status:4;
pkg_state_flag_t state_flag:11;
};
diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c
index 3abdcd3..a95fceb 100644
--- a/libopkg/pkg_depends.c
+++ b/libopkg/pkg_depends.c
@@ -55,7 +55,7 @@ static int pkg_constraint_satisfied(pkg_t * pkg, void *cdata)
/* returns ndependencies or negative error value */
int
pkg_hash_fetch_unsatisfied_dependencies(pkg_t * pkg, pkg_vec_t * unsatisfied,
- char ***unresolved)
+ char ***unresolved, int pre_check)
{
pkg_t *satisfier_entry_pkg;
int i, j, k;
@@ -63,6 +63,7 @@ pkg_hash_fetch_unsatisfied_dependencies(pkg_t * pkg, pkg_vec_t * unsatisfied,
char **the_lost;
abstract_pkg_t *ab_pkg;
compound_depend_t *compound_depend;
+ char *check;
/*
* this is a setup to check for redundant/cyclic dependency checks,
@@ -73,11 +74,19 @@ pkg_hash_fetch_unsatisfied_dependencies(pkg_t * pkg, pkg_vec_t * unsatisfied,
*unresolved = NULL;
return 0;
}
- if (ab_pkg->dependencies_checked) { /* avoid duplicate or cyclic checks */
+
+ if(pre_check) {
+ check = &ab_pkg->pre_dependencies_checked;
+ } else {
+ check = &ab_pkg->dependencies_checked;
+ }
+
+ if (*check) { /* avoid duplicate or cyclic checks */
*unresolved = NULL;
return 0;
} else {
- ab_pkg->dependencies_checked = 1; /* mark it for subsequent visits */
+ /* mark it for subsequent visits */
+ *check = 1;
}
compound_depend = pkg_get_ptr(pkg, PKG_DEPENDS);
@@ -117,14 +126,14 @@ pkg_hash_fetch_unsatisfied_dependencies(pkg_t * pkg, pkg_vec_t * unsatisfied,
pkg_t *pkg_scout = test_vec->pkgs[k];
/* not installed, and not already known about? */
if ((pkg_scout->state_want != SW_INSTALL)
- && !pkg_scout->parent->dependencies_checked
+ && !(pre_check ? pkg_scout->parent->pre_dependencies_checked : pkg_scout->parent->dependencies_checked)
&& !is_pkg_in_pkg_vec(unsatisfied, pkg_scout)) {
char **newstuff = NULL;
int rc;
pkg_vec_t *tmp_vec = pkg_vec_alloc();
/* check for not-already-installed dependencies */
rc = pkg_hash_fetch_unsatisfied_dependencies(
- pkg_scout, tmp_vec, &newstuff);
+ pkg_scout, tmp_vec, &newstuff, pre_check);
if (newstuff == NULL) {
int m;
int ok = 1;
@@ -251,7 +260,7 @@ pkg_hash_fetch_unsatisfied_dependencies(pkg_t * pkg, pkg_vec_t * unsatisfied,
!is_pkg_in_pkg_vec(unsatisfied, satisfier_entry_pkg))
{
pkg_hash_fetch_unsatisfied_dependencies(
- satisfier_entry_pkg, unsatisfied, &newstuff);
+ satisfier_entry_pkg, unsatisfied, &newstuff, pre_check);
pkg_vec_insert(unsatisfied, satisfier_entry_pkg);
the_lost = merge_unresolved(the_lost, newstuff);
if (newstuff)
diff --git a/libopkg/pkg_depends.h b/libopkg/pkg_depends.h
index af897b2..de1dabf 100644
--- a/libopkg/pkg_depends.h
+++ b/libopkg/pkg_depends.h
@@ -89,7 +89,7 @@ char *pkg_depend_str(pkg_t * pkg, int index);
void buildDependedUponBy(pkg_t * pkg, abstract_pkg_t * ab_pkg);
int version_constraints_satisfied(depend_t * depends, pkg_t * pkg);
int pkg_hash_fetch_unsatisfied_dependencies(pkg_t * pkg, pkg_vec_t * depends,
- char ***unresolved);
+ char ***unresolved, int pre_check);
pkg_vec_t *pkg_hash_fetch_conflicts(pkg_t * pkg);
int pkg_dependence_satisfiable(depend_t * depend);
const char *constraint_to_str(enum version_constraint c);
diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c
index 6eeedec..6b40872 100644
--- a/libopkg/pkg_hash.c
+++ b/libopkg/pkg_hash.c
@@ -279,17 +279,11 @@ pkg_hash_check_unresolved(pkg_t *maybe)
{
char **unresolved = NULL;
char **tmp;
- pkg_vec_t *depends, *all;
- int i, res = 0;
+ pkg_vec_t *depends;
+ int res = 0;
depends = pkg_vec_alloc();
- all = pkg_vec_alloc();
- pkg_hash_fetch_available(all);
- /* backup dependencies_checked marks, they get destroyed by pkg_hash_fetch_unsatisfied_dependencies */
- for (i = 0; i < all->len; i++)
- all->pkgs[i]->parent->prev_dependencies_checked = all->pkgs[i]->parent->dependencies_checked;
-
- pkg_hash_fetch_unsatisfied_dependencies(maybe, depends, &unresolved);
+ pkg_hash_fetch_unsatisfied_dependencies(maybe, depends, &unresolved, 1);
if (unresolved) {
res = 1;
@@ -300,12 +294,6 @@ pkg_hash_check_unresolved(pkg_t *maybe)
}
pkg_vec_free(depends);
- /* restore dependencies_checked marks */
- for (i = 0; i < all->len; i++)
- all->pkgs[i]->parent->dependencies_checked = all->pkgs[i]->parent->prev_dependencies_checked;
-
- pkg_vec_free(all);
-
return res;
}
@@ -411,13 +399,13 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
they show up twice sometimes. */
if ((arch_priority > 0)
&&
- (!pkg_vec_contains(matching_pkgs, maybe))
- &&
- (!pkg_hash_check_unresolved(maybe))) {
- max_count++;
- abstract_pkg_vec_insert(matching_apkgs,
- maybe->parent);
- pkg_vec_insert(matching_pkgs, maybe);
+ (!pkg_vec_contains(matching_pkgs, maybe))) {
+ if (!pkg_hash_check_unresolved(maybe)) {
+ max_count++;
+ abstract_pkg_vec_insert(matching_apkgs,
+ maybe->parent);
+ pkg_vec_insert(matching_pkgs, maybe);
+ }
}
}