2011-01-24 21:25:58 +05:30
|
|
|
/*-
|
2020-02-21 13:38:22 +05:30
|
|
|
* Copyright (c) 2009-2020 Juan Romero Pardines.
|
2011-01-24 21:25:58 +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 <stdbool.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
2014-07-13 15:15:04 +05:30
|
|
|
#include <sys/statvfs.h>
|
2011-01-24 21:25:58 +05:30
|
|
|
|
|
|
|
#include "xbps_api_impl.h"
|
|
|
|
|
|
|
|
/**
|
2019-06-21 14:18:17 +05:30
|
|
|
* @file lib/transaction_prepare.c
|
2011-01-24 21:25:58 +05:30
|
|
|
* @brief Transaction handling routines
|
2012-01-20 16:47:27 +05:30
|
|
|
* @defgroup transaction Transaction handling functions
|
2011-01-24 21:25:58 +05:30
|
|
|
*
|
|
|
|
* The following image shows off the full transaction dictionary returned
|
|
|
|
* by xbps_transaction_prepare().
|
|
|
|
*
|
|
|
|
* @image html images/xbps_transaction_dictionary.png
|
|
|
|
*
|
|
|
|
* Legend:
|
|
|
|
* - <b>Salmon bg box</b>: The transaction dictionary.
|
|
|
|
* - <b>White bg box</b>: mandatory objects.
|
|
|
|
* - <b>Grey bg box</b>: optional objects.
|
|
|
|
* - <b>Green bg box</b>: possible value set in the object, only one of them
|
|
|
|
* will be set.
|
|
|
|
*
|
|
|
|
* Text inside of white boxes are the key associated with the object, its
|
|
|
|
* data type is specified on its edge, i.e string, array, integer, dictionary.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int
|
2012-06-14 11:52:11 +05:30
|
|
|
compute_transaction_stats(struct xbps_handle *xhp)
|
2011-01-24 21:25:58 +05:30
|
|
|
{
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_dictionary_t pkg_metad;
|
|
|
|
xbps_object_iterator_t iter;
|
|
|
|
xbps_object_t obj;
|
2014-07-13 15:15:04 +05:30
|
|
|
struct statvfs svfs;
|
2014-07-18 16:14:32 +05:30
|
|
|
uint64_t rootdir_free_size, tsize, dlsize, instsize, rmsize;
|
2014-07-14 13:00:28 +05:30
|
|
|
uint32_t inst_pkgcnt, up_pkgcnt, cf_pkgcnt, rm_pkgcnt, dl_pkgcnt;
|
2020-04-23 09:33:56 +05:30
|
|
|
uint32_t hold_pkgcnt;
|
2011-01-24 21:25:58 +05:30
|
|
|
|
2020-04-23 09:33:56 +05:30
|
|
|
inst_pkgcnt = up_pkgcnt = cf_pkgcnt = rm_pkgcnt = 0;
|
|
|
|
hold_pkgcnt = dl_pkgcnt = 0;
|
2019-06-18 19:47:16 +05:30
|
|
|
tsize = dlsize = instsize = rmsize = 0;
|
2011-07-24 21:13:17 +05:30
|
|
|
|
2012-06-14 11:52:11 +05:30
|
|
|
iter = xbps_array_iter_from_dict(xhp->transd, "packages");
|
2011-01-24 21:25:58 +05:30
|
|
|
if (iter == NULL)
|
|
|
|
return EINVAL;
|
|
|
|
|
2013-06-20 13:56:12 +05:30
|
|
|
while ((obj = xbps_object_iterator_next(iter)) != NULL) {
|
2020-02-21 13:38:22 +05:30
|
|
|
const char *pkgver = NULL, *repo = NULL, *pkgname = NULL;
|
2014-07-13 13:26:06 +05:30
|
|
|
bool preserve = false;
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_trans_type_t ttype;
|
2011-07-24 21:13:17 +05:30
|
|
|
/*
|
|
|
|
* Count number of pkgs to be removed, configured,
|
|
|
|
* installed and updated.
|
|
|
|
*/
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgname);
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_dictionary_get_cstring_nocopy(obj, "repository", &repo);
|
2014-07-13 13:26:06 +05:30
|
|
|
xbps_dictionary_get_bool(obj, "preserve", &preserve);
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = xbps_transaction_pkg_type(obj);
|
2012-01-25 09:26:54 +05:30
|
|
|
|
2020-02-21 15:09:38 +05:30
|
|
|
if (ttype == XBPS_TRANS_REMOVE) {
|
|
|
|
rm_pkgcnt++;
|
|
|
|
} else if (ttype == XBPS_TRANS_CONFIGURE) {
|
|
|
|
cf_pkgcnt++;
|
|
|
|
} else if (ttype == XBPS_TRANS_INSTALL || ttype == XBPS_TRANS_REINSTALL) {
|
|
|
|
inst_pkgcnt++;
|
|
|
|
} else if (ttype == XBPS_TRANS_UPDATE) {
|
|
|
|
up_pkgcnt++;
|
2020-04-23 09:33:56 +05:30
|
|
|
} else if (ttype == XBPS_TRANS_HOLD) {
|
|
|
|
hold_pkgcnt++;
|
2020-02-21 15:09:38 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
if ((ttype != XBPS_TRANS_CONFIGURE) && (ttype != XBPS_TRANS_REMOVE) &&
|
|
|
|
xbps_repository_is_remote(repo) && !xbps_binpkg_exists(xhp, obj)) {
|
2020-02-18 13:04:41 +05:30
|
|
|
xbps_dictionary_get_uint64(obj, "filename-size", &tsize);
|
|
|
|
tsize += 512;
|
|
|
|
dlsize += tsize;
|
|
|
|
dl_pkgcnt++;
|
|
|
|
xbps_dictionary_set_bool(obj, "download", true);
|
|
|
|
}
|
2020-01-25 17:35:46 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY) {
|
|
|
|
continue;
|
|
|
|
}
|
2020-02-21 15:09:38 +05:30
|
|
|
/* installed_size from repo */
|
2020-02-25 13:13:52 +05:30
|
|
|
if (ttype != XBPS_TRANS_REMOVE && ttype != XBPS_TRANS_HOLD &&
|
|
|
|
ttype != XBPS_TRANS_CONFIGURE) {
|
|
|
|
xbps_dictionary_get_uint64(obj, "installed_size", &tsize);
|
|
|
|
instsize += tsize;
|
|
|
|
}
|
2011-11-27 13:35:18 +05:30
|
|
|
/*
|
2020-02-21 13:38:22 +05:30
|
|
|
* If removing or updating a package without preserve,
|
|
|
|
* get installed_size from pkgdb instead.
|
2011-11-27 13:35:18 +05:30
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
if (ttype == XBPS_TRANS_REMOVE ||
|
|
|
|
((ttype == XBPS_TRANS_UPDATE) && !preserve)) {
|
2014-09-11 03:42:12 +05:30
|
|
|
pkg_metad = xbps_pkgdb_get_pkg(xhp, pkgname);
|
2011-12-24 05:35:26 +05:30
|
|
|
if (pkg_metad == NULL)
|
|
|
|
continue;
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_dictionary_get_uint64(pkg_metad,
|
2011-11-27 13:35:18 +05:30
|
|
|
"installed_size", &tsize);
|
|
|
|
rmsize += tsize;
|
2012-01-25 09:40:24 +05:30
|
|
|
}
|
2011-01-24 21:25:58 +05:30
|
|
|
}
|
2013-12-14 09:24:52 +05:30
|
|
|
xbps_object_iterator_release(iter);
|
2012-01-25 09:26:54 +05:30
|
|
|
|
2013-12-16 11:54:17 +05:30
|
|
|
if (instsize > rmsize) {
|
|
|
|
instsize -= rmsize;
|
|
|
|
rmsize = 0;
|
|
|
|
} else if (rmsize > instsize) {
|
|
|
|
rmsize -= instsize;
|
|
|
|
instsize = 0;
|
|
|
|
} else {
|
|
|
|
instsize = rmsize = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
2013-12-14 09:24:52 +05:30
|
|
|
"total-install-pkgs", inst_pkgcnt))
|
|
|
|
return EINVAL;
|
2013-12-16 11:54:17 +05:30
|
|
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
2013-12-14 09:24:52 +05:30
|
|
|
"total-update-pkgs", up_pkgcnt))
|
|
|
|
return EINVAL;
|
2013-12-16 11:54:17 +05:30
|
|
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
2013-12-14 09:24:52 +05:30
|
|
|
"total-configure-pkgs", cf_pkgcnt))
|
|
|
|
return EINVAL;
|
2013-12-16 11:54:17 +05:30
|
|
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
2013-12-14 09:24:52 +05:30
|
|
|
"total-remove-pkgs", rm_pkgcnt))
|
|
|
|
return EINVAL;
|
2014-07-14 13:00:28 +05:30
|
|
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
|
|
|
"total-download-pkgs", dl_pkgcnt))
|
|
|
|
return EINVAL;
|
2020-04-23 09:33:56 +05:30
|
|
|
if (!xbps_dictionary_set_uint32(xhp->transd,
|
|
|
|
"total-hold-pkgs", hold_pkgcnt))
|
|
|
|
return EINVAL;
|
2013-06-20 13:56:12 +05:30
|
|
|
if (!xbps_dictionary_set_uint64(xhp->transd,
|
2013-12-14 09:24:52 +05:30
|
|
|
"total-installed-size", instsize))
|
|
|
|
return EINVAL;
|
2013-06-20 13:56:12 +05:30
|
|
|
if (!xbps_dictionary_set_uint64(xhp->transd,
|
2013-12-14 09:24:52 +05:30
|
|
|
"total-download-size", dlsize))
|
|
|
|
return EINVAL;
|
2013-06-20 13:56:12 +05:30
|
|
|
if (!xbps_dictionary_set_uint64(xhp->transd,
|
2013-12-14 09:24:52 +05:30
|
|
|
"total-removed-size", rmsize))
|
|
|
|
return EINVAL;
|
2011-01-24 21:25:58 +05:30
|
|
|
|
2014-07-13 15:15:04 +05:30
|
|
|
/* Get free space from target rootdir: return ENOSPC if there's not enough space */
|
|
|
|
if (statvfs(xhp->rootdir, &svfs) == -1) {
|
|
|
|
xbps_dbg_printf(xhp, "%s: statvfs failed: %s\n", __func__, strerror(errno));
|
2014-07-14 13:39:34 +05:30
|
|
|
return 0;
|
2014-07-13 15:15:04 +05:30
|
|
|
}
|
|
|
|
/* compute free space on disk */
|
2014-09-18 15:41:02 +05:30
|
|
|
rootdir_free_size = svfs.f_bfree * svfs.f_bsize;
|
2014-07-13 15:15:04 +05:30
|
|
|
|
|
|
|
if (!xbps_dictionary_set_uint64(xhp->transd,
|
|
|
|
"disk-free-size", rootdir_free_size))
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
if (instsize > rootdir_free_size)
|
|
|
|
return ENOSPC;
|
|
|
|
|
2013-12-14 09:24:52 +05:30
|
|
|
return 0;
|
2011-01-24 21:25:58 +05:30
|
|
|
}
|
|
|
|
|
2012-01-22 14:30:46 +05:30
|
|
|
int HIDDEN
|
|
|
|
xbps_transaction_init(struct xbps_handle *xhp)
|
2011-01-24 21:25:58 +05:30
|
|
|
{
|
2014-07-13 13:26:06 +05:30
|
|
|
xbps_array_t array;
|
2019-06-17 15:02:46 +05:30
|
|
|
xbps_dictionary_t dict;
|
2011-01-24 21:25:58 +05:30
|
|
|
|
2012-01-22 14:30:46 +05:30
|
|
|
if (xhp->transd != NULL)
|
|
|
|
return 0;
|
2011-01-24 21:25:58 +05:30
|
|
|
|
2013-06-20 13:56:12 +05:30
|
|
|
if ((xhp->transd = xbps_dictionary_create()) == NULL)
|
2012-01-22 14:30:46 +05:30
|
|
|
return ENOMEM;
|
2011-01-24 21:25:58 +05:30
|
|
|
|
2019-01-18 23:51:47 +05:30
|
|
|
if ((array = xbps_array_create()) == NULL) {
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_release(xhp->transd);
|
2012-01-22 14:30:46 +05:30
|
|
|
xhp->transd = NULL;
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
2014-10-18 16:05:47 +05:30
|
|
|
if (!xbps_dictionary_set(xhp->transd, "packages", array)) {
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_release(xhp->transd);
|
2012-01-22 14:30:46 +05:30
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
2014-07-13 13:26:06 +05:30
|
|
|
xbps_object_release(array);
|
2014-05-22 14:11:07 +05:30
|
|
|
|
2014-07-13 13:26:06 +05:30
|
|
|
if ((array = xbps_array_create()) == NULL) {
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_release(xhp->transd);
|
2012-01-22 14:30:46 +05:30
|
|
|
xhp->transd = NULL;
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
2014-07-13 13:26:06 +05:30
|
|
|
if (!xbps_dictionary_set(xhp->transd, "missing_deps", array)) {
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_release(xhp->transd);
|
2012-01-22 14:30:46 +05:30
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
2014-07-13 13:26:06 +05:30
|
|
|
xbps_object_release(array);
|
2014-05-22 14:11:07 +05:30
|
|
|
|
2014-09-11 03:42:12 +05:30
|
|
|
if ((array = xbps_array_create()) == NULL) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
if (!xbps_dictionary_set(xhp->transd, "missing_shlibs", array)) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
xbps_object_release(array);
|
|
|
|
|
2014-07-13 13:26:06 +05:30
|
|
|
if ((array = xbps_array_create()) == NULL) {
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_release(xhp->transd);
|
2012-06-11 19:44:03 +05:30
|
|
|
xhp->transd = NULL;
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
2014-07-13 13:26:06 +05:30
|
|
|
if (!xbps_dictionary_set(xhp->transd, "conflicts", array)) {
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_object_release(xhp->transd);
|
2012-06-11 19:44:03 +05:30
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
2014-07-13 13:26:06 +05:30
|
|
|
xbps_object_release(array);
|
2012-01-22 14:30:46 +05:30
|
|
|
|
2019-06-17 15:02:46 +05:30
|
|
|
if ((dict = xbps_dictionary_create()) == NULL) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
if (!xbps_dictionary_set(xhp->transd, "obsolete_files", dict)) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
xbps_object_release(dict);
|
|
|
|
|
|
|
|
if ((dict = xbps_dictionary_create()) == NULL) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
if (!xbps_dictionary_set(xhp->transd, "remove_files", dict)) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
xbps_object_release(dict);
|
|
|
|
|
2012-01-22 14:30:46 +05:30
|
|
|
return 0;
|
2011-01-24 21:25:58 +05:30
|
|
|
}
|
|
|
|
|
2012-01-22 14:30:46 +05:30
|
|
|
int
|
2012-06-14 11:52:11 +05:30
|
|
|
xbps_transaction_prepare(struct xbps_handle *xhp)
|
2011-01-24 21:25:58 +05:30
|
|
|
{
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_array_t pkgs, edges;
|
2019-12-28 01:41:29 +05:30
|
|
|
xbps_dictionary_t tpkgd;
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_trans_type_t ttype;
|
2019-08-05 15:18:15 +05:30
|
|
|
unsigned int i, cnt;
|
2011-01-24 21:25:58 +05:30
|
|
|
int rv = 0;
|
2019-12-28 01:41:29 +05:30
|
|
|
bool all_on_hold = true;
|
2011-01-24 21:25:58 +05:30
|
|
|
|
2019-06-21 20:43:06 +05:30
|
|
|
if ((rv = xbps_transaction_init(xhp)) != 0)
|
|
|
|
return rv;
|
|
|
|
|
2012-01-22 14:30:46 +05:30
|
|
|
if (xhp->transd == NULL)
|
|
|
|
return ENXIO;
|
|
|
|
|
2019-08-05 15:18:15 +05:30
|
|
|
/*
|
|
|
|
* Collect dependencies for pkgs in transaction.
|
|
|
|
*/
|
|
|
|
if ((edges = xbps_array_create()) == NULL)
|
|
|
|
return ENOMEM;
|
2020-02-21 13:38:22 +05:30
|
|
|
|
|
|
|
xbps_dbg_printf(xhp, "%s: processing deps\n", __func__);
|
2019-08-05 15:18:15 +05:30
|
|
|
/*
|
|
|
|
* The edges are also appended after its dependencies have been
|
|
|
|
* collected; the edges at the original array are removed later.
|
|
|
|
*/
|
|
|
|
pkgs = xbps_dictionary_get(xhp->transd, "packages");
|
|
|
|
assert(xbps_object_type(pkgs) == XBPS_TYPE_ARRAY);
|
|
|
|
cnt = xbps_array_count(pkgs);
|
|
|
|
for (i = 0; i < cnt; i++) {
|
|
|
|
xbps_dictionary_t pkgd;
|
|
|
|
xbps_string_t str;
|
|
|
|
|
|
|
|
pkgd = xbps_array_get(pkgs, i);
|
|
|
|
str = xbps_dictionary_get(pkgd, "pkgver");
|
2020-02-21 13:38:22 +05:30
|
|
|
ttype = xbps_transaction_pkg_type(pkgd);
|
|
|
|
|
|
|
|
if (ttype == XBPS_TRANS_REMOVE || ttype == XBPS_TRANS_HOLD)
|
2019-08-05 15:18:15 +05:30
|
|
|
continue;
|
2014-10-18 16:05:47 +05:30
|
|
|
|
2019-08-05 15:18:15 +05:30
|
|
|
assert(xbps_object_type(str) == XBPS_TYPE_STRING);
|
2014-10-18 16:05:47 +05:30
|
|
|
|
2020-02-21 13:38:22 +05:30
|
|
|
if (!xbps_array_add(edges, str)) {
|
|
|
|
xbps_object_release(edges);
|
2019-08-05 15:18:15 +05:30
|
|
|
return ENOMEM;
|
2020-02-21 13:38:22 +05:30
|
|
|
}
|
|
|
|
if ((rv = xbps_transaction_pkg_deps(xhp, pkgs, pkgd)) != 0) {
|
|
|
|
xbps_object_release(edges);
|
2019-07-02 18:52:58 +05:30
|
|
|
return rv;
|
2020-02-21 13:38:22 +05:30
|
|
|
}
|
|
|
|
if (!xbps_array_add(pkgs, pkgd)) {
|
|
|
|
xbps_object_release(edges);
|
2019-08-05 15:18:15 +05:30
|
|
|
return ENOMEM;
|
2020-02-21 13:38:22 +05:30
|
|
|
}
|
2019-07-02 18:52:58 +05:30
|
|
|
}
|
2019-08-05 15:18:15 +05:30
|
|
|
/* ... remove dup edges at head */
|
|
|
|
for (i = 0; i < xbps_array_count(edges); i++) {
|
|
|
|
const char *pkgver = NULL;
|
|
|
|
xbps_array_get_cstring_nocopy(edges, i, &pkgver);
|
|
|
|
xbps_remove_pkg_from_array_by_pkgver(pkgs, pkgver);
|
|
|
|
}
|
|
|
|
xbps_object_release(edges);
|
|
|
|
|
2020-02-18 13:37:03 +05:30
|
|
|
/*
|
|
|
|
* Do not perform any checks if XBPS_FLAG_DOWNLOAD_ONLY
|
|
|
|
* is set. We just need to download the archives (dependencies).
|
|
|
|
*/
|
|
|
|
if (xhp->flags & XBPS_FLAG_DOWNLOAD_ONLY)
|
|
|
|
goto out;
|
|
|
|
|
2019-12-28 01:41:29 +05:30
|
|
|
/*
|
|
|
|
* If all pkgs in transaction are on hold, no need to check
|
|
|
|
* for anything else.
|
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dbg_printf(xhp, "%s: checking on hold pkgs\n", __func__);
|
2019-12-28 01:41:29 +05:30
|
|
|
for (i = 0; i < cnt; i++) {
|
|
|
|
tpkgd = xbps_array_get(pkgs, i);
|
2020-02-21 13:38:22 +05:30
|
|
|
if (xbps_transaction_pkg_type(tpkgd) != XBPS_TRANS_HOLD) {
|
2019-12-28 01:41:29 +05:30
|
|
|
all_on_hold = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (all_on_hold)
|
|
|
|
goto out;
|
|
|
|
|
2015-10-14 15:16:56 +05:30
|
|
|
/*
|
2019-08-05 15:18:15 +05:30
|
|
|
* Check for packages to be replaced.
|
2015-10-14 15:16:56 +05:30
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dbg_printf(xhp, "%s: checking replaces\n", __func__);
|
|
|
|
if (!xbps_transaction_check_replaces(xhp, pkgs)) {
|
2019-08-05 15:18:15 +05:30
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
2020-02-21 13:38:22 +05:30
|
|
|
return EINVAL;
|
2015-10-14 15:16:56 +05:30
|
|
|
}
|
2011-01-24 21:25:58 +05:30
|
|
|
/*
|
2020-02-21 13:38:22 +05:30
|
|
|
* Check if there are missing revdeps.
|
2011-01-24 21:25:58 +05:30
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dbg_printf(xhp, "%s: checking revdeps\n", __func__);
|
|
|
|
if (!xbps_transaction_check_revdeps(xhp, pkgs)) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
if (xbps_dictionary_get(xhp->transd, "missing_deps")) {
|
2015-02-03 14:50:13 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_FORCE_REMOVE_REVDEPS) {
|
|
|
|
xbps_dbg_printf(xhp, "[trans] continuing with broken reverse dependencies!");
|
|
|
|
} else {
|
|
|
|
return ENODEV;
|
|
|
|
}
|
|
|
|
}
|
2012-06-11 19:44:03 +05:30
|
|
|
/*
|
2020-02-21 13:38:22 +05:30
|
|
|
* Check for package conflicts.
|
2012-06-11 19:44:03 +05:30
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dbg_printf(xhp, "%s: checking conflicts\n", __func__);
|
|
|
|
if (!xbps_transaction_check_conflicts(xhp, pkgs)) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
if (xbps_dictionary_get(xhp->transd, "conflicts")) {
|
2012-06-11 19:44:03 +05:30
|
|
|
return EAGAIN;
|
2020-02-21 13:38:22 +05:30
|
|
|
}
|
2014-11-13 16:09:20 +05:30
|
|
|
/*
|
|
|
|
* Check for unresolved shared libraries.
|
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dbg_printf(xhp, "%s: checking shlibs\n", __func__);
|
|
|
|
if (!xbps_transaction_check_shlibs(xhp, pkgs)) {
|
|
|
|
xbps_object_release(xhp->transd);
|
|
|
|
xhp->transd = NULL;
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
if (xbps_dictionary_get(xhp->transd, "missing_shlibs")) {
|
2015-02-03 14:50:13 +05:30
|
|
|
if (xhp->flags & XBPS_FLAG_FORCE_REMOVE_REVDEPS) {
|
|
|
|
xbps_dbg_printf(xhp, "[trans] continuing with unresolved shared libraries!");
|
|
|
|
} else {
|
|
|
|
return ENOEXEC;
|
|
|
|
}
|
|
|
|
}
|
2019-12-28 01:41:29 +05:30
|
|
|
out:
|
2011-01-24 21:25:58 +05:30
|
|
|
/*
|
2011-07-24 21:13:17 +05:30
|
|
|
* Add transaction stats for total download/installed size,
|
|
|
|
* number of packages to be installed, updated, configured
|
|
|
|
* and removed to the transaction dictionary.
|
2011-01-24 21:25:58 +05:30
|
|
|
*/
|
2020-02-21 13:38:22 +05:30
|
|
|
xbps_dbg_printf(xhp, "%s: computing stats\n", __func__);
|
2012-06-14 11:52:11 +05:30
|
|
|
if ((rv = compute_transaction_stats(xhp)) != 0) {
|
2012-01-22 14:30:46 +05:30
|
|
|
return rv;
|
2011-01-24 21:25:58 +05:30
|
|
|
}
|
|
|
|
/*
|
2020-02-21 13:38:22 +05:30
|
|
|
* Make transaction dictionary immutable.
|
2011-01-24 21:25:58 +05:30
|
|
|
*/
|
2013-06-20 13:56:12 +05:30
|
|
|
xbps_dictionary_make_immutable(xhp->transd);
|
2011-01-24 21:25:58 +05:30
|
|
|
|
2012-01-22 14:30:46 +05:30
|
|
|
return 0;
|
2011-01-24 21:25:58 +05:30
|
|
|
}
|