2009-08-17 22:37:20 +05:30
|
|
|
/*-
|
2020-04-29 17:42:10 +05:30
|
|
|
* Copyright (c) 2008-2020 Juan Romero Pardines.
|
|
|
|
* 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.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#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
|
|
|
add_missing_reqdep(struct xbps_handle *xhp, const char *reqpkg)
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_array_t mdeps;
|
|
|
|
xbps_object_iterator_t iter = NULL;
|
|
|
|
xbps_object_t obj;
|
2013-06-12 13:34:10 +05:30
|
|
|
unsigned int idx = 0;
|
2009-11-29 07:47:35 +05:30
|
|
|
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;
|
2013-06-20 13:56:12 +05:30
|
|
|
mdeps = xbps_dictionary_get(xhp->transd, "missing_deps");
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2013-06-20 13:56:12 +05:30
|
|
|
iter = xbps_array_iterator(mdeps);
|
2009-11-29 07:47:35 +05:30
|
|
|
if (iter == NULL)
|
|
|
|
goto out;
|
|
|
|
|
2013-06-20 13:56:12 +05:30
|
|
|
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
|
2009-11-29 07:47:35 +05:30
|
|
|
const char *curdep, *curver, *pkgver;
|
2020-02-09 00:01:29 +05:30
|
|
|
char curpkgnamedep[XBPS_NAME_SIZE];
|
|
|
|
char pkgnamedep[XBPS_NAME_SIZE];
|
2009-11-29 07:47:35 +05:30
|
|
|
|
2013-06-20 13:56:12 +05:30
|
|
|
assert(xbps_object_type(obj) == XBPS_TYPE_STRING);
|
|
|
|
curdep = xbps_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;
|
2020-02-09 00:01:29 +05:30
|
|
|
if (!xbps_pkgpattern_name(curpkgnamedep, XBPS_NAME_SIZE, curdep)) {
|
2009-11-29 07:47:35 +05:30
|
|
|
goto out;
|
2020-02-09 00:01:29 +05:30
|
|
|
}
|
|
|
|
if (!xbps_pkgpattern_name(pkgnamedep, XBPS_NAME_SIZE, reqpkg)) {
|
2009-11-29 07:47:35 +05:30
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
if (strcmp(pkgnamedep, curpkgnamedep) == 0) {
|
|
|
|
pkgfound = true;
|
2010-11-24 03:47:04 +05:30
|
|
|
if (strcmp(curver, pkgver) == 0) {
|
|
|
|
rv = EEXIST;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-11-29 07:47:35 +05:30
|
|
|
/*
|
|
|
|
* if new dependency version is greater than current
|
|
|
|
* one, store it.
|
|
|
|
*/
|
2022-12-24 18:16:33 +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;
|
2010-11-24 03:47:04 +05:30
|
|
|
rv = EEXIST;
|
2009-11-29 07:47:35 +05:30
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
update_pkgdep = true;
|
|
|
|
}
|
|
|
|
if (pkgfound)
|
|
|
|
break;
|
|
|
|
|
|
|
|
idx++;
|
|
|
|
}
|
|
|
|
add_pkgdep = true;
|
|
|
|
out:
|
|
|
|
if (iter)
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_iterator_release(iter);
|
2009-11-29 07:47:35 +05:30
|
|
|
if (update_pkgdep)
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_array_remove(mdeps, idx);
|
2013-06-27 20:22:31 +05:30
|
|
|
if (add_pkgdep) {
|
|
|
|
char *str;
|
|
|
|
|
2013-07-16 11:30:42 +05:30
|
|
|
str = xbps_xasprintf("MISSING: %s", reqpkg);
|
2013-06-27 20:22:31 +05:30
|
|
|
xbps_array_add_cstring(mdeps, str);
|
|
|
|
free(str);
|
2009-11-23 15:16:51 +05:30
|
|
|
}
|
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
|
2020-02-21 13:38:22 +05:30
|
|
|
repo_deps(struct xbps_handle *xhp,
|
|
|
|
xbps_array_t pkgs, /* array of pkgs */
|
|
|
|
xbps_dictionary_t pkg_repod, /* pkg repo dictionary */
|
|
|
|
unsigned short *depth) /* max recursion depth */
|
2009-08-17 22:37:20 +05:30
|
|
|
{
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_array_t pkg_rdeps = NULL, pkg_provides = NULL;
|
2023-05-31 00:08:40 +05:30
|
|
|
xbps_dictionary_t curpkgd = NULL, repopkgd = NULL;
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_trans_type_t ttype;
|
|
|
|
pkg_state_t state;
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_t obj;
|
|
|
|
xbps_object_iterator_t iter;
|
2020-02-21 13:38:22 +05:30
|
|
|
const char *curpkg = NULL, *reqpkg = NULL, *pkgver_q = NULL;
|
|
|
|
char pkgname[XBPS_NAME_SIZE], reqpkgname[XBPS_NAME_SIZE];
|
2010-11-19 18:10:13 +05:30
|
|
|
int rv = 0;
|
2009-08-17 22:37:20 +05:30
|
|
|
|
2020-02-21 13:38:22 +05:30
|
|
|
assert(xhp);
|
|
|
|
assert(pkgs);
|
|
|
|
assert(pkg_repod);
|
|
|
|
|
2011-10-30 21:11:39 +05:30
|
|
|
if (*depth >= MAX_DEPTH)
|
2011-01-28 16:42:47 +05:30
|
|
|
return ELOOP;
|
|
|
|
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &curpkg);
|
|
|
|
pkg_provides = xbps_dictionary_get(pkg_repod, "provides");
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
|
|
|
* Iterate over the list of required run dependencies for
|
|
|
|
* current package.
|
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
pkg_rdeps = xbps_dictionary_get(pkg_repod, "run_depends");
|
|
|
|
if (xbps_array_count(pkg_rdeps) == 0)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
iter = xbps_array_iterator(pkg_rdeps);
|
2012-11-30 14:19:09 +05:30
|
|
|
assert(iter);
|
|
|
|
|
2013-06-20 13:56:12 +05:30
|
|
|
while ((obj = xbps_object_iterator_next(iter))) {
|
2020-02-03 13:49:54 +05:30
|
|
|
bool error = false, foundvpkg = false;
|
2023-05-31 00:08:40 +05:30
|
|
|
bool autoinst = true;
|
2020-02-09 00:01:29 +05:30
|
|
|
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = XBPS_TRANS_UNKNOWN;
|
2013-06-20 13:56:12 +05:30
|
|
|
reqpkg = xbps_string_cstring_nocopy(obj);
|
2020-02-03 13:49:54 +05:30
|
|
|
|
2012-01-22 15:22:35 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("%s", "");
|
2014-05-16 01:37:10 +05:30
|
|
|
for (unsigned short x = 0; x < *depth; x++) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append(" ");
|
2014-05-16 01:37:10 +05:30
|
|
|
}
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("%s: requires dependency '%s': ", curpkg ? curpkg : " ", reqpkg);
|
2011-10-30 21:11:39 +05:30
|
|
|
}
|
2020-02-09 00:01:29 +05:30
|
|
|
if ((!xbps_pkgpattern_name(pkgname, sizeof(pkgname), reqpkg)) &&
|
|
|
|
(!xbps_pkg_name(pkgname, sizeof(pkgname), reqpkg))) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("%s: can't guess pkgname for dependency: %s\n", curpkg, reqpkg);
|
2014-07-02 14:29:25 +05:30
|
|
|
xbps_set_cb_state(xhp, XBPS_STATE_INVALID_DEP, ENXIO, NULL,
|
|
|
|
"%s: can't guess pkgname for dependency '%s'", curpkg, reqpkg);
|
|
|
|
rv = ENXIO;
|
2012-12-02 21:04:01 +05:30
|
|
|
break;
|
|
|
|
}
|
2019-03-05 21:15:29 +05:30
|
|
|
/*
|
|
|
|
* Pass 0: check if required dependency is ignored.
|
|
|
|
*/
|
|
|
|
if (xbps_pkg_is_ignored(xhp, pkgname)) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("%s ignored.\n", pkgname);
|
2019-03-05 21:15:29 +05:30
|
|
|
continue;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2014-04-20 20:24:50 +05:30
|
|
|
* Pass 1: check if required dependency is provided as virtual
|
|
|
|
* package via "provides", if true ignore dependency.
|
|
|
|
*/
|
|
|
|
if (pkg_provides && xbps_match_virtual_pkg_in_array(pkg_provides, reqpkg)) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("%s is a vpkg provided by %s, ignored.\n", pkgname, curpkg);
|
2014-04-20 20:24:50 +05:30
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Pass 2: check if required dependency has been already
|
2014-03-16 22:38:59 +05:30
|
|
|
* added in the transaction dictionary.
|
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
if ((curpkgd = xbps_find_pkg_in_array(pkgs, reqpkg, 0)) ||
|
|
|
|
(curpkgd = xbps_find_virtualpkg_in_array(xhp, pkgs, reqpkg, 0))) {
|
2021-03-19 18:24:23 +05:30
|
|
|
xbps_trans_type_t ttype_q = xbps_transaction_pkg_type(curpkgd);
|
2014-05-16 01:37:10 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q);
|
2021-03-19 18:24:23 +05:30
|
|
|
if (ttype_q != XBPS_TRANS_REMOVE && ttype_q != XBPS_TRANS_HOLD) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append(" (%s queued %d)\n", pkgver_q, ttype_q);
|
2021-03-19 18:24:23 +05:30
|
|
|
continue;
|
|
|
|
}
|
2014-03-16 22:38:59 +05:30
|
|
|
}
|
|
|
|
/*
|
2014-04-20 20:24:50 +05:30
|
|
|
* Pass 3: check if required dependency is already installed
|
2011-10-27 14:24:28 +05:30
|
|
|
* and its version is fully matched.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2014-05-16 01:37:10 +05:30
|
|
|
if ((curpkgd = xbps_pkgdb_get_pkg(xhp, pkgname)) == NULL) {
|
|
|
|
if ((curpkgd = xbps_pkgdb_get_virtualpkg(xhp, pkgname))) {
|
|
|
|
foundvpkg = true;
|
|
|
|
}
|
|
|
|
}
|
2020-01-25 17:35:46 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY) {
|
|
|
|
/*
|
|
|
|
* if XBPS_FLAG_DOWNLOAD_ONLY always assume
|
|
|
|
* all deps are not installed. This way one can download
|
|
|
|
* the whole set of binary packages to perform an
|
|
|
|
* off-line installation later on.
|
|
|
|
*/
|
|
|
|
curpkgd = NULL;
|
|
|
|
}
|
|
|
|
|
2014-05-16 01:37:10 +05:30
|
|
|
if (curpkgd == NULL) {
|
2011-10-27 14:24:28 +05:30
|
|
|
if (errno && errno != ENOENT) {
|
|
|
|
/* error */
|
|
|
|
rv = errno;
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("failed to find installed pkg for `%s': %s\n", reqpkg, strerror(rv));
|
2011-10-27 14:24:28 +05:30
|
|
|
break;
|
|
|
|
}
|
2014-05-22 15:49:35 +05:30
|
|
|
/* Required dependency not installed */
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("not installed.\n");
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = XBPS_TRANS_INSTALL;
|
2011-10-27 14:24:28 +05:30
|
|
|
state = XBPS_PKG_STATE_NOT_INSTALLED;
|
2011-01-25 22:39:27 +05:30
|
|
|
} else {
|
|
|
|
/*
|
2014-05-22 15:49:35 +05:30
|
|
|
* Required dependency is installed, check if its version can
|
|
|
|
* satisfy the requirements.
|
2011-01-25 22:39:27 +05:30
|
|
|
*/
|
2014-05-22 15:49:35 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q);
|
2011-01-25 22:39:27 +05:30
|
|
|
|
|
|
|
/* Check its state */
|
2014-05-16 01:37:10 +05:30
|
|
|
if ((rv = xbps_pkg_state_dictionary(curpkgd, &state)) != 0) {
|
2009-11-26 07:52:50 +05:30
|
|
|
break;
|
2014-05-16 01:37:10 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if (foundvpkg && xbps_match_virtual_pkg_in_dict(curpkgd, reqpkg)) {
|
2011-06-23 15:00:04 +05:30
|
|
|
/*
|
2014-05-18 17:54:59 +05:30
|
|
|
* Check if required dependency is a virtual package and is satisfied
|
|
|
|
* by an installed package.
|
2011-06-23 15:00:04 +05:30
|
|
|
*/
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("[virtual] satisfied by `%s'.\n", pkgver_q);
|
2011-06-23 15:00:04 +05:30
|
|
|
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) {
|
2020-02-09 00:01:29 +05:30
|
|
|
char curpkgname[XBPS_NAME_SIZE];
|
2014-05-22 15:49:35 +05:30
|
|
|
/*
|
|
|
|
* The version requirement is not satisfied.
|
|
|
|
*/
|
2020-02-09 00:01:29 +05:30
|
|
|
if (!xbps_pkg_name(curpkgname, sizeof(curpkgname), pkgver_q)) {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2014-05-22 15:49:35 +05:30
|
|
|
if (strcmp(pkgname, curpkgname)) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("not installed `%s (vpkg)'", pkgver_q);
|
2014-05-22 15:49:35 +05:30
|
|
|
if (xbps_dictionary_get(curpkgd, "hold")) {
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = XBPS_TRANS_HOLD;
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append(" on hold state! ignoring package.\n");
|
2021-03-19 18:22:37 +05:30
|
|
|
rv = ENODEV;
|
2014-05-18 17:54:59 +05:30
|
|
|
} else {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("\n");
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = XBPS_TRANS_INSTALL;
|
2014-05-18 17:54:59 +05:30
|
|
|
}
|
|
|
|
} else {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("installed `%s', must be updated", pkgver_q);
|
2014-05-18 17:54:59 +05:30
|
|
|
if (xbps_dictionary_get(curpkgd, "hold")) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append(" on hold state! ignoring package.\n");
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = XBPS_TRANS_HOLD;
|
2021-03-19 18:22:37 +05:30
|
|
|
rv = ENODEV;
|
2014-05-18 17:54:59 +05:30
|
|
|
} else {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("\n");
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = XBPS_TRANS_UPDATE;
|
2014-05-16 01:37:10 +05:30
|
|
|
}
|
2013-08-12 18:16:54 +05:30
|
|
|
}
|
2021-03-19 18:22:37 +05:30
|
|
|
/*
|
|
|
|
* Not satisfied and package on hold.
|
|
|
|
*/
|
|
|
|
if (rv == ENODEV) {
|
|
|
|
rv = add_missing_reqdep(xhp, reqpkg);
|
|
|
|
if (rv != 0 && rv != EEXIST) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("`%s': add_missing_reqdep failed\n", reqpkg);
|
2021-03-19 18:22:37 +05:30
|
|
|
break;
|
|
|
|
} else if (rv == EEXIST) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("`%s' missing dep already added.\n", reqpkg);
|
2021-03-19 18:22:37 +05:30
|
|
|
rv = 0;
|
|
|
|
continue;
|
|
|
|
} else {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("`%s' added into the missing deps array.\n", reqpkg);
|
2021-03-19 18:22:37 +05:30
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2011-01-27 22:53:32 +05:30
|
|
|
} else if (rv == 1) {
|
2014-05-22 15:49:35 +05:30
|
|
|
/*
|
|
|
|
* The version requirement is satisfied.
|
|
|
|
*/
|
2011-01-28 01:32:56 +05:30
|
|
|
rv = 0;
|
2011-01-25 22:39:27 +05:30
|
|
|
if (state == XBPS_PKG_STATE_UNPACKED) {
|
|
|
|
/*
|
2014-05-18 17:54:59 +05:30
|
|
|
* 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
|
|
|
*/
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("installed `%s', must be configured.\n", pkgver_q);
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = XBPS_TRANS_CONFIGURE;
|
2012-11-30 11:41:51 +05:30
|
|
|
} else if (state == XBPS_PKG_STATE_INSTALLED) {
|
2011-01-25 22:39:27 +05:30
|
|
|
/*
|
2014-05-18 17:54:59 +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
|
|
|
*/
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("installed `%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 */
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("failed to match pattern %s with %s\n", reqpkg, pkgver_q);
|
2011-10-27 14:24:28 +05:30
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2014-04-20 20:24:50 +05:30
|
|
|
* Pass 4: find required dependency in repository pool.
|
2012-01-24 23:15:50 +05:30
|
|
|
* 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
|
|
|
*/
|
2021-07-20 00:59:32 +05:30
|
|
|
if (xbps_dictionary_get(curpkgd, "repolock")) {
|
|
|
|
const char *repourl = NULL;
|
|
|
|
struct xbps_repo *repo = NULL;
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("`%s' is repolocked, looking at single repository.\n", reqpkg);
|
2021-07-20 00:59:32 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(curpkgd, "repository", &repourl);
|
|
|
|
if (repourl && (repo = xbps_regget_repo(xhp, repourl))) {
|
2023-05-31 00:08:40 +05:30
|
|
|
repopkgd = xbps_repo_get_pkg(repo, reqpkg);
|
2021-07-20 00:59:32 +05:30
|
|
|
} else {
|
2023-05-31 00:08:40 +05:30
|
|
|
repopkgd = NULL;
|
2021-07-20 00:59:32 +05:30
|
|
|
}
|
|
|
|
} else {
|
2023-05-31 00:08:40 +05:30
|
|
|
repopkgd = xbps_rpool_get_pkg(xhp, reqpkg);
|
|
|
|
if (!repopkgd) {
|
|
|
|
repopkgd = xbps_rpool_get_virtualpkg(xhp, reqpkg);
|
2021-07-20 00:59:32 +05:30
|
|
|
}
|
|
|
|
}
|
2023-05-31 00:08:40 +05:30
|
|
|
if (repopkgd == NULL) {
|
2012-05-30 13:52:53 +05:30
|
|
|
/* pkg not found, there was some error */
|
|
|
|
if (errno && errno != ENOENT) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("failed to find pkg for `%s' in rpool: %s\n", reqpkg, strerror(errno));
|
2012-05-30 13:52:53 +05:30
|
|
|
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) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("`%s': add_missing_reqdep failed\n", reqpkg);
|
2012-05-30 13:52:53 +05:30
|
|
|
break;
|
|
|
|
} else if (rv == EEXIST) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("`%s' missing dep already added.\n", reqpkg);
|
2012-05-30 13:52:53 +05:30
|
|
|
rv = 0;
|
|
|
|
continue;
|
|
|
|
} else {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("`%s' added into the missing deps array.\n", reqpkg);
|
2012-05-30 13:52:53 +05:30
|
|
|
continue;
|
2011-10-27 14:24:28 +05:30
|
|
|
}
|
|
|
|
}
|
2020-02-09 00:01:29 +05:30
|
|
|
|
|
|
|
|
2023-05-31 00:08:40 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(repopkgd, "pkgver", &pkgver_q);
|
2020-02-09 00:01:29 +05:30
|
|
|
if (!xbps_pkg_name(reqpkgname, sizeof(reqpkgname), pkgver_q)) {
|
|
|
|
rv = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2013-09-17 12:34:01 +05:30
|
|
|
/*
|
|
|
|
* Check dependency validity.
|
|
|
|
*/
|
2020-02-09 00:01:29 +05:30
|
|
|
if (!xbps_pkg_name(pkgname, sizeof(pkgname), curpkg)) {
|
|
|
|
rv = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2013-09-17 12:34:01 +05:30
|
|
|
if (strcmp(pkgname, reqpkgname) == 0) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("[ignoring wrong dependency %s (depends on itself)]\n", reqpkg);
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_remove_string_from_array(pkg_rdeps, reqpkg);
|
2013-09-17 12:34:01 +05:30
|
|
|
continue;
|
|
|
|
}
|
2020-02-03 13:49:54 +05:30
|
|
|
/*
|
|
|
|
* Installed package must be updated, check if dependency is
|
|
|
|
* satisfied.
|
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
if (ttype == XBPS_TRANS_UPDATE) {
|
2020-02-03 13:49:54 +05:30
|
|
|
switch (xbps_pkgpattern_match(pkgver_q, reqpkg)) {
|
|
|
|
case 0: /* nomatch */
|
|
|
|
break;
|
|
|
|
case 1: /* match */
|
2020-02-09 00:01:29 +05:30
|
|
|
if (!xbps_pkg_name(pkgname, sizeof(pkgname), pkgver_q)) {
|
|
|
|
abort();
|
|
|
|
}
|
2020-02-03 13:49:54 +05:30
|
|
|
/*
|
|
|
|
* If there's an update in transaction,
|
|
|
|
* it's assumed version is greater.
|
|
|
|
* So dependency pattern matching didn't
|
|
|
|
* succeed... return ENODEV.
|
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
if (xbps_find_pkg_in_array(pkgs, pkgname, XBPS_TRANS_UPDATE)) {
|
2020-02-03 13:49:54 +05:30
|
|
|
error = true;
|
|
|
|
rv = ENODEV;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
error = true;
|
|
|
|
rv = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
2023-05-31 00:08:40 +05:30
|
|
|
pkg_rdeps = xbps_dictionary_get(repopkgd, "run_depends");
|
2020-02-21 13:38:22 +05:30
|
|
|
if (xbps_array_count(pkg_rdeps)) {
|
2014-10-18 16:05:47 +05:30
|
|
|
/*
|
2020-02-21 13:38:22 +05:30
|
|
|
* Process rundeps for current pkg found in rpool.
|
2014-10-18 16:05:47 +05:30
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_DEBUG) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("%s", "");
|
2020-02-21 13:38:22 +05:30
|
|
|
for (unsigned short x = 0; x < *depth; x++) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append(" ");
|
2020-02-21 13:38:22 +05:30
|
|
|
}
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf_append("%s: finding dependencies:\n", pkgver_q);
|
2020-02-21 13:38:22 +05:30
|
|
|
}
|
|
|
|
(*depth)++;
|
2023-05-31 00:08:40 +05:30
|
|
|
rv = repo_deps(xhp, pkgs, repopkgd, depth);
|
2014-10-18 16:05:47 +05:30
|
|
|
if (rv != 0) {
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("Error checking %s for rundeps: %s\n", reqpkg, strerror(rv));
|
2014-10-18 16:05:47 +05:30
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-02-21 13:38:22 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY) {
|
|
|
|
ttype = XBPS_TRANS_DOWNLOAD;
|
|
|
|
} else if (xbps_dictionary_get(curpkgd, "hold")) {
|
|
|
|
ttype = XBPS_TRANS_HOLD;
|
2011-10-30 21:11:39 +05:30
|
|
|
}
|
2023-05-31 00:08:40 +05:30
|
|
|
if (ttype == XBPS_TRANS_UPDATE || ttype == XBPS_TRANS_CONFIGURE) {
|
|
|
|
/*
|
|
|
|
* If the package is already installed preserve the installation mode,
|
|
|
|
* which is not automatic if automatic-install is not set.
|
|
|
|
*/
|
|
|
|
bool pkgd_auto = false;
|
|
|
|
xbps_dictionary_get_bool(curpkgd, "automatic-install", &pkgd_auto);
|
|
|
|
autoinst = pkgd_auto;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
/*
|
2020-02-21 13:38:22 +05:30
|
|
|
* All deps were processed, store pkg in transaction.
|
2009-08-17 22:37:20 +05:30
|
|
|
*/
|
2023-05-31 00:08:40 +05:30
|
|
|
if (!xbps_transaction_pkg_type_set(repopkgd, ttype)) {
|
2020-02-21 13:38:22 +05:30
|
|
|
rv = EINVAL;
|
2023-05-31 00:08:40 +05:30
|
|
|
xbps_dbg_printf("xbps_transaction_pkg_type_set failed for `%s': %s\n", reqpkg, strerror(rv));
|
2009-11-23 02:22:57 +05:30
|
|
|
break;
|
2009-11-23 05:13:48 +05:30
|
|
|
}
|
2023-05-31 00:08:40 +05:30
|
|
|
if (!xbps_transaction_store(xhp, pkgs, repopkgd, autoinst)) {
|
2020-02-21 13:38:22 +05:30
|
|
|
rv = EINVAL;
|
2022-12-24 18:16:33 +05:30
|
|
|
xbps_dbg_printf("xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv));
|
2014-10-18 16:05:47 +05:30
|
|
|
break;
|
|
|
|
}
|
2009-08-17 22:37:20 +05:30
|
|
|
}
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_iterator_release(iter);
|
2020-02-21 13:38:22 +05:30
|
|
|
out:
|
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
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_transaction_pkg_deps(struct xbps_handle *xhp,
|
|
|
|
xbps_array_t pkgs,
|
|
|
|
xbps_dictionary_t pkg_repod)
|
2010-01-21 07:40:19 +05:30
|
|
|
{
|
2011-01-28 16:42:47 +05:30
|
|
|
const char *pkgver;
|
2013-06-12 13:34:10 +05:30
|
|
|
unsigned short depth = 0;
|
2010-01-21 07:40:19 +05:30
|
|
|
|
2020-02-21 13:38:22 +05:30
|
|
|
assert(xhp);
|
|
|
|
assert(pkgs);
|
|
|
|
assert(pkg_repod);
|
2010-01-21 07:40:19 +05:30
|
|
|
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
|
2022-12-24 18:16:33 +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
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
return repo_deps(xhp, pkgs, pkg_repod, &depth);
|
2010-01-21 07:40:19 +05:30
|
|
|
}
|