2009-08-17 22:37:20 +05:30
|
|
|
/*-
|
2012-01-18 12:55:28 +05:30
|
|
|
* Copyright (c) 2008-2012 Juan Romero Pardines.
|
2009-08-17 22:37:20 +05:30
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
|
2010-11-13 07:48:58 +05:30
|
|
|
#include "xbps_api_impl.h"
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
static int
|
2012-06-14 11:52:11 +05:30
|
|
|
store_dependency(struct xbps_handle *xhp,
|
2012-11-30 11:41:51 +05:30
|
|
|
prop_array_t unsorted,
|
2011-10-27 14:24:28 +05:30
|
|
|
prop_dictionary_t repo_pkgd,
|
2012-11-30 11:41:51 +05:30
|
|
|
pkg_state_t repo_pkg_state)
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
2012-06-05 02:52:33 +05:30
|
|
|
int rv;
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2011-02-23 21:44:33 +05:30
|
|
|
* Overwrite package state in dictionary with same state than the
|
|
|
|
* package currently uses, otherwise not-installed.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2011-10-27 14:24:28 +05:30
|
|
|
if ((rv = xbps_set_pkg_state_dictionary(repo_pkgd, repo_pkg_state)) != 0)
|
2011-02-23 21:44:33 +05:30
|
|
|
return rv;
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* Add required objects into package dep's dictionary.
|
|
|
|
*/
|
2011-10-20 18:09:58 +05:30
|
|
|
if (!prop_dictionary_set_bool(repo_pkgd, "automatic-install", true))
|
2012-06-05 02:52:33 +05:30
|
|
|
return EINVAL;
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2012-11-30 11:41:51 +05:30
|
|
|
* Add the dictionary into the unsorted queue.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2012-11-30 11:41:51 +05:30
|
|
|
prop_array_add(unsorted, repo_pkgd);
|
|
|
|
xbps_dbg_printf_append(xhp, "(added)\n");
|
2012-06-05 02:52:33 +05:30
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2012-06-14 11:52:11 +05:30
|
|
|
add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
2012-06-14 11:52:11 +05:30
|
|
|
prop_array_t mdeps;
|
2009-11-29 07:47:35 +05:30
|
|
|
prop_string_t reqpkg_str;
|
|
|
|
prop_object_iterator_t iter = NULL;
|
|
|
|
prop_object_t obj;
|
|
|
|
size_t idx = 0;
|
|
|
|
bool add_pkgdep, pkgfound, update_pkgdep;
|
2010-11-24 03:47:04 +05:30
|
|
|
int rv = 0;
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-29 07:47:35 +05:30
|
|
|
assert(reqpkg != NULL);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-29 07:47:35 +05:30
|
|
|
add_pkgdep = update_pkgdep = pkgfound = false;
|
2012-06-14 11:52:11 +05:30
|
|
|
mdeps = prop_dictionary_get(xhp->transd, "missing_deps");
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2009-11-29 07:47:35 +05:30
|
|
|
reqpkg_str = prop_string_create_cstring_nocopy(reqpkg);
|
|
|
|
if (reqpkg_str == NULL)
|
2009-11-21 11:42:42 +05:30
|
|
|
return errno;
|
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
iter = prop_array_iterator(mdeps);
|
2009-11-29 07:47:35 +05:30
|
|
|
if (iter == NULL)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
|
|
|
const char *curdep, *curver, *pkgver;
|
|
|
|
char *curpkgnamedep = NULL, *pkgnamedep = NULL;
|
|
|
|
|
|
|
|
assert(prop_object_type(obj) == PROP_TYPE_STRING);
|
|
|
|
curdep = prop_string_cstring_nocopy(obj);
|
2011-06-01 13:07:32 +05:30
|
|
|
curver = xbps_pkgpattern_version(curdep);
|
|
|
|
pkgver = xbps_pkgpattern_version(reqpkg);
|
2009-11-29 07:47:35 +05:30
|
|
|
if (curver == NULL || pkgver == NULL)
|
|
|
|
goto out;
|
2011-06-01 13:07:32 +05:30
|
|
|
curpkgnamedep = xbps_pkgpattern_name(curdep);
|
2009-11-29 07:47:35 +05:30
|
|
|
if (curpkgnamedep == NULL)
|
|
|
|
goto out;
|
2011-06-01 13:07:32 +05:30
|
|
|
pkgnamedep = xbps_pkgpattern_name(reqpkg);
|
2009-11-29 07:47:35 +05:30
|
|
|
if (pkgnamedep == NULL) {
|
|
|
|
free(curpkgnamedep);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (strcmp(pkgnamedep, curpkgnamedep) == 0) {
|
|
|
|
pkgfound = true;
|
2010-11-24 03:47:04 +05:30
|
|
|
if (strcmp(curver, pkgver) == 0) {
|
|
|
|
free(curpkgnamedep);
|
|
|
|
free(pkgnamedep);
|
|
|
|
rv = EEXIST;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-11-29 07:47:35 +05:30
|
|
|
/*
|
|
|
|
* if new dependency version is greater than current
|
|
|
|
* one, store it.
|
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "Missing pkgdep name matched, "
|
2010-11-19 18:10:13 +05:30
|
|
|
"curver: %s newver: %s\n", curver, pkgver);
|
2009-11-29 07:47:35 +05:30
|
|
|
if (xbps_cmpver(curver, pkgver) <= 0) {
|
|
|
|
add_pkgdep = false;
|
|
|
|
free(curpkgnamedep);
|
|
|
|
free(pkgnamedep);
|
2010-11-24 03:47:04 +05:30
|
|
|
rv = EEXIST;
|
2009-11-29 07:47:35 +05:30
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
update_pkgdep = true;
|
|
|
|
}
|
|
|
|
free(curpkgnamedep);
|
|
|
|
free(pkgnamedep);
|
|
|
|
if (pkgfound)
|
|
|
|
break;
|
|
|
|
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
add_pkgdep = true;
|
|
|
|
out:
|
|
|
|
if (iter)
|
|
|
|
prop_object_iterator_release(iter);
|
|
|
|
if (update_pkgdep)
|
2012-06-14 11:52:11 +05:30
|
|
|
prop_array_remove(mdeps, idx);
|
|
|
|
if (add_pkgdep && !xbps_add_obj_to_array(mdeps, reqpkg_str)) {
|
2009-11-29 07:47:35 +05:30
|
|
|
prop_object_release(reqpkg_str);
|
2009-11-23 15:16:51 +05:30
|
|
|
return errno;
|
|
|
|
}
|
2009-11-29 07:47:35 +05:30
|
|
|
|
2010-11-24 03:47:04 +05:30
|
|
|
return rv;
|
2009-11-29 07:47:35 +05:30
|
|
|
}
|
|
|
|
|
2011-01-28 16:42:47 +05:30
|
|
|
#define MAX_DEPTH 512
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
static int
|
2012-06-14 11:52:11 +05:30
|
|
|
find_repo_deps(struct xbps_handle *xhp,
|
2012-11-30 11:41:51 +05:30
|
|
|
prop_array_t unsorted, /* array of unsorted deps */
|
2011-01-28 16:42:47 +05:30
|
|
|
prop_array_t pkg_rdeps_array, /* current pkg rundeps array */
|
2011-10-30 21:11:39 +05:30
|
|
|
const char *curpkg, /* current pkgver */
|
|
|
|
size_t *depth) /* max recursion depth */
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
2009-11-23 05:13:48 +05:30
|
|
|
prop_dictionary_t curpkgd, tmpd;
|
2012-11-30 14:19:09 +05:30
|
|
|
prop_object_t obj;
|
|
|
|
prop_object_iterator_t iter;
|
2012-11-30 11:41:51 +05:30
|
|
|
prop_array_t curpkgrdeps;
|
2011-01-28 16:42:47 +05:30
|
|
|
pkg_state_t state;
|
2012-11-30 14:19:09 +05:30
|
|
|
size_t x;
|
2013-03-05 08:38:42 +05:30
|
|
|
const char *reqpkg, *pkgver_q, *reason = NULL;
|
|
|
|
char *pkgname, *reqpkgname;
|
2010-11-19 18:10:13 +05:30
|
|
|
int rv = 0;
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2011-10-30 21:11:39 +05:30
|
|
|
if (*depth >= MAX_DEPTH)
|
2011-01-28 16:42:47 +05:30
|
|
|
return ELOOP;
|
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* Iterate over the list of required run dependencies for
|
|
|
|
* current package.
|
|
|
|
*/
|
2012-11-30 14:19:09 +05:30
|
|
|
iter = prop_array_iterator(pkg_rdeps_array);
|
|
|
|
assert(iter);
|
|
|
|
|
|
|
|
while ((obj = prop_object_iterator_next(iter))) {
|
|
|
|
reqpkg = prop_string_cstring_nocopy(obj);
|
2012-01-22 15:22:35 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "");
|
2011-10-30 21:11:39 +05:30
|
|
|
for (x = 0; x < *depth; x++)
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, " ");
|
|
|
|
xbps_dbg_printf_append(xhp, "%s: requires dependency '%s': ",
|
|
|
|
curpkg != NULL ? curpkg : " ", reqpkg);
|
2011-10-30 21:11:39 +05:30
|
|
|
}
|
2012-12-02 21:04:01 +05:30
|
|
|
if (((pkgname = xbps_pkgpattern_name(reqpkg)) == NULL) &&
|
|
|
|
((pkgname = xbps_pkg_name(reqpkg)) == NULL)) {
|
|
|
|
xbps_dbg_printf(xhp, "can't guess pkgname for %s\n",
|
|
|
|
reqpkg);
|
|
|
|
rv = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2011-10-27 14:24:28 +05:30
|
|
|
* Pass 1: check if required dependency is already installed
|
|
|
|
* and its version is fully matched.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2012-12-02 21:04:01 +05:30
|
|
|
if (((tmpd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) &&
|
|
|
|
((tmpd = xbps_pkgdb_get_virtualpkg(xhp, pkgname)) == NULL)) {
|
|
|
|
free(pkgname);
|
2011-10-27 14:24:28 +05:30
|
|
|
if (errno && errno != ENOENT) {
|
|
|
|
/* error */
|
|
|
|
rv = errno;
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "failed to find "
|
2011-10-27 14:24:28 +05:30
|
|
|
"installed pkg for `%s': %s\n",
|
|
|
|
reqpkg, strerror(errno));
|
|
|
|
break;
|
|
|
|
}
|
2011-01-25 22:39:27 +05:30
|
|
|
/* Required pkgdep not installed */
|
2012-11-30 11:41:51 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "not installed ");
|
2011-10-27 14:24:28 +05:30
|
|
|
reason = "install";
|
|
|
|
state = XBPS_PKG_STATE_NOT_INSTALLED;
|
2011-01-25 22:39:27 +05:30
|
|
|
} else {
|
2012-12-02 21:04:01 +05:30
|
|
|
free(pkgname);
|
2011-01-25 22:39:27 +05:30
|
|
|
/*
|
|
|
|
* Check if installed version matches the
|
|
|
|
* required pkgdep version.
|
|
|
|
*/
|
|
|
|
prop_dictionary_get_cstring_nocopy(tmpd,
|
2011-01-27 22:53:32 +05:30
|
|
|
"pkgver", &pkgver_q);
|
2011-01-25 22:39:27 +05:30
|
|
|
|
|
|
|
/* Check its state */
|
2012-06-16 12:32:07 +05:30
|
|
|
if ((rv = xbps_pkg_state_dictionary(tmpd, &state)) != 0)
|
2009-11-26 07:52:50 +05:30
|
|
|
break;
|
2011-07-15 21:52:58 +05:30
|
|
|
if (xbps_match_virtual_pkg_in_dict(tmpd,reqpkg,true)) {
|
2011-06-23 15:00:04 +05:30
|
|
|
/*
|
|
|
|
* Check if required dependency is a virtual
|
|
|
|
* package and is satisfied by an
|
|
|
|
* installed package.
|
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp,
|
|
|
|
"[virtual] satisfied by "
|
2011-06-23 15:00:04 +05:30
|
|
|
"`%s'.\n", pkgver_q);
|
|
|
|
continue;
|
|
|
|
}
|
2011-06-04 17:07:53 +05:30
|
|
|
rv = xbps_pkgpattern_match(pkgver_q, reqpkg);
|
2011-01-27 22:53:32 +05:30
|
|
|
if (rv == 0) {
|
2011-01-25 22:39:27 +05:30
|
|
|
/*
|
|
|
|
* Package is installed but does not match
|
2012-03-24 13:51:28 +05:30
|
|
|
* the dependency pattern, update pkg.
|
2011-01-25 22:39:27 +05:30
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp,
|
|
|
|
"installed `%s', "
|
2012-03-24 13:51:28 +05:30
|
|
|
"must be updated.\n", pkgver_q);
|
|
|
|
reason = "update";
|
2011-01-27 22:53:32 +05:30
|
|
|
} else if (rv == 1) {
|
2011-01-28 01:32:56 +05:30
|
|
|
rv = 0;
|
2011-01-25 22:39:27 +05:30
|
|
|
if (state == XBPS_PKG_STATE_UNPACKED) {
|
|
|
|
/*
|
|
|
|
* Package matches the dependency
|
|
|
|
* pattern but was only unpacked,
|
2012-03-24 13:51:28 +05:30
|
|
|
* configure pkg.
|
2011-01-25 22:39:27 +05:30
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp,
|
|
|
|
"installed `%s'"
|
2011-10-27 14:24:28 +05:30
|
|
|
", must be configured.\n",
|
2011-01-27 22:53:32 +05:30
|
|
|
pkgver_q);
|
2011-10-27 14:24:28 +05:30
|
|
|
reason = "configure";
|
2012-11-30 11:41:51 +05:30
|
|
|
} else if (state == XBPS_PKG_STATE_INSTALLED) {
|
2011-01-25 22:39:27 +05:30
|
|
|
/*
|
|
|
|
* Package matches the dependency
|
|
|
|
* pattern and is fully installed,
|
2012-03-24 13:51:28 +05:30
|
|
|
* skip to next one.
|
2011-01-25 22:39:27 +05:30
|
|
|
*/
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp,
|
|
|
|
"installed "
|
2011-01-27 22:53:32 +05:30
|
|
|
"`%s'.\n", pkgver_q);
|
2011-01-25 22:39:27 +05:30
|
|
|
continue;
|
|
|
|
}
|
2011-01-27 22:53:32 +05:30
|
|
|
} else {
|
|
|
|
/* error matching pkgpattern */
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "failed to match "
|
2011-10-27 14:24:28 +05:30
|
|
|
"pattern %s with %s\n", reqpkg, pkgver_q);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
2012-06-05 02:52:33 +05:30
|
|
|
* Pass 2: check if required dependency has been already
|
|
|
|
* added in the transaction dictionary.
|
2011-10-27 14:24:28 +05:30
|
|
|
*/
|
2012-11-30 11:41:51 +05:30
|
|
|
if ((curpkgd = xbps_find_pkg_in_array(unsorted, reqpkg)) ||
|
|
|
|
(curpkgd = xbps_find_virtualpkg_in_array(xhp, unsorted, reqpkg))) {
|
2011-10-27 14:24:28 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
|
|
|
"pkgver", &pkgver_q);
|
2012-11-30 11:41:51 +05:30
|
|
|
xbps_dbg_printf_append(xhp, " (%s queued)\n", pkgver_q);
|
2011-10-27 14:24:28 +05:30
|
|
|
continue;
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
/*
|
2012-01-24 23:15:50 +05:30
|
|
|
* Pass 3: find required dependency in repository pool.
|
|
|
|
* If dependency does not match add pkg into the missing
|
|
|
|
* deps array and pass to next one.
|
2011-10-27 14:24:28 +05:30
|
|
|
*/
|
2012-11-30 11:41:51 +05:30
|
|
|
if (((curpkgd = xbps_rpool_get_pkg(xhp, reqpkg)) == NULL) &&
|
|
|
|
((curpkgd = xbps_rpool_get_virtualpkg(xhp, reqpkg)) == NULL)) {
|
2012-05-30 13:52:53 +05:30
|
|
|
/* pkg not found, there was some error */
|
|
|
|
if (errno && errno != ENOENT) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "failed to find pkg "
|
2012-05-30 13:52:53 +05:30
|
|
|
"for `%s' in rpool: %s\n",
|
|
|
|
reqpkg, strerror(errno));
|
|
|
|
rv = errno;
|
|
|
|
break;
|
|
|
|
}
|
2012-06-14 11:52:11 +05:30
|
|
|
rv = add_missing_reqdep(xhp, reqpkg);
|
2012-05-30 13:52:53 +05:30
|
|
|
if (rv != 0 && rv != EEXIST) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "`%s': "
|
2012-05-30 13:52:53 +05:30
|
|
|
"add_missing_reqdep failed %s\n",
|
|
|
|
reqpkg);
|
|
|
|
break;
|
|
|
|
} else if (rv == EEXIST) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "`%s' missing "
|
2012-05-30 13:52:53 +05:30
|
|
|
"dep already added.\n", reqpkg);
|
|
|
|
rv = 0;
|
|
|
|
continue;
|
|
|
|
} else {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, "`%s' added "
|
2012-05-30 13:52:53 +05:30
|
|
|
"into the missing deps array.\n",
|
|
|
|
reqpkg);
|
|
|
|
continue;
|
2011-10-27 14:24:28 +05:30
|
|
|
}
|
|
|
|
}
|
2012-06-14 11:52:11 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
|
|
|
"pkgver", &pkgver_q);
|
2013-03-05 08:38:42 +05:30
|
|
|
reqpkgname = xbps_pkg_name(pkgver_q);
|
|
|
|
assert(reqpkgname);
|
2013-02-07 23:20:55 +05:30
|
|
|
/*
|
|
|
|
* Check dependency validity.
|
|
|
|
*/
|
|
|
|
pkgname = xbps_pkg_name(curpkg);
|
|
|
|
assert(pkgname);
|
|
|
|
if (strcmp(pkgname, reqpkgname) == 0) {
|
|
|
|
xbps_dbg_printf_append(xhp, "[ignoring wrong dependency "
|
|
|
|
"%s (depends on itself)]\n",
|
|
|
|
reqpkg);
|
|
|
|
free(pkgname);
|
2013-03-05 08:38:42 +05:30
|
|
|
free(reqpkgname);
|
2013-02-07 23:20:55 +05:30
|
|
|
continue;
|
|
|
|
}
|
|
|
|
free(pkgname);
|
2013-03-05 08:38:42 +05:30
|
|
|
free(reqpkgname);
|
2013-02-07 23:20:55 +05:30
|
|
|
|
2012-06-11 19:44:03 +05:30
|
|
|
/*
|
|
|
|
* Check if package has matched conflicts.
|
|
|
|
*/
|
2012-11-30 11:41:51 +05:30
|
|
|
xbps_pkg_find_conflicts(xhp, unsorted, curpkgd);
|
2011-10-27 14:24:28 +05:30
|
|
|
/*
|
|
|
|
* Package is on repo, add it into the transaction dictionary.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2012-06-05 02:52:33 +05:30
|
|
|
prop_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason);
|
2012-11-30 11:41:51 +05:30
|
|
|
rv = store_dependency(xhp, unsorted, curpkgd, state);
|
2011-10-30 21:11:39 +05:30
|
|
|
if (rv != 0) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "store_dependency failed for "
|
2011-02-01 22:02:25 +05:30
|
|
|
"`%s': %s\n", reqpkg, strerror(rv));
|
2009-08-17 22:37:20 +05:30
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If package doesn't have rundeps, pass to the next one.
|
|
|
|
*/
|
2011-01-28 16:42:47 +05:30
|
|
|
curpkgrdeps = prop_dictionary_get(curpkgd, "run_depends");
|
2012-11-15 06:07:09 +05:30
|
|
|
if (curpkgrdeps == NULL)
|
2009-08-17 22:37:20 +05:30
|
|
|
continue;
|
2012-11-15 06:07:09 +05:30
|
|
|
|
2012-01-22 15:22:35 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "");
|
2011-10-30 21:11:39 +05:30
|
|
|
for (x = 0; x < *depth; x++)
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp, " ");
|
2011-10-30 21:11:39 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf_append(xhp,
|
|
|
|
"%s: finding dependencies:\n", pkgver_q);
|
2011-10-30 21:11:39 +05:30
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2011-01-28 16:42:47 +05:30
|
|
|
* Recursively find rundeps for current pkg dictionary.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2011-10-30 21:11:39 +05:30
|
|
|
(*depth)++;
|
2012-11-30 11:41:51 +05:30
|
|
|
rv = find_repo_deps(xhp, unsorted, curpkgrdeps,
|
|
|
|
pkgver_q, depth);
|
2011-01-18 19:14:39 +05:30
|
|
|
if (rv != 0) {
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "Error checking %s for rundeps: %s\n",
|
2010-11-19 18:10:13 +05:30
|
|
|
reqpkg, strerror(rv));
|
2009-11-23 02:22:57 +05:30
|
|
|
break;
|
2009-11-23 05:13:48 +05:30
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
2012-11-30 14:19:09 +05:30
|
|
|
prop_object_iterator_release(iter);
|
2011-10-30 21:11:39 +05:30
|
|
|
(*depth)--;
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2010-01-21 07:40:19 +05:30
|
|
|
|
|
|
|
int HIDDEN
|
2012-11-30 11:41:51 +05:30
|
|
|
xbps_repository_find_deps(struct xbps_handle *xhp,
|
|
|
|
prop_array_t unsorted,
|
|
|
|
prop_dictionary_t repo_pkgd)
|
2010-01-21 07:40:19 +05:30
|
|
|
{
|
2012-06-14 11:52:11 +05:30
|
|
|
prop_array_t pkg_rdeps;
|
2011-01-28 16:42:47 +05:30
|
|
|
const char *pkgver;
|
2011-10-30 21:11:39 +05:30
|
|
|
size_t depth = 0;
|
2010-01-21 07:40:19 +05:30
|
|
|
|
2011-01-18 19:14:39 +05:30
|
|
|
pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends");
|
2011-10-31 14:18:46 +05:30
|
|
|
if (prop_object_type(pkg_rdeps) != PROP_TYPE_ARRAY)
|
2010-01-21 07:40:19 +05:30
|
|
|
return 0;
|
2012-11-15 06:07:09 +05:30
|
|
|
else if (prop_array_count(pkg_rdeps) == 0)
|
|
|
|
return 0;
|
2010-01-21 07:40:19 +05:30
|
|
|
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_dbg_printf(xhp, "Finding required dependencies for '%s':\n", pkgver);
|
2010-01-21 07:40:19 +05:30
|
|
|
/*
|
2011-01-18 19:14:39 +05:30
|
|
|
* This will find direct and indirect deps, if any of them is not
|
|
|
|
* there it will be added into the missing_deps array.
|
2010-01-21 07:40:19 +05:30
|
|
|
*/
|
2012-11-30 11:41:51 +05:30
|
|
|
return find_repo_deps(xhp, unsorted, pkg_rdeps, pkgver, &depth);
|
2010-01-21 07:40:19 +05:30
|
|
|
}
|