2009-08-17 22:37:20 +05:30
|
|
|
/*-
|
2011-01-18 19:14:39 +05:30
|
|
|
* Copyright (c) 2008-2011 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
|
2011-01-27 22:53:32 +05:30
|
|
|
store_dependency(prop_dictionary_t transd, prop_dictionary_t repo_pkgd)
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
|
|
|
prop_array_t array;
|
2011-06-04 17:07:53 +05:30
|
|
|
const char *pkgname, *pkgver, *repoloc, *reason;
|
2010-11-19 18:10:13 +05:30
|
|
|
int rv = 0;
|
2009-08-17 22:37:20 +05:30
|
|
|
pkg_state_t state = 0;
|
|
|
|
|
2011-10-19 20:23:38 +05:30
|
|
|
assert(prop_object_type(transd) == PROP_TYPE_DICTIONARY);
|
|
|
|
assert(prop_object_type(repo_pkgd) == PROP_TYPE_DICTIONARY);
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* Get some info about dependencies and current repository.
|
|
|
|
*/
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgname", &pkgname);
|
|
|
|
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);
|
|
|
|
prop_dictionary_get_cstring_nocopy(repo_pkgd, "repository", &repoloc);
|
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-06-01 13:07:32 +05:30
|
|
|
if ((rv = xbps_pkg_state_installed(pkgname, &state)) != 0) {
|
2011-10-20 18:09:58 +05:30
|
|
|
if (rv != ENOENT)
|
2009-08-17 22:37:20 +05:30
|
|
|
return rv;
|
2011-06-04 17:07:53 +05:30
|
|
|
/* pkg not installed */
|
2011-02-23 21:44:33 +05:30
|
|
|
state = XBPS_PKG_STATE_NOT_INSTALLED;
|
|
|
|
}
|
2011-10-20 18:09:58 +05:30
|
|
|
if ((rv = xbps_set_pkg_state_dictionary(repo_pkgd, state)) != 0)
|
2011-02-23 21:44:33 +05:30
|
|
|
return rv;
|
2011-06-04 17:07:53 +05:30
|
|
|
/*
|
|
|
|
* If pkg dependency is already installed, skip it if the transaction
|
|
|
|
* reason is "install".
|
|
|
|
*/
|
|
|
|
if (state == XBPS_PKG_STATE_INSTALLED) {
|
|
|
|
prop_dictionary_get_cstring_nocopy(repo_pkgd,
|
|
|
|
"transaction", &reason);
|
|
|
|
if (strcmp(reason, "install") == 0) {
|
|
|
|
xbps_dbg_printf("%s: skipping, already installed.\n",
|
|
|
|
pkgver);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
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))
|
2009-12-22 17:07:36 +05:30
|
|
|
return errno;
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* Add the dictionary into the array.
|
|
|
|
*/
|
2011-10-20 18:09:58 +05:30
|
|
|
array = prop_dictionary_get(transd, "unsorted_deps");
|
|
|
|
if (array == NULL)
|
|
|
|
return errno;
|
|
|
|
|
|
|
|
if (!prop_array_add(array, repo_pkgd))
|
2009-08-17 22:37:20 +05:30
|
|
|
return EINVAL;
|
2011-10-20 18:09:58 +05:30
|
|
|
|
2010-11-19 18:10:13 +05:30
|
|
|
xbps_dbg_printf("Added package '%s' into "
|
|
|
|
"the transaction (%s).\n", pkgver, repoloc);
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2011-01-18 19:14:39 +05:30
|
|
|
add_missing_reqdep(prop_array_t missing_rdeps, const char *reqpkg)
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
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
|
|
|
|
2011-10-19 20:23:38 +05:30
|
|
|
assert(prop_object_type(missing_rdeps) == PROP_TYPE_ARRAY);
|
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;
|
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;
|
|
|
|
|
2009-11-29 07:47:35 +05:30
|
|
|
iter = prop_array_iterator(missing_rdeps);
|
|
|
|
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.
|
|
|
|
*/
|
2010-11-19 18:10:13 +05:30
|
|
|
xbps_dbg_printf("Missing pkgdep name matched, "
|
|
|
|
"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)
|
|
|
|
prop_array_remove(missing_rdeps, idx);
|
|
|
|
if (add_pkgdep && !xbps_add_obj_to_array(missing_rdeps, reqpkg_str)) {
|
|
|
|
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
|
2011-01-27 22:53:32 +05:30
|
|
|
find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_array_t mrdeps, /* missing rundeps array */
|
2011-01-28 16:42:47 +05:30
|
|
|
prop_array_t pkg_rdeps_array, /* current pkg rundeps array */
|
|
|
|
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;
|
2011-01-28 16:42:47 +05:30
|
|
|
prop_array_t curpkgrdeps;
|
2009-11-23 05:13:48 +05:30
|
|
|
prop_object_t obj;
|
2009-08-17 22:37:20 +05:30
|
|
|
prop_object_iterator_t iter;
|
2011-01-28 16:42:47 +05:30
|
|
|
pkg_state_t state;
|
2011-01-28 02:24:55 +05:30
|
|
|
const char *reqpkg, *pkgver_q, *repopkgver;
|
2009-08-17 22:37:20 +05:30
|
|
|
char *pkgname;
|
2010-11-19 18:10:13 +05:30
|
|
|
int rv = 0;
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2011-10-19 20:23:38 +05:30
|
|
|
assert(prop_object_type(transd) == PROP_TYPE_DICTIONARY);
|
|
|
|
assert(prop_object_type(mrdeps) == PROP_TYPE_ARRAY);
|
|
|
|
assert(prop_object_type(pkg_rdeps_array) == PROP_TYPE_ARRAY);
|
|
|
|
|
2011-01-28 16:42:47 +05:30
|
|
|
if (depth >= MAX_DEPTH)
|
|
|
|
return ELOOP;
|
|
|
|
|
2010-05-20 10:51:24 +05:30
|
|
|
iter = prop_array_iterator(pkg_rdeps_array);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (iter == NULL)
|
|
|
|
return ENOMEM;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate over the list of required run dependencies for
|
|
|
|
* current package.
|
|
|
|
*/
|
2009-11-23 02:22:57 +05:30
|
|
|
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
2011-02-03 22:19:43 +05:30
|
|
|
curpkgd = NULL;
|
2009-08-17 22:37:20 +05:30
|
|
|
reqpkg = prop_string_cstring_nocopy(obj);
|
2009-11-23 15:16:51 +05:30
|
|
|
if (reqpkg == NULL) {
|
|
|
|
rv = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2011-01-28 16:42:47 +05:30
|
|
|
if (depth < 1)
|
|
|
|
xbps_dbg_printf(" [direct] Requires "
|
|
|
|
"dependency '%s' ", reqpkg);
|
2010-11-19 18:10:13 +05:30
|
|
|
else
|
2011-01-28 16:42:47 +05:30
|
|
|
xbps_dbg_printf(" [indirect] Requires "
|
|
|
|
"dependency '%s' ", reqpkg);
|
2010-11-19 18:10:13 +05:30
|
|
|
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* Check if package is already added in the
|
2009-11-22 09:45:47 +05:30
|
|
|
* array of unsorted deps, and check if current required
|
2011-10-16 15:52:46 +05:30
|
|
|
* dependency pattern is matched. First checking if required
|
|
|
|
* dependency is supplied by a virtual pkg set in
|
|
|
|
* the configuration file.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2011-10-16 15:52:46 +05:30
|
|
|
curpkgd = xbps_find_virtualpkg_conf_in_dict_by_pattern(transd,
|
2011-01-27 22:53:32 +05:30
|
|
|
"unsorted_deps", reqpkg);
|
2011-10-16 15:52:46 +05:30
|
|
|
if (curpkgd == NULL) {
|
|
|
|
/*
|
|
|
|
* Look for a real package matching pattern
|
|
|
|
* if no match.
|
|
|
|
*/
|
|
|
|
curpkgd = xbps_find_pkg_in_dict_by_pattern(transd,
|
|
|
|
"unsorted_deps", reqpkg);
|
|
|
|
}
|
2011-01-25 22:39:27 +05:30
|
|
|
if (curpkgd != NULL) {
|
2010-11-06 11:14:00 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
2011-01-27 22:53:32 +05:30
|
|
|
"pkgver", &pkgver_q);
|
|
|
|
xbps_dbg_printf_append("`%s' queued "
|
|
|
|
"in the transaction.\n", pkgver_q);
|
|
|
|
continue;
|
2011-01-25 22:39:27 +05:30
|
|
|
} else {
|
|
|
|
/* error matching required pkgdep */
|
|
|
|
if (errno && errno != ENOENT) {
|
|
|
|
rv = errno;
|
|
|
|
break;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
/*
|
2011-10-16 15:52:46 +05:30
|
|
|
* If required pkgdep (first virtual pkg in conf, otherwise
|
|
|
|
* real pkg) is not in repo, add it into the missing deps
|
|
|
|
* array and pass to the next one.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2011-10-16 15:52:46 +05:30
|
|
|
curpkgd = xbps_repository_pool_find_virtualpkg(reqpkg, true, false);
|
2009-08-17 22:37:20 +05:30
|
|
|
if (curpkgd == NULL) {
|
2011-10-16 15:52:46 +05:30
|
|
|
curpkgd = xbps_repository_pool_find_pkg(reqpkg, true, false);
|
|
|
|
if (curpkgd == NULL) {
|
|
|
|
/* pkg not found, there was some error */
|
|
|
|
if (errno && errno != ENOENT) {
|
|
|
|
rv = errno;
|
|
|
|
break;
|
|
|
|
}
|
2009-11-26 07:52:50 +05:30
|
|
|
|
2011-10-16 15:52:46 +05:30
|
|
|
rv = add_missing_reqdep(mrdeps, reqpkg);
|
|
|
|
if (rv != 0 && rv != EEXIST) {
|
|
|
|
xbps_dbg_printf_append("`%s': "
|
|
|
|
"add_missing_reqdep failed %s\n", reqpkg);
|
|
|
|
break;
|
|
|
|
} else if (rv == EEXIST) {
|
|
|
|
xbps_dbg_printf_append("`%s' missing dep "
|
|
|
|
"already added.\n", reqpkg);
|
|
|
|
rv = 0;
|
|
|
|
continue;
|
|
|
|
} else {
|
|
|
|
xbps_dbg_printf_append("`%s' added "
|
|
|
|
"into the missing deps array.\n", reqpkg);
|
|
|
|
continue;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
}
|
2011-06-01 13:07:32 +05:30
|
|
|
pkgname = xbps_pkgpattern_name(reqpkg);
|
2011-01-28 02:24:55 +05:30
|
|
|
if (pkgname == NULL) {
|
|
|
|
prop_object_release(curpkgd);
|
|
|
|
rv = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2011-01-25 22:39:27 +05:30
|
|
|
* Check if required pkgdep is installed and matches
|
|
|
|
* the required version.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2011-01-25 22:39:27 +05:30
|
|
|
tmpd = xbps_find_pkg_dict_installed(pkgname, false);
|
2009-11-26 07:52:50 +05:30
|
|
|
if (tmpd == NULL) {
|
2011-01-25 22:39:27 +05:30
|
|
|
free(pkgname);
|
2009-11-26 07:52:50 +05:30
|
|
|
if (errno && errno != ENOENT) {
|
2011-01-25 22:39:27 +05:30
|
|
|
/* error */
|
2009-11-26 07:52:50 +05:30
|
|
|
rv = errno;
|
2011-01-28 02:24:55 +05:30
|
|
|
prop_object_release(curpkgd);
|
2009-11-26 07:52:50 +05:30
|
|
|
break;
|
|
|
|
}
|
2011-01-25 22:39:27 +05:30
|
|
|
/* Required pkgdep not installed */
|
2009-08-17 22:37:20 +05:30
|
|
|
prop_dictionary_set_cstring_nocopy(curpkgd,
|
2011-02-05 16:51:04 +05:30
|
|
|
"transaction", "install");
|
2011-01-25 22:39:27 +05:30
|
|
|
xbps_dbg_printf_append("not installed.\n");
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* 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 */
|
2011-06-01 13:07:32 +05:30
|
|
|
rv = xbps_pkg_state_installed(pkgname, &state);
|
2009-11-26 07:52:50 +05:30
|
|
|
if (rv != 0) {
|
2009-11-29 07:47:35 +05:30
|
|
|
free(pkgname);
|
2009-11-26 07:52:50 +05:30
|
|
|
prop_object_release(tmpd);
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_object_release(curpkgd);
|
2009-11-26 07:52:50 +05:30
|
|
|
break;
|
|
|
|
}
|
2011-01-25 22:39:27 +05:30
|
|
|
free(pkgname);
|
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.
|
|
|
|
*/
|
|
|
|
xbps_dbg_printf_append("[virtual] satisfied by "
|
|
|
|
"`%s'.\n", pkgver_q);
|
|
|
|
prop_object_release(tmpd);
|
|
|
|
prop_object_release(curpkgd);
|
|
|
|
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
|
|
|
|
* the dependency pattern, an update
|
|
|
|
* needs to be installed.
|
|
|
|
*/
|
|
|
|
prop_dictionary_get_cstring_nocopy(curpkgd,
|
|
|
|
"version", &repopkgver);
|
|
|
|
xbps_dbg_printf_append("installed `%s', "
|
|
|
|
"updating to `%s'...\n",
|
2011-01-27 22:53:32 +05:30
|
|
|
pkgver_q, repopkgver);
|
2009-11-26 07:52:50 +05:30
|
|
|
prop_dictionary_set_cstring_nocopy(curpkgd,
|
2011-02-05 16:51:04 +05:30
|
|
|
"transaction", "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,
|
|
|
|
* mark pkg to be configured.
|
|
|
|
*/
|
|
|
|
prop_dictionary_set_cstring_nocopy(
|
2011-02-05 16:51:04 +05:30
|
|
|
curpkgd, "transaction",
|
2011-01-25 22:39:27 +05:30
|
|
|
"configure");
|
|
|
|
xbps_dbg_printf_append("installed `%s'"
|
|
|
|
", but needs to be configured...\n",
|
2011-01-27 22:53:32 +05:30
|
|
|
pkgver_q);
|
2011-01-25 22:39:27 +05:30
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Package matches the dependency
|
|
|
|
* pattern and is fully installed,
|
2011-01-27 22:53:32 +05:30
|
|
|
* skip and pass to next one.
|
2011-01-25 22:39:27 +05:30
|
|
|
*/
|
|
|
|
xbps_dbg_printf_append("installed "
|
2011-01-27 22:53:32 +05:30
|
|
|
"`%s'.\n", pkgver_q);
|
2011-01-25 22:39:27 +05:30
|
|
|
prop_object_release(tmpd);
|
|
|
|
prop_object_release(curpkgd);
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-27 22:53:32 +05:30
|
|
|
} else {
|
|
|
|
/* error matching pkgpattern */
|
|
|
|
prop_object_release(tmpd);
|
|
|
|
prop_object_release(curpkgd);
|
|
|
|
break;
|
2011-01-25 22:39:27 +05:30
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Package is on repo, add it into the dictionary.
|
|
|
|
*/
|
2011-01-27 22:53:32 +05:30
|
|
|
if ((rv = store_dependency(transd, curpkgd)) != 0) {
|
2011-02-01 22:02:25 +05:30
|
|
|
xbps_dbg_printf("store_dependency failed for "
|
|
|
|
"`%s': %s\n", reqpkg, strerror(rv));
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_object_release(curpkgd);
|
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");
|
|
|
|
if (curpkgrdeps == NULL) {
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_object_release(curpkgd);
|
2009-08-17 22:37:20 +05:30
|
|
|
continue;
|
2010-05-20 10:51:24 +05:30
|
|
|
}
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_object_release(curpkgd);
|
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-01-28 16:42:47 +05:30
|
|
|
xbps_dbg_printf("%s[%sdirect] Finding dependencies for '%s':\n",
|
|
|
|
depth < 1 ? "" : " ", depth < 1 ? "" : "in", reqpkg);
|
|
|
|
rv = find_repo_deps(transd, mrdeps, curpkgrdeps, depth++);
|
2011-01-18 19:14:39 +05:30
|
|
|
if (rv != 0) {
|
2010-11-19 18:10:13 +05:30
|
|
|
xbps_dbg_printf("Error checking %s for rundeps: %s\n",
|
|
|
|
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
|
|
|
}
|
|
|
|
prop_object_iterator_release(iter);
|
2011-01-28 16:42:47 +05:30
|
|
|
depth--;
|
2009-08-17 22:37:20 +05:30
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2010-01-21 07:40:19 +05:30
|
|
|
|
|
|
|
int HIDDEN
|
2011-01-27 22:53:32 +05:30
|
|
|
xbps_repository_find_pkg_deps(prop_dictionary_t transd,
|
2011-01-24 21:25:58 +05:30
|
|
|
prop_array_t mdeps,
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_dictionary_t repo_pkgd)
|
2010-01-21 07:40:19 +05:30
|
|
|
{
|
2011-01-24 21:25:58 +05:30
|
|
|
prop_array_t pkg_rdeps;
|
2011-01-28 16:42:47 +05:30
|
|
|
const char *pkgver;
|
2010-11-19 18:10:13 +05:30
|
|
|
int rv = 0;
|
2010-01-21 07:40:19 +05:30
|
|
|
|
2011-10-19 20:23:38 +05:30
|
|
|
assert(prop_object_type(transd) == PROP_TYPE_DICTIONARY);
|
|
|
|
assert(prop_object_type(mdeps) == PROP_TYPE_ARRAY);
|
|
|
|
assert(prop_object_type(repo_pkgd) == PROP_TYPE_DICTIONARY);
|
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");
|
2010-01-21 07:40:19 +05:30
|
|
|
if (pkg_rdeps == NULL)
|
|
|
|
return 0;
|
|
|
|
|
2011-01-18 19:14:39 +05:30
|
|
|
prop_dictionary_get_cstring_nocopy(repo_pkgd, "pkgver", &pkgver);
|
2010-11-19 18:10:13 +05:30
|
|
|
xbps_dbg_printf("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
|
|
|
*/
|
2011-01-28 16:42:47 +05:30
|
|
|
if ((rv = find_repo_deps(transd, mdeps, pkg_rdeps, 0)) != 0) {
|
2011-01-18 19:14:39 +05:30
|
|
|
xbps_dbg_printf("Error '%s' while checking rundeps!\n",
|
|
|
|
strerror(rv));
|
2010-01-21 07:40:19 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|