libxbps: multiple random changes for overall performance increase.

This commit is contained in:
Juan RP 2012-06-04 23:22:33 +02:00
parent fa73de309f
commit 9441f9f14b
7 changed files with 65 additions and 204 deletions

View File

@ -56,7 +56,7 @@
*/ */
#define XBPS_PKGINDEX_VERSION "1.5" #define XBPS_PKGINDEX_VERSION "1.5"
#define XBPS_API_VERSION "20120604" #define XBPS_API_VERSION "20120604-1"
#define XBPS_VERSION "0.16" #define XBPS_VERSION "0.16"
/** /**

View File

@ -134,16 +134,7 @@ int HIDDEN xbps_requiredby_pkg_remove(const char *);
prop_dictionary_t HIDDEN prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_array_by_name(prop_array_t, const char *); xbps_find_virtualpkg_conf_in_array_by_name(prop_array_t, const char *);
prop_dictionary_t HIDDEN prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_dict_by_name(prop_dictionary_t, xbps_find_virtualpkg_conf_in_array_by_pattern(prop_array_t, const char *);
const char *,
const char *);
prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_array_by_pattern(prop_array_t,
const char *);
prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_dict_by_pattern(prop_dictionary_t,
const char *,
const char *);
/** /**
* @private * @private

View File

@ -61,9 +61,10 @@ find_pkg_in_array(prop_array_t array,
while ((obj = prop_object_iterator_next(iter))) { while ((obj = prop_object_iterator_next(iter))) {
chkarch = prop_dictionary_get_cstring_nocopy(obj, chkarch = prop_dictionary_get_cstring_nocopy(obj,
"architecture", &arch); "architecture", &arch);
if (virtual) {
if (chkarch && !xbps_pkg_arch_match(arch, targetarch)) if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue; continue;
if (virtual) {
/* /*
* Check if package pattern matches * Check if package pattern matches
* any virtual package version in dictionary. * any virtual package version in dictionary.
@ -72,8 +73,6 @@ find_pkg_in_array(prop_array_t array,
break; break;
} else if (bypattern) { } else if (bypattern) {
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
/* /*
* Check if package pattern matches the * Check if package pattern matches the
* pkgver string object in dictionary. * pkgver string object in dictionary.
@ -84,8 +83,6 @@ find_pkg_in_array(prop_array_t array,
if (xbps_pkgpattern_match(pkgver, str)) if (xbps_pkgpattern_match(pkgver, str))
break; break;
} else { } else {
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
if (!prop_dictionary_get_cstring_nocopy(obj, if (!prop_dictionary_get_cstring_nocopy(obj,
"pkgname", &dpkgn)) "pkgname", &dpkgn))
continue; continue;
@ -239,25 +236,6 @@ xbps_find_virtualpkg_conf_in_array_by_pattern(prop_array_t array, const char *p)
return find_virtualpkg_user_in_array(array, p, true); return find_virtualpkg_user_in_array(array, p, true);
} }
static prop_dictionary_t
find_virtualpkg_user_in_dict(prop_dictionary_t d,
const char *key,
const char *str,
bool bypattern)
{
prop_array_t array;
assert(prop_object_type(d) == PROP_TYPE_DICTIONARY);
assert(str != NULL);
assert(key != NULL);
array = prop_dictionary_get(d, key);
if (prop_object_type(array) != PROP_TYPE_ARRAY)
return NULL;
return find_virtualpkg_user_in_array(array, str, bypattern);
}
static prop_dictionary_t static prop_dictionary_t
find_pkg_in_dict(prop_dictionary_t d, find_pkg_in_dict(prop_dictionary_t d,
const char *key, const char *key,
@ -328,22 +306,6 @@ xbps_find_virtualpkg_in_dict_by_pattern(prop_dictionary_t d,
return find_pkg_in_dict(d, key, pattern, true, true); return find_pkg_in_dict(d, key, pattern, true, true);
} }
prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_dict_by_name(prop_dictionary_t d,
const char *key,
const char *name)
{
return find_virtualpkg_user_in_dict(d, key, name, false);
}
prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_dict_by_pattern(prop_dictionary_t d,
const char *key,
const char *pattern)
{
return find_virtualpkg_user_in_dict(d, key, pattern, true);
}
static prop_dictionary_t static prop_dictionary_t
find_pkgd_installed(const char *str, bool bypattern, bool virtual) find_pkgd_installed(const char *str, bool bypattern, bool virtual)
{ {

View File

@ -31,25 +31,13 @@
#include "xbps_api_impl.h" #include "xbps_api_impl.h"
static int static int
store_dependency(prop_dictionary_t transd, store_dependency(prop_array_t transd_unsorted,
prop_dictionary_t repo_pkgd, prop_dictionary_t repo_pkgd,
pkg_state_t repo_pkg_state, pkg_state_t repo_pkg_state,
size_t *depth) size_t *depth)
{ {
const struct xbps_handle *xhp = xbps_handle_get(); const struct xbps_handle *xhp = xbps_handle_get();
prop_array_t array; int rv;
const char *pkgname, *pkgver, *repoloc;
size_t x;
int rv = 0;
assert(prop_object_type(transd) == PROP_TYPE_DICTIONARY);
assert(prop_object_type(repo_pkgd) == PROP_TYPE_DICTIONARY);
/*
* Get some info about dependencies and current repository.
*/
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);
/* /*
* Overwrite package state in dictionary with same state than the * Overwrite package state in dictionary with same state than the
* package currently uses, otherwise not-installed. * package currently uses, otherwise not-installed.
@ -60,27 +48,28 @@ store_dependency(prop_dictionary_t transd,
* Add required objects into package dep's dictionary. * Add required objects into package dep's dictionary.
*/ */
if (!prop_dictionary_set_bool(repo_pkgd, "automatic-install", true)) if (!prop_dictionary_set_bool(repo_pkgd, "automatic-install", true))
return errno; return EINVAL;
/* /*
* Add the dictionary into the array. * Add the dictionary into the array.
*/ */
array = prop_dictionary_get(transd, "unsorted_deps"); if (!prop_array_add(transd_unsorted, repo_pkgd))
if (array == NULL)
return errno;
if (!prop_array_add(array, repo_pkgd))
return EINVAL; return EINVAL;
if (xhp->flags & XBPS_FLAG_DEBUG) { if (xhp->flags & XBPS_FLAG_DEBUG) {
size_t x;
const char *repo, *pkgver;
prop_dictionary_get_cstring_nocopy(repo_pkgd,
"repository", &repo);
prop_dictionary_get_cstring_nocopy(repo_pkgd,
"pkgver", &pkgver);
xbps_dbg_printf(" "); xbps_dbg_printf(" ");
for (x = 0; x < *depth; x++) for (x = 0; x < *depth; x++)
xbps_dbg_printf_append(" "); xbps_dbg_printf_append(" ");
xbps_dbg_printf_append("%s: added into " xbps_dbg_printf_append("%s: added into "
"the transaction (%s).\n", pkgver, repoloc); "the transaction (%s).\n", pkgver, repo);
} }
return 0; return 0;
} }
@ -182,32 +171,22 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
prop_dictionary_t curpkgd, tmpd; prop_dictionary_t curpkgd, tmpd;
prop_array_t curpkgrdeps, unsorted; prop_array_t curpkgrdeps, unsorted;
prop_object_t obj; prop_object_t obj;
prop_object_iterator_t iter;
pkg_state_t state; pkg_state_t state;
size_t x; size_t i, x;
const char *reqpkg, *pkgver_q, *reason = NULL; const char *reqpkg, *pkgver_q, *reason = NULL;
char *pkgname; char *pkgname;
int rv = 0; int rv = 0;
assert(prop_object_type(transd) == PROP_TYPE_DICTIONARY);
assert(prop_object_type(trans_mdeps) == PROP_TYPE_ARRAY);
assert(prop_object_type(pkg_rdeps_array) == PROP_TYPE_ARRAY);
if (*depth >= MAX_DEPTH) if (*depth >= MAX_DEPTH)
return ELOOP; return ELOOP;
iter = prop_array_iterator(pkg_rdeps_array);
if (iter == NULL)
return ENOMEM;
/* /*
* Iterate over the list of required run dependencies for * Iterate over the list of required run dependencies for
* current package. * current package.
*/ */
while ((obj = prop_object_iterator_next(iter)) != NULL) { for (i = 0; i < prop_array_count(pkg_rdeps_array); i++) {
curpkgd = NULL; obj = prop_array_get(pkg_rdeps_array, i);
reqpkg = prop_string_cstring_nocopy(obj); if ((reqpkg = prop_string_cstring_nocopy(obj)) == NULL) {
if (reqpkg == NULL) {
rv = EINVAL; rv = EINVAL;
break; break;
} }
@ -222,8 +201,7 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
* Pass 1: check if required dependency is already installed * Pass 1: check if required dependency is already installed
* and its version is fully matched. * and its version is fully matched.
*/ */
pkgname = xbps_pkgpattern_name(reqpkg); if ((pkgname = xbps_pkgpattern_name(reqpkg)) == NULL) {
if (pkgname == NULL) {
rv = EINVAL; rv = EINVAL;
xbps_dbg_printf("failed to get " xbps_dbg_printf("failed to get "
"pkgname from `%s'!", reqpkg); "pkgname from `%s'!", reqpkg);
@ -248,8 +226,8 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
*/ */
tmpd = xbps_find_virtualpkg_dict_installed(pkgname, false); tmpd = xbps_find_virtualpkg_dict_installed(pkgname, false);
} }
if (tmpd == NULL) {
free(pkgname); free(pkgname);
if (tmpd == NULL) {
if (errno && errno != ENOENT) { if (errno && errno != ENOENT) {
/* error */ /* error */
rv = errno; rv = errno;
@ -273,11 +251,9 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
/* Check its state */ /* Check its state */
rv = xbps_pkg_state_dictionary(tmpd, &state); rv = xbps_pkg_state_dictionary(tmpd, &state);
if (rv != 0) { if (rv != 0) {
free(pkgname);
prop_object_release(tmpd); prop_object_release(tmpd);
break; break;
} }
free(pkgname);
if (xbps_match_virtual_pkg_in_dict(tmpd,reqpkg,true)) { if (xbps_match_virtual_pkg_in_dict(tmpd,reqpkg,true)) {
/* /*
* Check if required dependency is a virtual * Check if required dependency is a virtual
@ -330,13 +306,12 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
} }
} }
/* /*
* Pass 2: * Pass 2: check if required dependency has been already
* check if required dependency was already added * added in the transaction dictionary.
* in the transaction.
*/ */
unsorted = prop_dictionary_get(transd, "unsorted_deps"); unsorted = prop_dictionary_get(transd, "unsorted_deps");
if (((curpkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(unsorted, reqpkg)) == NULL) && if (((curpkgd = xbps_find_pkg_in_array_by_pattern(unsorted, reqpkg, NULL)) == NULL) &&
((curpkgd = xbps_find_pkg_in_array_by_pattern(unsorted, reqpkg, NULL)) == NULL) && ((curpkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(unsorted, reqpkg)) == NULL) &&
((curpkgd = xbps_find_virtualpkg_in_array_by_pattern(unsorted, reqpkg)) == NULL)) { ((curpkgd = xbps_find_virtualpkg_in_array_by_pattern(unsorted, reqpkg)) == NULL)) {
/* error matching required pkgdep */ /* error matching required pkgdep */
if (errno && errno != ENOENT) { if (errno && errno != ENOENT) {
@ -384,12 +359,11 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
continue; continue;
} }
} }
prop_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason);
prop_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q);
/* /*
* Package is on repo, add it into the transaction dictionary. * Package is on repo, add it into the transaction dictionary.
*/ */
rv = store_dependency(transd, curpkgd, state, depth); prop_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason);
rv = store_dependency(unsorted, curpkgd, state, depth);
if (rv != 0) { if (rv != 0) {
xbps_dbg_printf("store_dependency failed for " xbps_dbg_printf("store_dependency failed for "
"`%s': %s\n", reqpkg, strerror(rv)); "`%s': %s\n", reqpkg, strerror(rv));
@ -425,7 +399,6 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
break; break;
} }
} }
prop_object_iterator_release(iter);
(*depth)--; (*depth)--;
return rv; return rv;
@ -438,10 +411,6 @@ xbps_repository_find_pkg_deps(struct xbps_handle *xhp,
prop_array_t mdeps, pkg_rdeps; prop_array_t mdeps, pkg_rdeps;
const char *pkgver; const char *pkgver;
size_t depth = 0; size_t depth = 0;
int rv = 0;
assert(prop_object_type(xhp->transd) == PROP_TYPE_DICTIONARY);
assert(prop_object_type(repo_pkgd) == PROP_TYPE_DICTIONARY);
pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends"); pkg_rdeps = prop_dictionary_get(repo_pkgd, "run_depends");
if (prop_object_type(pkg_rdeps) != PROP_TYPE_ARRAY) if (prop_object_type(pkg_rdeps) != PROP_TYPE_ARRAY)
@ -454,11 +423,5 @@ xbps_repository_find_pkg_deps(struct xbps_handle *xhp,
* This will find direct and indirect deps, if any of them is not * This will find direct and indirect deps, if any of them is not
* there it will be added into the missing_deps array. * there it will be added into the missing_deps array.
*/ */
if ((rv = find_repo_deps(xhp->transd, mdeps, pkg_rdeps, return find_repo_deps(xhp->transd, mdeps, pkg_rdeps, pkgver, &depth);
pkgver, &depth)) != 0) {
xbps_dbg_printf("Error '%s' while checking rundeps!\n",
strerror(rv));
}
return rv;
} }

View File

@ -49,8 +49,6 @@ repo_find_virtualpkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
{ {
struct repo_pool_fpkg *rpf = arg; struct repo_pool_fpkg *rpf = arg;
assert(rpi != NULL);
if (rpf->bypattern) { if (rpf->bypattern) {
rpf->pkgd = rpf->pkgd =
xbps_find_virtualpkg_in_array_by_pattern(rpi->repo, xbps_find_virtualpkg_in_array_by_pattern(rpi->repo,
@ -74,8 +72,6 @@ repo_find_virtualpkg_conf_cb(struct xbps_rpool_index *rpi, void *arg, bool *done
{ {
struct repo_pool_fpkg *rpf = arg; struct repo_pool_fpkg *rpf = arg;
assert(rpi != NULL);
if (rpf->bypattern) { if (rpf->bypattern) {
rpf->pkgd = rpf->pkgd =
xbps_find_virtualpkg_conf_in_array_by_pattern(rpi->repo, xbps_find_virtualpkg_conf_in_array_by_pattern(rpi->repo,
@ -99,8 +95,6 @@ repo_find_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
{ {
struct repo_pool_fpkg *rpf = arg; struct repo_pool_fpkg *rpf = arg;
assert(rpi != NULL);
if (rpf->exact) { if (rpf->exact) {
/* exact match by pkgver */ /* exact match by pkgver */
rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(rpi->repo, rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(rpi->repo,
@ -134,8 +128,6 @@ repo_find_best_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
const char *repopkgver; const char *repopkgver;
prop_dictionary_t pkgd; prop_dictionary_t pkgd;
assert(rpi != NULL);
(void)done; (void)done;
if (rpf->bypattern) { if (rpf->bypattern) {
@ -185,129 +177,92 @@ typedef enum {
REAL_PKG REAL_PKG
} pkg_repo_type_t; } pkg_repo_type_t;
static struct repo_pool_fpkg * static prop_dictionary_t
repo_find_pkg(const char *pkg, bool bypattern, pkg_repo_type_t type) repo_find_pkg(const char *pkg, bool bypattern, pkg_repo_type_t type)
{ {
struct repo_pool_fpkg *rpf; struct repo_pool_fpkg rpf;
int rv = 0; int rv = 0;
assert(pkg != NULL); rpf.pattern = pkg;
rpf.bypattern = bypattern;
rpf = malloc(sizeof(*rpf)); rpf.exact = false;
if (rpf == NULL) rpf.pkgd = NULL;
return NULL; rpf.bestpkgver = NULL;
rpf->pattern = pkg;
rpf->bypattern = bypattern;
rpf->exact = false;
rpf->pkgd = NULL;
rpf->bestpkgver = NULL;
switch (type) { switch (type) {
case EXACT_PKG: case EXACT_PKG:
/* /*
* Find exact pkg version. * Find exact pkg version.
*/ */
rpf->exact = true; rpf.exact = true;
rv = xbps_rpool_foreach(repo_find_pkg_cb, rpf); rv = xbps_rpool_foreach(repo_find_pkg_cb, &rpf);
break; break;
case BEST_PKG: case BEST_PKG:
/* /*
* Find best pkg version. * Find best pkg version.
*/ */
rv = xbps_rpool_foreach(repo_find_best_pkg_cb, rpf); rv = xbps_rpool_foreach(repo_find_best_pkg_cb, &rpf);
break; break;
case VIRTUAL_PKG: case VIRTUAL_PKG:
/* /*
* Find virtual pkg. * Find virtual pkg.
*/ */
rv = xbps_rpool_foreach(repo_find_virtualpkg_cb, rpf); rv = xbps_rpool_foreach(repo_find_virtualpkg_cb, &rpf);
break; break;
case VIRTUAL_CONF_PKG: case VIRTUAL_CONF_PKG:
/* /*
* Find virtual pkg as specified in configuration file. * Find virtual pkg as specified in configuration file.
*/ */
rv = xbps_rpool_foreach(repo_find_virtualpkg_conf_cb, rpf); rv = xbps_rpool_foreach(repo_find_virtualpkg_conf_cb, &rpf);
break; break;
case REAL_PKG: case REAL_PKG:
/* /*
* Find real pkg. * Find real pkg.
*/ */
rv = xbps_rpool_foreach(repo_find_pkg_cb, rpf); rv = xbps_rpool_foreach(repo_find_pkg_cb, &rpf);
break; break;
} }
if (rv != 0) if (rv != 0) {
errno = rv; errno = rv;
return NULL;
}
return rpf; return prop_dictionary_copy(rpf.pkgd);
} }
prop_dictionary_t prop_dictionary_t
xbps_rpool_find_virtualpkg(const char *pkg, bool bypattern) xbps_rpool_find_virtualpkg(const char *pkg, bool bypattern)
{ {
struct repo_pool_fpkg *rpf;
prop_dictionary_t pkgd = NULL;
assert(pkg != NULL); assert(pkg != NULL);
rpf = repo_find_pkg(pkg, bypattern, VIRTUAL_PKG); return repo_find_pkg(pkg, bypattern, VIRTUAL_PKG);
if (prop_object_type(rpf->pkgd) == PROP_TYPE_DICTIONARY)
pkgd = prop_dictionary_copy(rpf->pkgd);
free(rpf);
return pkgd;
} }
prop_dictionary_t prop_dictionary_t
xbps_rpool_find_virtualpkg_conf(const char *pkg, bool bypattern) xbps_rpool_find_virtualpkg_conf(const char *pkg, bool bypattern)
{ {
struct repo_pool_fpkg *rpf;
prop_dictionary_t pkgd = NULL;
assert(pkg != NULL); assert(pkg != NULL);
rpf = repo_find_pkg(pkg, bypattern, VIRTUAL_CONF_PKG); return repo_find_pkg(pkg, bypattern, VIRTUAL_CONF_PKG);
if (prop_object_type(rpf->pkgd) == PROP_TYPE_DICTIONARY)
pkgd = prop_dictionary_copy(rpf->pkgd);
free(rpf);
return pkgd;
} }
prop_dictionary_t prop_dictionary_t
xbps_rpool_find_pkg(const char *pkg, bool bypattern, bool best) xbps_rpool_find_pkg(const char *pkg, bool bypattern, bool best)
{ {
struct repo_pool_fpkg *rpf;
prop_dictionary_t pkgd = NULL;
assert(pkg != NULL); assert(pkg != NULL);
if (best) if (best)
rpf = repo_find_pkg(pkg, bypattern, BEST_PKG); return repo_find_pkg(pkg, bypattern, BEST_PKG);
else
rpf = repo_find_pkg(pkg, bypattern, REAL_PKG);
if (prop_object_type(rpf->pkgd) == PROP_TYPE_DICTIONARY) return repo_find_pkg(pkg, bypattern, REAL_PKG);
pkgd = prop_dictionary_copy(rpf->pkgd);
free(rpf);
return pkgd;
} }
prop_dictionary_t prop_dictionary_t
xbps_rpool_find_pkg_exact(const char *pkgver) xbps_rpool_find_pkg_exact(const char *pkgver)
{ {
struct repo_pool_fpkg *rpf;
prop_dictionary_t pkgd = NULL;
assert(pkgver != NULL); assert(pkgver != NULL);
rpf = repo_find_pkg(pkgver, false, EXACT_PKG); return repo_find_pkg(pkgver, false, EXACT_PKG);
if (prop_object_type(rpf->pkgd) == PROP_TYPE_DICTIONARY)
pkgd = prop_dictionary_copy(rpf->pkgd);
free(rpf);
return pkgd;
} }
prop_dictionary_t prop_dictionary_t

View File

@ -79,20 +79,16 @@ compute_transaction_stats(prop_dictionary_t transd)
prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract); prop_dictionary_get_cstring_nocopy(obj, "transaction", &tract);
prop_dictionary_get_cstring_nocopy(obj, "repository", &repo); prop_dictionary_get_cstring_nocopy(obj, "repository", &repo);
if (strcmp(tract, "install") == 0) if (strcmp(tract, "configure") == 0) {
inst_pkgcnt++;
else if (strcmp(tract, "update") == 0)
up_pkgcnt++;
else if (strcmp(tract, "configure") == 0)
cf_pkgcnt++; cf_pkgcnt++;
else if (strcmp(tract, "remove") == 0)
rm_pkgcnt++;
/*
* Only process pkgs to be installed or updated.
*/
if (strcmp(tract, "configure") == 0)
continue; continue;
} else if (strcmp(tract, "install") == 0) {
inst_pkgcnt++;
} else if (strcmp(tract, "update") == 0) {
up_pkgcnt++;
} else if (strcmp(tract, "remove") == 0) {
rm_pkgcnt++;
}
tsize = 0; tsize = 0;
/* /*
@ -199,24 +195,20 @@ xbps_transaction_init(struct xbps_handle *xhp)
if (xhp->transd != NULL) if (xhp->transd != NULL)
return 0; return 0;
xhp->transd = prop_dictionary_create(); if ((xhp->transd = prop_dictionary_create()) == NULL)
if (xhp->transd == NULL)
return ENOMEM; return ENOMEM;
unsorted = prop_array_create(); if ((unsorted = prop_array_create()) == NULL) {
if (unsorted == NULL) {
prop_object_release(xhp->transd); prop_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return ENOMEM; return ENOMEM;
} }
if (!xbps_add_obj_to_dict(xhp->transd, unsorted, "unsorted_deps")) { if (!xbps_add_obj_to_dict(xhp->transd, unsorted, "unsorted_deps")) {
prop_object_release(xhp->transd); prop_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return EINVAL; return EINVAL;
} }
mdeps = prop_array_create(); if ((mdeps = prop_array_create()) == NULL) {
if (mdeps == NULL) {
prop_object_release(xhp->transd); prop_object_release(xhp->transd);
xhp->transd = NULL; xhp->transd = NULL;
return ENOMEM; return ENOMEM;

View File

@ -110,7 +110,7 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
prop_dictionary_get_cstring_nocopy(pkg_repod, "version", &repover); prop_dictionary_get_cstring_nocopy(pkg_repod, "version", &repover);
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc); prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
if (best && (action == TRANS_UPDATE)) { if (action == TRANS_UPDATE) {
/* /*
* Compare installed version vs best pkg available in repos. * Compare installed version vs best pkg available in repos.
*/ */
@ -130,13 +130,11 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool best, bool exact,
*/ */
if ((rv = xbps_transaction_init(xhp)) != 0) if ((rv = xbps_transaction_init(xhp)) != 0)
goto out; goto out;
/* /*
* Prepare required package dependencies and add them into the * Prepare required package dependencies and add them into the
* "unsorted" array in transaction dictionary. * "unsorted" array in transaction dictionary.
*/ */
if ((xbps_pkg_has_rundeps(pkg_repod)) && if ((rv = xbps_repository_find_pkg_deps(xhp, pkg_repod)) != 0)
((rv = xbps_repository_find_pkg_deps(xhp, pkg_repod)) != 0))
goto out; goto out;
/* /*
* Set package state in dictionary with same state than the * Set package state in dictionary with same state than the