diff options
author | pixdamix@gmail.com <pixdamix@gmail.com@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2012-11-22 04:17:43 (EST) |
---|---|---|
committer | pixdamix@gmail.com <pixdamix@gmail.com@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358> | 2012-11-22 04:17:43 (EST) |
commit | ea1f09e2112cf5c98d45c973af0bcc34fb3f43f1 (patch) | |
tree | 9e9f6ea36267fcfcf6b447c8ec0d0a50b0527aa1 /libopkg/opkg_install.c | |
parent | 341202d382d0e721d311f530168d494c58348145 (diff) |
Fix dependency issues for preinst scripts
There is a problem with dependency order when installing packages. The key
problem revolves around the satisfy_dependencies_for() function which is
called from opkg_install_pkg just before the installation (and preinst)
happens.
The satisfy_dependencies_for() function calls pkg_hash_fetch_unsatisfied_dependencies()
which will only return packages which were previously not marked as
*going* to be installed at some point. For the purposes of
opkg_install_pkg() we really need to know which dependencies haven't been
installed yet.
This patch adds pkg_hash_fetch_satisfied_dependencies() which returns a
list of package dependencies. We can then directly check the status of
these and ensure any hard dependencies (not suggestions or recommendations)
are installed before returning.
Consider the situation (where -> means 'depends on'):
X -> A,E
A -> B,E
E -> B
B -> C
Currently X would install A and E. When installing A the packages B, E
and C would be marked as "to install". When the package B is considered
the second time (as a dependency of E rather than A), it would install
straight away even though C was not currently installed, just marked
as needing to be installed.
The patch changes the behaviour so B can't install until C really is installed.
This change is required to run the postinst scripts in the correct order.
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
git-svn-id: http://opkg.googlecode.com/svn/trunk@638 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/opkg_install.c')
-rw-r--r-- | libopkg/opkg_install.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libopkg/opkg_install.c b/libopkg/opkg_install.c index 3925f58..6ed67d2 100644 --- a/libopkg/opkg_install.c +++ b/libopkg/opkg_install.c @@ -77,6 +77,27 @@ satisfy_dependencies_for(pkg_t *pkg) if (ndepends <= 0) { pkg_vec_free(depends); + depends = pkg_hash_fetch_satisfied_dependencies(pkg); + + for (i = 0; i < depends->len; i++) { + dep = depends->pkgs[i]; + /* The package was uninstalled when we started, but another + dep earlier in this loop may have depended on it and pulled + it in, so check first. */ + if ((dep->state_status != SS_INSTALLED) && (dep->state_status != SS_UNPACKED)) { + opkg_msg(DEBUG2,"Calling opkg_install_pkg.\n"); + err = opkg_install_pkg(dep, 0); + /* mark this package as having been automatically installed to + * satisfy a dependency */ + dep->auto_installed = 1; + if (err) { + pkg_vec_free(depends); + return err; + } + } + } + + pkg_vec_free(depends); return 0; } |