Revert "libopkg: check installed reverse dependencies upon install/upgrade"
authorJo-Philipp Wich <jo@mein.io>
Fri, 18 Jan 2019 15:07:53 +0000 (16:07 +0100)
committerJo-Philipp Wich <jo@mein.io>
Fri, 18 Jan 2019 17:40:34 +0000 (18:40 +0100)
This reverts commit 89fe77cb119a24f728088320d66d51250a1f02ab.

After spending further thoughts on this I think this makes no sense at all
and such situations should be avoided on the repo level instead by don't
providing incompatible packages having an identical name.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg/opkg_install.c
libopkg/pkg.h
libopkg/pkg_depends.c
libopkg/pkg_hash.c

index cc8ba94..d2d919a 100644 (file)
 #include "xsystem.h"
 #include "libbb/libbb.h"
 
-static pkg_vec_t * check_dependencies_for(pkg_t *pkg, bool silent)
+static int satisfy_dependencies_for(pkg_t * pkg)
 {
-       char **tmp, **unresolved = NULL, *prev = NULL;
+       int i, err;
        pkg_vec_t *depends = pkg_vec_alloc();
+       pkg_t *dep;
+       char **tmp, **unresolved = NULL, *prev = NULL;
+       int ndepends;
 
-       pkg_hash_fetch_unsatisfied_dependencies(pkg, depends, &unresolved);
+       ndepends = pkg_hash_fetch_unsatisfied_dependencies(pkg, depends,
+                                                          &unresolved);
 
        if (unresolved) {
-               if (silent == false)
-                       opkg_msg(ERROR,
-                                "Cannot satisfy the following dependencies for %s:\n",
-                                pkg->name);
+               opkg_msg(ERROR,
+                        "Cannot satisfy the following dependencies for %s:\n",
+                        pkg->name);
                tmp = unresolved;
                while (*unresolved) {
                        if (!prev || strcmp(*unresolved, prev))
-                               if (silent == false)
-                                       opkg_message(ERROR, "\t%s\n", *unresolved);
+                               opkg_message(ERROR, "\t%s\n", *unresolved);
                        prev = *unresolved;
                        unresolved++;
                }
@@ -66,30 +68,19 @@ static pkg_vec_t * check_dependencies_for(pkg_t *pkg, bool silent)
                        unresolved++;
                }
                free(tmp);
-               pkg_vec_free(depends);
-               return NULL;
-       }
-
-       return depends;
-}
-
-static int satisfy_dependencies_for(pkg_t * pkg)
-{
-       pkg_vec_t *depends;
-       int i, err;
-       pkg_t *dep;
-
-       depends = check_dependencies_for(pkg, false);
-
-       if (depends == NULL) {
                if (!conf->force_depends) {
                        opkg_msg(INFO,
                                 "This could mean that your package list is out of date or that the packages\n"
                                 "mentioned above do not yet exist (try 'opkg update'). To proceed in spite\n"
                                 "of this problem try again with the '-force-depends' option.\n");
+                       pkg_vec_free(depends);
+                       return -1;
                }
+       }
 
-               return -1;
+       if (ndepends <= 0) {
+               pkg_vec_free(depends);
+               return 0;
        }
 
        /* Mark packages as to-be-installed */
@@ -153,67 +144,6 @@ static int check_conflicts_for(pkg_t * pkg)
        return 0;
 }
 
-static int check_reverse_depends_for(pkg_t *pkg, pkg_t *old_pkg)
-{
-       int err = 0;
-       int i, n_dependents;
-       abstract_pkg_t **dependents, *dependent;
-       pkg_vec_t *depends;
-       pkg_t *updated;
-
-       opkg_msg(DEBUG, "Checking reverse depends for %s\n", old_pkg->name);
-
-       n_dependents = pkg_has_installed_dependents(old_pkg, &dependents);
-
-       /* pretend that old package does not exist */
-       old_pkg->state_flag |= SF_IGNORE;
-
-       if (n_dependents == 0)
-               goto out;
-
-       while ((dependent = *dependents++) != NULL) {
-               if (dependent->state_status != SS_INSTALLED)
-                       continue;
-
-               if (dependent->pkgs == NULL)
-                       continue;
-
-               for (i = 0; i < dependent->pkgs->len; i++) {
-                       if (dependent->pkgs->pkgs[i]->state_status != SS_INSTALLED)
-                               continue;
-
-                       depends = check_dependencies_for(dependent->pkgs->pkgs[i], true);
-                       if (depends == NULL) {
-#if 0
-                               updated = pkg_hash_fetch_best_installation_candidate_by_name(dependent->pkgs->pkgs[i]->name);
-                               depends = updated ? check_dependencies_for(updated, false) : NULL;
-                               if (depends == NULL) {
-                                       opkg_msg(ERROR, "Package %s reverse dependency check failed\n",
-                                                pkg->name);
-                                       err = -1;
-                                       goto out;
-                               }
-                               else {
-                                       err = opkg_install_pkg(updated, 1);
-                                       if (err)
-                                               goto out;
-                               }
-#else
-                               opkg_msg(ERROR, "Package %s reverse dependency check failed\n", pkg->name);
-                               err = -1;
-                               goto out;
-#endif
-                       }
-
-                       pkg_vec_free(depends);
-               }
-       }
-
-out:
-       old_pkg->state_flag &= ~SF_IGNORE;
-       return err;
-}
-
 static int update_file_ownership(pkg_t * new_pkg, pkg_t * old_pkg)
 {
        str_list_t *new_list, *old_list;
@@ -1361,10 +1291,6 @@ int opkg_install_pkg(pkg_t * pkg, int from_upgrade)
        pkg->state_want = SW_INSTALL;
        if (old_pkg) {
                old_pkg->state_want = SW_DEINSTALL;     /* needed for check_data_file_clashes of dependencies */
-
-               err = check_reverse_depends_for(pkg, old_pkg);
-               if (err)
-                       return -1;
        }
 
        err = check_conflicts_for(pkg);
index f03bbb4..600fc9e 100644 (file)
@@ -59,7 +59,6 @@ enum pkg_state_flag {
        SF_FILELIST_CHANGED = 128,      /* needs filelist written */
        SF_USER = 256,
        SF_NEED_DETAIL = 512,
-       SF_IGNORE = 1024,               /* ignore this package in dependency checks */
        SF_LAST_STATE_FLAG
 };
 typedef enum pkg_state_flag pkg_state_flag_t;
index ae2ac9b..3abdcd3 100644 (file)
@@ -37,8 +37,7 @@ static int pkg_installed_and_constraint_satisfied(pkg_t * pkg, void *cdata)
        depend_t *depend = (depend_t *) cdata;
        if ((pkg->state_status == SS_INSTALLED
             || pkg->state_status == SS_UNPACKED)
-           && version_constraints_satisfied(depend, pkg)
-           && !(pkg->state_flag & SF_IGNORE))
+           && version_constraints_satisfied(depend, pkg))
                return 1;
        else
                return 0;
@@ -47,8 +46,7 @@ static int pkg_installed_and_constraint_satisfied(pkg_t * pkg, void *cdata)
 static int pkg_constraint_satisfied(pkg_t * pkg, void *cdata)
 {
        depend_t *depend = (depend_t *) cdata;
-       if (version_constraints_satisfied(depend, pkg)
-           && !(pkg->state_flag & SF_IGNORE))
+       if (version_constraints_satisfied(depend, pkg))
                return 1;
        else
                return 0;
index a474a18..611f3b9 100644 (file)
@@ -357,33 +357,12 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
                /* now check for supported architecture */
                {
                        int max_count = 0;
-                       int found_apkg = 0;
 
                        /* count packages matching max arch priority and keep track of last one */
                        for (j = 0; j < vec->len; j++) {
                                pkg_t *maybe = vec->pkgs[j];
                                arch_priority = pkg_get_arch_priority(maybe);
 
-                               /* check if this package actually provides the requested
-                                  abstract package */
-                               found_apkg = 0;
-                               provided_apkgs = pkg_get_ptr(maybe, PKG_PROVIDES);
-
-                               while (provided_apkgs && *provided_apkgs) {
-                                       if (!strcmp((*provided_apkgs)->name, apkg->name)) {
-                                               found_apkg = 1;
-                                               break;
-                                       }
-                                       provided_apkgs++;
-                               }
-
-                               if (found_apkg == 0) {
-                                       opkg_msg(DEBUG,
-                                               "%s version=%s skipped since it does not provide %s\n",
-                                               maybe->name, pkg_get_string(maybe, PKG_VERSION), apkg->name);
-                                       continue;
-                               }
-
                                opkg_msg(DEBUG,
                                         "%s arch=%s arch_priority=%d version=%s.\n",
                                         maybe->name, pkg_get_architecture(maybe),