libxbps: performance improvements by caching the most accessed paths.
1- We can cache the result of the first xbps_pkgdb_init() when it fails and avoid the malloc/free/access from it. 2- We cache the uname(2) result into a private var in xbps_handle and use it in xbps_pkg_arch_match(). This improves performance by ~5% approx and it's close as it was before introducing the repository index format 1.5.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/utsname.h>
|
||||
|
||||
#include "xbps_api_impl.h"
|
||||
|
||||
@@ -114,6 +115,7 @@ xbps_init(struct xbps_handle *xhp)
|
||||
CFG_FUNC(__UNCONST("include"), &cfg_include),
|
||||
CFG_END()
|
||||
};
|
||||
struct utsname un;
|
||||
int rv, cc, cch;
|
||||
bool syslog_enabled = false;
|
||||
|
||||
@@ -170,6 +172,10 @@ xbps_init(struct xbps_handle *xhp)
|
||||
return ENOMEM;
|
||||
xhp->metadir = xhp->metadir_priv;
|
||||
|
||||
uname(&un);
|
||||
xhp->un_machine = strdup(un.machine);
|
||||
assert(xhp->un_machine);
|
||||
|
||||
if (xhp->cfg == NULL) {
|
||||
xhp->flags |= XBPS_FLAG_SYSLOG;
|
||||
xhp->fetch_timeout = XBPS_FETCH_TIMEOUT;
|
||||
@@ -199,6 +205,7 @@ xbps_init(struct xbps_handle *xhp)
|
||||
xbps_dbg_printf(xhp, "Syslog=%u\n", syslog_enabled);
|
||||
xbps_dbg_printf(xhp, "TransactionFrequencyFlush=%u\n",
|
||||
xhp->transaction_frequency_flush);
|
||||
xbps_dbg_printf(xhp, "Architecture: %s\n", xhp->un_machine);
|
||||
|
||||
xbps_initialized = true;
|
||||
|
||||
@@ -217,10 +224,10 @@ xbps_end(struct xbps_handle *xhp)
|
||||
|
||||
if (xhp->cfg != NULL)
|
||||
cfg_free(xhp->cfg);
|
||||
if (xhp->cachedir_priv != NULL)
|
||||
free(xhp->cachedir_priv);
|
||||
if (xhp->metadir_priv != NULL)
|
||||
free(xhp->metadir_priv);
|
||||
|
||||
free(xhp->cachedir_priv);
|
||||
free(xhp->metadir_priv);
|
||||
free(xhp->un_machine);
|
||||
|
||||
xhp = NULL;
|
||||
xbps_initialized = false;
|
||||
|
||||
@@ -66,7 +66,7 @@ xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
|
||||
/*
|
||||
* Check if current pkg conflicts with any pkg in transaction.
|
||||
*/
|
||||
pkgd = xbps_find_pkg_in_dict_by_pattern(xhp->transd,
|
||||
pkgd = xbps_find_pkg_in_dict_by_pattern(xhp, xhp->transd,
|
||||
"unsorted_deps", cfpkg);
|
||||
if (pkgd != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
|
||||
@@ -137,7 +137,7 @@ find_orphan_pkg(struct xbps_handle *xhp,
|
||||
prop_object_iterator_release(iter);
|
||||
return EINVAL;
|
||||
}
|
||||
if (xbps_find_pkg_in_array_by_pattern(od->array, pkgdep, NULL))
|
||||
if (xbps_find_pkg_in_array_by_pattern(xhp, od->array, pkgdep, NULL))
|
||||
ndep++;
|
||||
if (od->orphans_user == NULL)
|
||||
continue;
|
||||
|
||||
@@ -58,7 +58,7 @@ add_pkg_into_reqby(struct xbps_handle *xhp,
|
||||
return ENOMEM;
|
||||
|
||||
if (xbps_match_pkgname_in_array(reqby, pkgname)) {
|
||||
if (!xbps_remove_pkgname_from_array(reqby, pkgname)) {
|
||||
if (!xbps_remove_pkgname_from_array(xhp, reqby, pkgname)) {
|
||||
xbps_dbg_printf(xhp, "%s: failed to remove %s reqby entry: "
|
||||
"%s\n", __func__, pkgname, strerror(errno));
|
||||
free(pkgname);
|
||||
@@ -113,7 +113,7 @@ remove_pkg_from_reqby(struct xbps_handle *xhp,
|
||||
return 0;
|
||||
|
||||
if (xbps_match_pkgname_in_array(reqby, pkgname)) {
|
||||
if (!xbps_remove_pkgname_from_array(reqby, pkgname))
|
||||
if (!xbps_remove_pkgname_from_array(xhp, reqby, pkgname))
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -161,10 +161,10 @@ xbps_requiredby_pkg_add(struct xbps_handle *xhp, prop_dictionary_t pkgd)
|
||||
if (pkgd_pkgdb == NULL) {
|
||||
pkgd_pkgdb =
|
||||
xbps_find_virtualpkg_in_array_by_pattern(
|
||||
xhp->pkgdb, str);
|
||||
xhp, xhp->pkgdb, str);
|
||||
if (pkgd_pkgdb == NULL) {
|
||||
pkgd_pkgdb = xbps_find_pkg_in_array_by_pattern(
|
||||
xhp->pkgdb, str, NULL);
|
||||
xhp, xhp->pkgdb, str, NULL);
|
||||
if (pkgd_pkgdb == NULL) {
|
||||
rv = ENOENT;
|
||||
xbps_dbg_printf(xhp,
|
||||
|
||||
47
lib/pkgdb.c
47
lib/pkgdb.c
@@ -80,31 +80,16 @@ int
|
||||
xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
|
||||
{
|
||||
char *plist;
|
||||
static int cached_rv;
|
||||
int rv = 0;
|
||||
|
||||
plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB);
|
||||
if (plist == NULL)
|
||||
return ENOMEM;
|
||||
if (cached_rv && !flush)
|
||||
return cached_rv;
|
||||
|
||||
if (xhp->pkgdb != NULL && flush) {
|
||||
/* Create metadir if doesn't exist */
|
||||
if (access(xhp->metadir, X_OK) == -1) {
|
||||
if (errno == ENOENT) {
|
||||
if (xbps_mkpath(xhp->metadir, 0755) != 0) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"[pkgdb] failed to "
|
||||
"create metadir %s: %s\n",
|
||||
xhp->metadir,
|
||||
strerror(errno));
|
||||
rv = errno;
|
||||
free(plist);
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
free(plist);
|
||||
return errno;
|
||||
}
|
||||
}
|
||||
plist = xbps_xasprintf("%s/%s", xhp->metadir, XBPS_PKGDB);
|
||||
assert(plist);
|
||||
|
||||
if (xhp->pkgdb && flush) {
|
||||
/* flush dictionary to storage */
|
||||
if (!prop_array_externalize_to_zfile(xhp->pkgdb, plist)) {
|
||||
free(plist);
|
||||
@@ -112,11 +97,11 @@ xbps_pkgdb_update(struct xbps_handle *xhp, bool flush)
|
||||
}
|
||||
prop_object_release(xhp->pkgdb);
|
||||
xhp->pkgdb = NULL;
|
||||
cached_rv = 0;
|
||||
}
|
||||
/* update copy in memory */
|
||||
xhp->pkgdb = prop_array_internalize_from_zfile(plist);
|
||||
if (xhp->pkgdb == NULL)
|
||||
rv = errno;
|
||||
if ((xhp->pkgdb = prop_array_internalize_from_zfile(plist)) == NULL)
|
||||
cached_rv = rv = errno;
|
||||
|
||||
free(plist);
|
||||
|
||||
@@ -180,9 +165,9 @@ xbps_pkgdb_get_pkgd(struct xbps_handle *xhp, const char *pkg, bool bypattern)
|
||||
return NULL;
|
||||
|
||||
if (bypattern)
|
||||
pkgd = xbps_find_pkg_in_array_by_pattern(xhp->pkgdb, pkg, NULL);
|
||||
pkgd = xbps_find_pkg_in_array_by_pattern(xhp, xhp->pkgdb, pkg, NULL);
|
||||
else
|
||||
pkgd = xbps_find_pkg_in_array_by_name(xhp->pkgdb, pkg, NULL);
|
||||
pkgd = xbps_find_pkg_in_array_by_name(xhp, xhp->pkgdb, pkg, NULL);
|
||||
|
||||
if (pkgd != NULL)
|
||||
return prop_dictionary_copy(pkgd);
|
||||
@@ -198,7 +183,7 @@ xbps_pkgdb_get_pkgd_by_pkgver(struct xbps_handle *xhp, const char *pkgver)
|
||||
if (xbps_pkgdb_init(xhp) != 0)
|
||||
return NULL;
|
||||
|
||||
pkgd = xbps_find_pkg_in_array_by_pkgver(xhp->pkgdb, pkgver, NULL);
|
||||
pkgd = xbps_find_pkg_in_array_by_pkgver(xhp, xhp->pkgdb, pkgver, NULL);
|
||||
if (pkgd != NULL)
|
||||
return prop_dictionary_copy(pkgd);
|
||||
|
||||
@@ -217,9 +202,11 @@ xbps_pkgdb_remove_pkgd(struct xbps_handle *xhp,
|
||||
return false;
|
||||
|
||||
if (bypattern)
|
||||
rv = xbps_remove_pkg_from_array_by_pattern(xhp->pkgdb, pkg, NULL);
|
||||
rv = xbps_remove_pkg_from_array_by_pattern(xhp,
|
||||
xhp->pkgdb, pkg, NULL);
|
||||
else
|
||||
rv = xbps_remove_pkg_from_array_by_name(xhp->pkgdb, pkg, NULL);
|
||||
rv = xbps_remove_pkg_from_array_by_name(xhp,
|
||||
xhp->pkgdb, pkg, NULL);
|
||||
|
||||
if (!flush || !rv)
|
||||
return rv;
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
* all library functions.
|
||||
*/
|
||||
static prop_dictionary_t
|
||||
find_pkg_in_array(prop_array_t array,
|
||||
find_pkg_in_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str,
|
||||
bool bypattern,
|
||||
bool virtual,
|
||||
@@ -61,7 +62,7 @@ find_pkg_in_array(prop_array_t array,
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch, targetarch))
|
||||
continue;
|
||||
|
||||
if (virtual) {
|
||||
@@ -99,21 +100,27 @@ find_pkg_in_array(prop_array_t array,
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_array_by_name(prop_array_t array, const char *name,
|
||||
xbps_find_pkg_in_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name,
|
||||
const char *targetarch)
|
||||
{
|
||||
return find_pkg_in_array(array, name, false, false, targetarch);
|
||||
return find_pkg_in_array(xhp, array, name, false, false, targetarch);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_array_by_pattern(prop_array_t array, const char *pattern,
|
||||
xbps_find_pkg_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pattern,
|
||||
const char *targetarch)
|
||||
{
|
||||
return find_pkg_in_array(array, pattern, true, false, targetarch);
|
||||
return find_pkg_in_array(xhp, array, pattern, true, false, targetarch);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_array_by_pkgver(prop_array_t array, const char *pkgver,
|
||||
xbps_find_pkg_in_array_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pkgver,
|
||||
const char *targetarch)
|
||||
{
|
||||
prop_object_iterator_t iter;
|
||||
@@ -134,7 +141,7 @@ xbps_find_pkg_in_array_by_pkgver(prop_array_t array, const char *pkgver,
|
||||
if (!prop_dictionary_get_cstring_nocopy(obj,
|
||||
"pkgver", &rpkgver))
|
||||
continue;
|
||||
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch, targetarch))
|
||||
continue;
|
||||
if (strcmp(pkgver, rpkgver) == 0) {
|
||||
found = true;
|
||||
@@ -149,15 +156,19 @@ xbps_find_pkg_in_array_by_pkgver(prop_array_t array, const char *pkgver,
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_array_by_name(prop_array_t array, const char *name)
|
||||
xbps_find_virtualpkg_in_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name)
|
||||
{
|
||||
return find_pkg_in_array(array, name, false, true, NULL);
|
||||
return find_pkg_in_array(xhp, array, name, false, true, NULL);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_array_by_pattern(prop_array_t array, const char *pattern)
|
||||
xbps_find_virtualpkg_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pattern)
|
||||
{
|
||||
return find_pkg_in_array(array, pattern, true, true, NULL);
|
||||
return find_pkg_in_array(xhp, array, pattern, true, true, NULL);
|
||||
}
|
||||
|
||||
static const char *
|
||||
@@ -230,7 +241,7 @@ find_virtualpkg_user_in_array(struct xbps_handle *xhp,
|
||||
if (vpkgname == NULL)
|
||||
return NULL;
|
||||
|
||||
return find_pkg_in_array(array, vpkgname, false, false, NULL);
|
||||
return find_pkg_in_array(xhp, array, vpkgname, false, false, NULL);
|
||||
}
|
||||
|
||||
prop_dictionary_t HIDDEN
|
||||
@@ -250,7 +261,8 @@ xbps_find_virtualpkg_conf_in_array_by_pattern(struct xbps_handle *xhp,
|
||||
}
|
||||
|
||||
static prop_dictionary_t
|
||||
find_pkg_in_dict(prop_dictionary_t d,
|
||||
find_pkg_in_dict(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *str,
|
||||
bool bypattern,
|
||||
@@ -266,27 +278,30 @@ find_pkg_in_dict(prop_dictionary_t d,
|
||||
if (prop_object_type(array) != PROP_TYPE_ARRAY)
|
||||
return NULL;
|
||||
|
||||
return find_pkg_in_array(array, str, bypattern, virtual, NULL);
|
||||
return find_pkg_in_array(xhp, array, str, bypattern, virtual, NULL);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict_by_name(prop_dictionary_t d,
|
||||
xbps_find_pkg_in_dict_by_name(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pkgname)
|
||||
{
|
||||
return find_pkg_in_dict(d, key, pkgname, false, false);
|
||||
return find_pkg_in_dict(xhp, d, key, pkgname, false, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict_by_pattern(prop_dictionary_t d,
|
||||
xbps_find_pkg_in_dict_by_pattern(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pattern)
|
||||
{
|
||||
return find_pkg_in_dict(d, key, pattern, true, false);
|
||||
return find_pkg_in_dict(xhp, d, key, pattern, true, false);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_pkg_in_dict_by_pkgver(prop_dictionary_t d,
|
||||
xbps_find_pkg_in_dict_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pkgver)
|
||||
{
|
||||
@@ -300,23 +315,25 @@ xbps_find_pkg_in_dict_by_pkgver(prop_dictionary_t d,
|
||||
if (array == NULL)
|
||||
return NULL;
|
||||
|
||||
return xbps_find_pkg_in_array_by_pkgver(array, pkgver, NULL);
|
||||
return xbps_find_pkg_in_array_by_pkgver(xhp, array, pkgver, NULL);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_dict_by_name(prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *name)
|
||||
xbps_find_virtualpkg_in_dict_by_name(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *name)
|
||||
{
|
||||
return find_pkg_in_dict(d, key, name, false, true);
|
||||
return find_pkg_in_dict(xhp, d, key, name, false, true);
|
||||
}
|
||||
|
||||
prop_dictionary_t
|
||||
xbps_find_virtualpkg_in_dict_by_pattern(prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pattern)
|
||||
xbps_find_virtualpkg_in_dict_by_pattern(struct xbps_handle *xhp,
|
||||
prop_dictionary_t d,
|
||||
const char *key,
|
||||
const char *pattern)
|
||||
{
|
||||
return find_pkg_in_dict(d, key, pattern, true, true);
|
||||
return find_pkg_in_dict(xhp, d, key, pattern, true, true);
|
||||
}
|
||||
|
||||
static prop_dictionary_t
|
||||
@@ -342,15 +359,15 @@ find_pkgd_installed(struct xbps_handle *xhp,
|
||||
|
||||
/* try normal pkg */
|
||||
if (virtual == false) {
|
||||
pkgd =
|
||||
find_pkg_in_array(xhp->pkgdb, str, bypattern, false, NULL);
|
||||
pkgd = find_pkg_in_array(xhp, xhp->pkgdb, str,
|
||||
bypattern, false, NULL);
|
||||
} else {
|
||||
/* virtual pkg set by user in conf */
|
||||
pkgd = find_virtualpkg_user_in_array(xhp, xhp->pkgdb,
|
||||
str, bypattern);
|
||||
if (pkgd == NULL) {
|
||||
/* any virtual pkg in array matching pattern */
|
||||
pkgd = find_pkg_in_array(xhp->pkgdb,
|
||||
pkgd = find_pkg_in_array(xhp, xhp->pkgdb,
|
||||
str, bypattern, true, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,11 @@
|
||||
* all library functions.
|
||||
*/
|
||||
static bool
|
||||
remove_obj_from_array(prop_array_t array, const char *str, int mode,
|
||||
const char *targetarch)
|
||||
remove_obj_from_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str,
|
||||
int mode,
|
||||
const char *targetarch)
|
||||
{
|
||||
prop_object_iterator_t iter;
|
||||
prop_object_t obj;
|
||||
@@ -79,7 +82,8 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode,
|
||||
/* match by pkgname, obj is a dictionary */
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(arch, targetarch)) {
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch,
|
||||
targetarch)) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
@@ -92,7 +96,8 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode,
|
||||
} else if (mode == 3) {
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(arch, targetarch)) {
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch,
|
||||
targetarch)) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
@@ -106,7 +111,8 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode,
|
||||
} else if (mode == 4) {
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj,
|
||||
"architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(arch, targetarch)) {
|
||||
if (chkarch && !xbps_pkg_arch_match(xhp, arch,
|
||||
targetarch)) {
|
||||
idx++;
|
||||
continue;
|
||||
}
|
||||
@@ -132,34 +138,44 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode,
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_string_from_array(prop_array_t array, const char *str)
|
||||
xbps_remove_string_from_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *str)
|
||||
{
|
||||
return remove_obj_from_array(array, str, 0, NULL);
|
||||
return remove_obj_from_array(xhp, array, str, 0, NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_pkgname_from_array(prop_array_t array, const char *name)
|
||||
xbps_remove_pkgname_from_array(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name)
|
||||
{
|
||||
return remove_obj_from_array(array, name, 1, NULL);
|
||||
return remove_obj_from_array(xhp, array, name, 1, NULL);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_pkg_from_array_by_name(prop_array_t array, const char *name,
|
||||
xbps_remove_pkg_from_array_by_name(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *name,
|
||||
const char *targetarch)
|
||||
{
|
||||
return remove_obj_from_array(array, name, 2, targetarch);
|
||||
return remove_obj_from_array(xhp, array, name, 2, targetarch);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_pkg_from_array_by_pkgver(prop_array_t array, const char *pkgver,
|
||||
xbps_remove_pkg_from_array_by_pkgver(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *pkgver,
|
||||
const char *targetarch)
|
||||
{
|
||||
return remove_obj_from_array(array, pkgver, 3, targetarch);
|
||||
return remove_obj_from_array(xhp, array, pkgver, 3, targetarch);
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_remove_pkg_from_array_by_pattern(prop_array_t array, const char *p,
|
||||
xbps_remove_pkg_from_array_by_pattern(struct xbps_handle *xhp,
|
||||
prop_array_t array,
|
||||
const char *p,
|
||||
const char *targetarch)
|
||||
{
|
||||
return remove_obj_from_array(array, p, 4, targetarch);
|
||||
return remove_obj_from_array(xhp, array, p, 4, targetarch);
|
||||
}
|
||||
|
||||
@@ -310,9 +310,9 @@ find_repo_deps(struct xbps_handle *xhp,
|
||||
* added in the transaction dictionary.
|
||||
*/
|
||||
unsorted = prop_dictionary_get(xhp->transd, "unsorted_deps");
|
||||
if (((curpkgd = xbps_find_pkg_in_array_by_pattern(unsorted, reqpkg, NULL)) == NULL) &&
|
||||
if (((curpkgd = xbps_find_pkg_in_array_by_pattern(xhp, unsorted, reqpkg, NULL)) == NULL) &&
|
||||
((curpkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(xhp, unsorted, reqpkg)) == NULL) &&
|
||||
((curpkgd = xbps_find_virtualpkg_in_array_by_pattern(unsorted, reqpkg)) == NULL)) {
|
||||
((curpkgd = xbps_find_virtualpkg_in_array_by_pattern(xhp, unsorted, reqpkg)) == NULL)) {
|
||||
/* error matching required pkgdep */
|
||||
if (errno && errno != ENOENT) {
|
||||
rv = errno;
|
||||
|
||||
@@ -56,11 +56,11 @@ repo_find_virtualpkg_cb(struct xbps_handle *xhp,
|
||||
|
||||
if (rpf->bypattern) {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_in_array_by_pattern(rpi->repo,
|
||||
xbps_find_virtualpkg_in_array_by_pattern(xhp, rpi->repo,
|
||||
rpf->pattern);
|
||||
} else {
|
||||
rpf->pkgd =
|
||||
xbps_find_virtualpkg_in_array_by_name(rpi->repo,
|
||||
xbps_find_virtualpkg_in_array_by_name(xhp, rpi->repo,
|
||||
rpf->pattern);
|
||||
}
|
||||
if (rpf->pkgd) {
|
||||
@@ -110,15 +110,15 @@ repo_find_pkg_cb(struct xbps_handle *xhp,
|
||||
|
||||
if (rpf->exact) {
|
||||
/* exact match by pkgver */
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(rpi->repo,
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
} else if (rpf->bypattern) {
|
||||
/* match by pkgpattern in pkgver*/
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_pattern(rpi->repo,
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_pattern(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
} else {
|
||||
/* match by pkgname */
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_name(rpi->repo,
|
||||
rpf->pkgd = xbps_find_pkg_in_array_by_name(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
}
|
||||
if (rpf->pkgd) {
|
||||
@@ -148,10 +148,10 @@ repo_find_best_pkg_cb(struct xbps_handle *xhp,
|
||||
(void)xhp;
|
||||
|
||||
if (rpf->bypattern) {
|
||||
pkgd = xbps_find_pkg_in_array_by_pattern(rpi->repo,
|
||||
pkgd = xbps_find_pkg_in_array_by_pattern(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
} else {
|
||||
pkgd = xbps_find_pkg_in_array_by_name(rpi->repo,
|
||||
pkgd = xbps_find_pkg_in_array_by_name(xhp, rpi->repo,
|
||||
rpf->pattern, NULL);
|
||||
}
|
||||
if (pkgd == NULL) {
|
||||
|
||||
@@ -108,7 +108,7 @@ xbps_transaction_package_replace(struct xbps_handle *xhp)
|
||||
* transaction and it's going to be updated.
|
||||
*/
|
||||
reppkgd = xbps_find_pkg_in_array_by_name(
|
||||
transd_unsorted, curpkgname, NULL);
|
||||
xhp, transd_unsorted, curpkgname, NULL);
|
||||
if (reppkgd) {
|
||||
xbps_dbg_printf(xhp,
|
||||
"found replaced pkg "
|
||||
|
||||
@@ -145,7 +145,7 @@ pkgdep_alloc(prop_dictionary_t d, const char *name, const char *trans)
|
||||
}
|
||||
|
||||
static void
|
||||
pkgdep_end(prop_array_t sorted)
|
||||
pkgdep_end(struct xbps_handle *xhp, prop_array_t sorted)
|
||||
{
|
||||
prop_dictionary_t d;
|
||||
struct pkgdep *pd;
|
||||
@@ -155,12 +155,12 @@ pkgdep_end(prop_array_t sorted)
|
||||
TAILQ_REMOVE(&pkgdep_list, pd, pkgdep_entries);
|
||||
if (sorted != NULL && pd->d != NULL) {
|
||||
/* do not add duplicates due to vpkgs */
|
||||
d = xbps_find_pkg_in_array_by_name(sorted,
|
||||
d = xbps_find_pkg_in_array_by_name(xhp, sorted,
|
||||
pd->name, NULL);
|
||||
if (d == NULL) {
|
||||
/* find a virtual pkg otherwise */
|
||||
d = xbps_find_virtualpkg_in_array_by_name(
|
||||
sorted, pd->name);
|
||||
xhp, sorted, pd->name);
|
||||
if (d == NULL) {
|
||||
prop_array_add(sorted, pd->d);
|
||||
pkgdep_release(pd);
|
||||
@@ -232,13 +232,13 @@ again:
|
||||
continue;
|
||||
}
|
||||
/* Find pkg by name */
|
||||
curpkgd = xbps_find_pkg_in_dict_by_name(xhp->transd,
|
||||
curpkgd = xbps_find_pkg_in_dict_by_name(xhp, xhp->transd,
|
||||
"unsorted_deps", pkgnamedep);
|
||||
if (curpkgd == NULL) {
|
||||
/* find virtualpkg by name if no match */
|
||||
curpkgd =
|
||||
xbps_find_virtualpkg_in_dict_by_name(xhp->transd,
|
||||
"unsorted_deps", pkgnamedep);
|
||||
xbps_find_virtualpkg_in_dict_by_name(xhp,
|
||||
xhp->transd, "unsorted_deps", pkgnamedep);
|
||||
}
|
||||
if (curpkgd == NULL) {
|
||||
free(pkgnamedep);
|
||||
@@ -343,7 +343,7 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
*/
|
||||
pd = pkgdep_alloc(obj, pkgname, tract);
|
||||
if (pd == NULL) {
|
||||
pkgdep_end(NULL);
|
||||
pkgdep_end(xhp, NULL);
|
||||
rv = ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
@@ -371,7 +371,7 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
* Sort package run-time dependencies for this package.
|
||||
*/
|
||||
if ((rv = sort_pkg_rundeps(xhp, pd, rundeps)) != 0) {
|
||||
pkgdep_end(NULL);
|
||||
pkgdep_end(xhp, NULL);
|
||||
goto out;
|
||||
}
|
||||
cnt++;
|
||||
@@ -381,7 +381,7 @@ xbps_transaction_sort_pkg_deps(struct xbps_handle *xhp)
|
||||
* from the sorted list into the "packages" array, and at
|
||||
* the same time freeing memory used for temporary sorting.
|
||||
*/
|
||||
pkgdep_end(sorted);
|
||||
pkgdep_end(xhp, sorted);
|
||||
/*
|
||||
* Sanity check that the array contains the same number of
|
||||
* objects than the total number of required dependencies.
|
||||
|
||||
@@ -281,13 +281,12 @@ xbps_pkg_has_rundeps(prop_dictionary_t pkgd)
|
||||
}
|
||||
|
||||
bool
|
||||
xbps_pkg_arch_match(const char *orig, const char *target)
|
||||
xbps_pkg_arch_match(struct xbps_handle *xhp,
|
||||
const char *orig,
|
||||
const char *target)
|
||||
{
|
||||
struct utsname un;
|
||||
|
||||
if (target == NULL) {
|
||||
uname(&un);
|
||||
if (strcmp(orig, "noarch") && strcmp(orig, un.machine))
|
||||
if (strcmp(orig, "noarch") && strcmp(orig, xhp->un_machine))
|
||||
return false;
|
||||
} else {
|
||||
if (strcmp(orig, "noarch") && strcmp(orig, target))
|
||||
|
||||
Reference in New Issue
Block a user