From 1eb9ea591ad1bfd4de066ac0485401eef645761d Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 9 Feb 2009 16:39:55 +0100 Subject: [PATCH] Fix binpkg dependency installation with new code. --HG-- extra : convert_revision : fc6c3fd108caf4cedec0edd3b813edbdfb6bd8be --- include/install.h | 2 +- lib/depends.c | 23 ++++++++++++++++++----- lib/install.c | 2 +- lib/unpack.c | 19 +++++++++++++++++-- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/include/install.h b/include/install.h index eebec35c8d9..57edbec734a 100644 --- a/include/install.h +++ b/include/install.h @@ -27,7 +27,7 @@ #define _XBPS_INSTALL_H_ /* From lib/install.c, lib/depends.c and lib/unpack.c */ -int xbps_install_pkg_deps(prop_dictionary_t); +int xbps_install_pkg_deps(prop_dictionary_t, const char *); int xbps_install_binary_pkg(const char *, const char *); int xbps_install_binary_pkg_fini(prop_dictionary_t, prop_dictionary_t, const char *); diff --git a/lib/depends.c b/lib/depends.c index a7f51f195a0..6b644835167 100644 --- a/lib/depends.c +++ b/lib/depends.c @@ -116,7 +116,7 @@ store_dependency(prop_dictionary_t origind, prop_dictionary_t depd, uint32_t prio = 0; size_t len = 0; const char *pkgname, *version, *reqbyname, *reqbyver; - const char *repoloc, *binfile, *array_key = NULL, *originpkg; + const char *repoloc, *binfile, *array_key, *originpkg, *short_desc; char *reqby; int rv = 0; @@ -130,6 +130,7 @@ store_dependency(prop_dictionary_t origind, prop_dictionary_t depd, prop_dictionary_get_cstring_nocopy(depd, "pkgname", &pkgname); prop_dictionary_get_cstring_nocopy(depd, "version", &version); prop_dictionary_get_cstring_nocopy(depd, "filename", &binfile); + prop_dictionary_get_cstring_nocopy(depd, "short_desc", &short_desc); prop_dictionary_get_uint32(depd, "priority", &prio); prop_dictionary_get_cstring_nocopy(origind, "pkgname", &reqbyname); prop_dictionary_get_cstring_nocopy(origind, "version", &reqbyver); @@ -221,6 +222,7 @@ store_dependency(prop_dictionary_t origind, prop_dictionary_t depd, prop_dictionary_set_cstring(dict, "repository", repoloc); prop_dictionary_set_cstring(dict, "filename", binfile); prop_dictionary_set_uint32(dict, "priority", prio); + prop_dictionary_set_cstring(dict, "short_desc", short_desc); } /* * Add the dictionary into the array. @@ -406,7 +408,7 @@ out: } int -xbps_install_pkg_deps(prop_dictionary_t pkg) +xbps_install_pkg_deps(prop_dictionary_t pkg, const char *destdir) { prop_array_t array, installed, direct, indirect; prop_dictionary_t dict; @@ -414,7 +416,7 @@ xbps_install_pkg_deps(prop_dictionary_t pkg) prop_object_iterator_t iter; uint32_t maxprio = 0, prio = 0; size_t curidx = 0, idx = 0; - const char *array_key, *reqby, *curname; + const char *array_key, *reqby, *curname, *curver; int rv = 0; assert(pkg != NULL); @@ -447,7 +449,10 @@ xbps_install_pkg_deps(prop_dictionary_t pkg) again: array = prop_dictionary_get(chaindeps, array_key); - if (array == NULL || prop_array_count(array) == 0) { + if (array && prop_array_count(array) == 0) { + rv = 0; + goto out; + } else if (array == NULL || prop_array_count(array) == 0) { rv = EINVAL; goto out; } @@ -475,8 +480,17 @@ again: } prop_dictionary_get_cstring_nocopy(dict, "pkgname", &curname); + prop_dictionary_get_cstring_nocopy(dict, "version", &curver); prop_dictionary_get_cstring_nocopy(dict, "requiredby", &reqby); + printf("Installing %s-%s required by %s...\n", curname, curver, reqby); + rv = xbps_install_binary_pkg_fini(NULL, dict, destdir); + if (rv != 0) { + printf("Error while installing %s-%s (%s)\n", curname, curver, + strerror(rv)); + goto out; + } + prop_array_remove(array, curidx); if (prop_array_count(array) > 0) { prio = maxprio = 0; @@ -491,7 +505,6 @@ again: out: prop_object_release(chaindeps); - exit(0); return rv; } diff --git a/lib/install.c b/lib/install.c index 2077c454703..02f5180a678 100644 --- a/lib/install.c +++ b/lib/install.c @@ -157,7 +157,7 @@ xbps_install_binary_pkg(const char *pkgname, const char *destdir) /* * Install all required dependencies and the package itself. */ - rv = xbps_install_pkg_deps(pkgrd); + rv = xbps_install_pkg_deps(pkgrd, destdir); if (rv == 0) { rv = xbps_install_binary_pkg_fini(repod, pkgrd, destdir); diff --git a/lib/unpack.c b/lib/unpack.c index 4f564fb7d69..b6c7013dc3f 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -37,6 +37,19 @@ static int unpack_archive_init(prop_dictionary_t, const char *, const char *); static int unpack_archive_fini(struct archive *, const char *, prop_dictionary_t); +static void unpack_defcb_print(prop_dictionary_t); + +static void +unpack_defcb_print(prop_dictionary_t pkg) +{ + const char *pkgname, *version; + assert(pkg != NULL); + + prop_dictionary_get_cstring_nocopy(pkg, "pkgname", &pkgname); + prop_dictionary_get_cstring_nocopy(pkg, "version", &version); + + printf(" Unpacking %s-%s...\n", pkgname, version); +} int xbps_unpack_binary_pkg(prop_dictionary_t repo, prop_dictionary_t pkg, @@ -54,7 +67,7 @@ xbps_unpack_binary_pkg(prop_dictionary_t repo, prop_dictionary_t pkg, if (repo) repoloc = prop_dictionary_get(repo, "location-local"); else - repoloc = prop_dictionary_get(pkg, "location-local"); + repoloc = prop_dictionary_get(pkg, "repository"); binfile = xbps_append_full_path(false, prop_string_cstring_nocopy(repoloc), @@ -62,7 +75,9 @@ xbps_unpack_binary_pkg(prop_dictionary_t repo, prop_dictionary_t pkg, if (binfile == NULL) return EINVAL; - if (cb_print) + if (!cb_print) + unpack_defcb_print(pkg); + else (*cb_print)(pkg); rv = unpack_archive_init(pkg, destdir, binfile);