Welcome "repository index format 1.5". See NEWS for information.

This commit is contained in:
Juan RP
2012-05-31 16:29:56 +02:00
parent e155d9601a
commit 7289547432
23 changed files with 384 additions and 392 deletions

View File

@@ -133,7 +133,7 @@ find_orphan_pkg(prop_object_t obj, void *arg, bool *loop_done)
prop_object_iterator_release(iter);
return EINVAL;
}
if (xbps_find_pkg_in_array_by_pattern(od->array, pkgdep))
if (xbps_find_pkg_in_array_by_pattern(od->array, pkgdep, NULL))
ndep++;
if (od->orphans_user == NULL)
continue;

View File

@@ -157,7 +157,7 @@ xbps_requiredby_pkg_add(struct xbps_handle *xhp, prop_dictionary_t pkgd)
xhp->pkgdb, str);
if (pkgd_pkgdb == NULL) {
pkgd_pkgdb = xbps_find_pkg_in_array_by_pattern(
xhp->pkgdb, str);
xhp->pkgdb, str, NULL);
if (pkgd_pkgdb == NULL) {
rv = ENOENT;
xbps_dbg_printf("%s: couldnt find `%s' "

View File

@@ -179,9 +179,9 @@ xbps_pkgdb_get_pkgd(const char *pkg, bool bypattern)
return NULL;
if (bypattern)
pkgd = xbps_find_pkg_in_array_by_pattern(xhp->pkgdb, pkg);
pkgd = xbps_find_pkg_in_array_by_pattern(xhp->pkgdb, pkg, NULL);
else
pkgd = xbps_find_pkg_in_array_by_name(xhp->pkgdb, pkg);
pkgd = xbps_find_pkg_in_array_by_name(xhp->pkgdb, pkg, NULL);
if (pkgd != NULL)
return prop_dictionary_copy(pkgd);
@@ -198,7 +198,7 @@ xbps_pkgdb_get_pkgd_by_pkgver(const char *pkgver)
if (xbps_pkgdb_init(xhp) != 0)
return NULL;
pkgd = xbps_find_pkg_in_array_by_pkgver(xhp->pkgdb, pkgver);
pkgd = xbps_find_pkg_in_array_by_pkgver(xhp->pkgdb, pkgver, NULL);
if (pkgd != NULL)
return prop_dictionary_copy(pkgd);
@@ -215,9 +215,9 @@ xbps_pkgdb_remove_pkgd(const char *pkg, bool bypattern, bool flush)
return false;
if (bypattern)
rv = xbps_remove_pkg_from_array_by_pattern(xhp->pkgdb, pkg);
rv = xbps_remove_pkg_from_array_by_pattern(xhp->pkgdb, pkg, NULL);
else
rv = xbps_remove_pkg_from_array_by_name(xhp->pkgdb, pkg);
rv = xbps_remove_pkg_from_array_by_name(xhp->pkgdb, pkg, NULL);
if (!flush || !rv)
return rv;

View File

@@ -39,16 +39,17 @@
* These functions manipulate plist files and objects shared by almost
* all library functions.
*/
static prop_dictionary_t
find_pkg_in_array(prop_array_t array,
const char *str,
bool bypattern,
bool virtual)
bool virtual,
const char *targetarch)
{
prop_object_iterator_t iter;
prop_object_t obj = NULL;
const char *pkgver, *dpkgn;
const char *pkgver, *dpkgn, *arch;
bool chkarch;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(str != NULL);
@@ -58,14 +59,21 @@ find_pkg_in_array(prop_array_t array,
return NULL;
while ((obj = prop_object_iterator_next(iter))) {
chkarch = prop_dictionary_get_cstring_nocopy(obj,
"architecture", &arch);
if (virtual) {
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
/*
* Check if package pattern matches
* any virtual package version in dictionary.
*/
if (xbps_match_virtual_pkg_in_dict(obj, str, bypattern))
break;
} else if (bypattern) {
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
/*
* Check if package pattern matches the
* pkgver string object in dictionary.
@@ -76,6 +84,8 @@ find_pkg_in_array(prop_array_t array,
if (xbps_pkgpattern_match(pkgver, str))
break;
} else {
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
if (!prop_dictionary_get_cstring_nocopy(obj,
"pkgname", &dpkgn))
continue;
@@ -93,24 +103,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(prop_array_t array, const char *name,
const char *targetarch)
{
return find_pkg_in_array(array, name, false, false);
return find_pkg_in_array(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(prop_array_t array, const char *pattern,
const char *targetarch)
{
return find_pkg_in_array(array, pattern, true, false);
return find_pkg_in_array(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(prop_array_t array, const char *pkgver,
const char *targetarch)
{
prop_object_iterator_t iter;
prop_object_t obj = NULL;
const char *rpkgver;
bool found = false;
const char *rpkgver, *arch;
bool chkarch, found = false;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
assert(pkgver != NULL);
@@ -120,9 +133,13 @@ xbps_find_pkg_in_array_by_pkgver(prop_array_t array, const char *pkgver)
return NULL;
while ((obj = prop_object_iterator_next(iter))) {
chkarch = prop_dictionary_get_cstring_nocopy(obj,
"architecture", &arch);
if (!prop_dictionary_get_cstring_nocopy(obj,
"pkgver", &rpkgver))
continue;
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
if (strcmp(pkgver, rpkgver) == 0) {
found = true;
break;
@@ -138,13 +155,13 @@ 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)
{
return find_pkg_in_array(array, name, false, true);
return find_pkg_in_array(array, name, false, true, NULL);
}
prop_dictionary_t
xbps_find_virtualpkg_in_array_by_pattern(prop_array_t array, const char *pattern)
{
return find_pkg_in_array(array, pattern, true, true);
return find_pkg_in_array(array, pattern, true, true, NULL);
}
static const char *
@@ -207,7 +224,7 @@ find_virtualpkg_user_in_array(prop_array_t array,
if (vpkgname == NULL)
return NULL;
return find_pkg_in_array(array, vpkgname, false, false);
return find_pkg_in_array(array, vpkgname, false, false, NULL);
}
prop_dictionary_t HIDDEN
@@ -258,7 +275,7 @@ 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);
return find_pkg_in_array(array, str, bypattern, virtual, NULL);
}
prop_dictionary_t
@@ -292,7 +309,7 @@ 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);
return xbps_find_pkg_in_array_by_pkgver(array, pkgver, NULL);
}
prop_dictionary_t
@@ -396,7 +413,8 @@ find_pkgd_installed(const char *str, bool bypattern, bool virtual)
/* try normal pkg */
if (virtual == false) {
pkgd = find_pkg_in_array(xhp->pkgdb, str, bypattern, false);
pkgd =
find_pkg_in_array(xhp->pkgdb, str, bypattern, false, NULL);
} else {
/* virtual pkg set by user in conf */
pkgd = find_virtualpkg_user_in_array(xhp->pkgdb,
@@ -404,7 +422,7 @@ find_pkgd_installed(const char *str, bool bypattern, bool virtual)
if (pkgd == NULL) {
/* any virtual pkg in array matching pattern */
pkgd = find_pkg_in_array(xhp->pkgdb,
str, bypattern, true);
str, bypattern, true, NULL);
}
}
/* pkg not found */

View File

@@ -40,14 +40,15 @@
* all library functions.
*/
static bool
remove_obj_from_array(prop_array_t array, const char *str, int mode)
remove_obj_from_array(prop_array_t array, const char *str, int mode,
const char *targetarch)
{
prop_object_iterator_t iter;
prop_object_t obj;
const char *curname, *pkgdep;
const char *curname, *pkgdep, *arch;
char *curpkgname;
size_t idx = 0;
bool found = false;
bool found = false, chkarch;
assert(prop_object_type(array) == PROP_TYPE_ARRAY);
@@ -76,6 +77,10 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
free(curpkgname);
} else if (mode == 2) {
/* match by pkgname, obj is a dictionary */
chkarch = prop_dictionary_get_cstring_nocopy(obj,
"architecture", &arch);
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
prop_dictionary_get_cstring_nocopy(obj,
"pkgname", &curname);
if (strcmp(curname, str) == 0) {
@@ -83,6 +88,10 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
break;
}
} else if (mode == 3) {
chkarch = prop_dictionary_get_cstring_nocopy(obj,
"architecture", &arch);
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
/* match by pkgver, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj,
"pkgver", &curname);
@@ -91,6 +100,10 @@ remove_obj_from_array(prop_array_t array, const char *str, int mode)
break;
}
} else if (mode == 4) {
chkarch = prop_dictionary_get_cstring_nocopy(obj,
"architecture", &arch);
if (chkarch && !xbps_pkg_arch_match(arch, targetarch))
continue;
/* match by pattern, obj is a dictionary */
prop_dictionary_get_cstring_nocopy(obj,
"pkgver", &curname);
@@ -115,83 +128,32 @@ 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)
{
return remove_obj_from_array(array, str, 0);
return remove_obj_from_array(array, str, 0, NULL);
}
bool
xbps_remove_pkgname_from_array(prop_array_t array, const char *name)
{
return remove_obj_from_array(array, name, 1);
return remove_obj_from_array(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(prop_array_t array, const char *name,
const char *targetarch)
{
return remove_obj_from_array(array, name, 2);
return remove_obj_from_array(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(prop_array_t array, const char *pkgver,
const char *targetarch)
{
return remove_obj_from_array(array, pkgver, 3);
return remove_obj_from_array(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(prop_array_t array, const char *p,
const char *targetarch)
{
return remove_obj_from_array(array, p, 4);
}
bool
xbps_remove_pkg_from_dict_by_name(prop_dictionary_t dict,
const char *key,
const char *pkgname)
{
prop_array_t array;
assert(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
assert(key != NULL);
assert(pkgname != NULL);
array = prop_dictionary_get(dict, key);
if (array == NULL) {
errno = ENOENT;
return false;
}
if (!xbps_remove_pkg_from_array_by_name(array, pkgname))
return false;
return prop_dictionary_set(dict, key, array);
}
bool
xbps_remove_pkg_dict_from_plist_by_name(const char *pkg, const char *plist)
{
prop_dictionary_t pdict;
assert(pkg != NULL);
assert(plist != NULL);
pdict = prop_dictionary_internalize_from_zfile(plist);
if (pdict == NULL) {
xbps_dbg_printf("'%s' cannot read from file %s: %s\n",
pkg, plist, strerror(errno));
return false;
}
if (!xbps_remove_pkg_from_dict_by_name(pdict, "packages", pkg)) {
prop_object_release(pdict);
return false;
}
if (!prop_dictionary_externalize_to_zfile(pdict, plist)) {
xbps_dbg_printf("'%s' cannot write plist file %s: %s\n",
pkg, plist, strerror(errno));
prop_object_release(pdict);
return false;
}
prop_object_release(pdict);
return true;
return remove_obj_from_array(array, p, 4, targetarch);
}

View File

@@ -336,7 +336,7 @@ find_repo_deps(prop_dictionary_t transd, /* transaction dictionary */
*/
unsorted = prop_dictionary_get(transd, "unsorted_deps");
if (((curpkgd = xbps_find_virtualpkg_conf_in_array_by_pattern(unsorted, reqpkg)) == NULL) &&
((curpkgd = xbps_find_pkg_in_array_by_pattern(unsorted, reqpkg)) == NULL) &&
((curpkgd = xbps_find_pkg_in_array_by_pattern(unsorted, reqpkg, NULL)) == NULL) &&
((curpkgd = xbps_find_virtualpkg_in_array_by_pattern(unsorted, reqpkg)) == NULL)) {
/* error matching required pkgdep */
if (errno && errno != ENOENT) {

View File

@@ -39,29 +39,6 @@
* @defgroup repopool Repository pool functions
*/
/*
* Returns true if repository URI contains "noarch" or matching architecture
* in last component, false otherwise.
*/
static bool
check_repo_arch(const char *uri)
{
struct utsname un;
char *p, *b;
if ((p = strdup(uri)) == NULL)
return false;
uname(&un);
b = basename(p);
if ((strcmp(b, "noarch")) && (strcmp(b, un.machine))) {
free(p);
return false;
}
free(p);
return true;
}
int HIDDEN
xbps_rpool_init(struct xbps_handle *xhp)
{
@@ -84,15 +61,6 @@ xbps_rpool_init(struct xbps_handle *xhp)
for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
ntotal++;
/*
* Check if repository doesn't match our architecture.
*/
if (!check_repo_arch(repouri)) {
xbps_dbg_printf("[rpool] `%s' arch not matched, "
"ignoring.\n", repouri);
nmissing++;
continue;
}
/*
* If index file is not there, skip.
*/
@@ -188,14 +156,6 @@ xbps_rpool_sync(void)
for (i = 0; i < cfg_size(xhp->cfg, "repositories"); i++) {
repouri = cfg_getnstr(xhp->cfg, "repositories", i);
/*
* Check if repository doesn't match our architecture.
*/
if (!check_repo_arch(repouri)) {
xbps_dbg_printf("[rpool] `%s' arch not matched, "
"ignoring.\n", repouri);
continue;
}
/*
* Fetch repository plist index.
*/
@@ -222,12 +182,11 @@ xbps_rpool_sync(void)
}
int
xbps_rpool_foreach(int (*fn)(struct repository_pool_index *, void *, bool *),
void *arg)
xbps_rpool_foreach(int (*fn)(struct xbps_rpool_index *, void *, bool *), void *arg)
{
prop_dictionary_t d;
struct xbps_handle *xhp = xbps_handle_get();
struct repository_pool_index rpi;
struct xbps_rpool_index rpi;
size_t i;
int rv = 0;
bool done = false;
@@ -246,9 +205,9 @@ xbps_rpool_foreach(int (*fn)(struct repository_pool_index *, void *, bool *),
/* Iterate over repository pool */
for (i = 0; i < prop_array_count(xhp->repo_pool); i++) {
d = prop_array_get(xhp->repo_pool, i);
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi.rpi_uri);
rpi.rpi_repo = prop_dictionary_get(d, "index");
rpi.rpi_index = i;
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi.uri);
rpi.repo = prop_dictionary_get(d, "index");
rpi.index = i;
rv = (*fn)(&rpi, arg, &done);
if (rv != 0 || done)

View File

@@ -45,7 +45,7 @@ struct repo_pool_fpkg {
};
static int
repo_find_virtualpkg_cb(struct repository_pool_index *rpi, void *arg, bool *done)
repo_find_virtualpkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
{
struct repo_pool_fpkg *rpf = arg;
@@ -53,16 +53,15 @@ repo_find_virtualpkg_cb(struct repository_pool_index *rpi, void *arg, bool *done
if (rpf->bypattern) {
rpf->pkgd =
xbps_find_virtualpkg_in_array_by_pattern(rpi->rpi_repo,
xbps_find_virtualpkg_in_array_by_pattern(rpi->repo,
rpf->pattern);
} else {
rpf->pkgd =
xbps_find_virtualpkg_in_array_by_name(rpi->rpi_repo,
xbps_find_virtualpkg_in_array_by_name(rpi->repo,
rpf->pattern);
}
if (rpf->pkgd) {
prop_dictionary_set_cstring(rpf->pkgd, "repository",
rpi->rpi_uri);
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->uri);
*done = true;
return 0;
}
@@ -71,8 +70,7 @@ repo_find_virtualpkg_cb(struct repository_pool_index *rpi, void *arg, bool *done
}
static int
repo_find_virtualpkg_conf_cb(struct repository_pool_index *rpi,
void *arg, bool *done)
repo_find_virtualpkg_conf_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
{
struct repo_pool_fpkg *rpf = arg;
@@ -80,16 +78,15 @@ repo_find_virtualpkg_conf_cb(struct repository_pool_index *rpi,
if (rpf->bypattern) {
rpf->pkgd =
xbps_find_virtualpkg_conf_in_array_by_pattern(rpi->rpi_repo,
xbps_find_virtualpkg_conf_in_array_by_pattern(rpi->repo,
rpf->pattern);
} else {
rpf->pkgd =
xbps_find_virtualpkg_conf_in_array_by_name(rpi->rpi_repo,
xbps_find_virtualpkg_conf_in_array_by_name(rpi->repo,
rpf->pattern);
}
if (rpf->pkgd) {
prop_dictionary_set_cstring(rpf->pkgd, "repository",
rpi->rpi_uri);
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->uri);
*done = true;
return 0;
}
@@ -98,7 +95,7 @@ repo_find_virtualpkg_conf_cb(struct repository_pool_index *rpi,
}
static int
repo_find_pkg_cb(struct repository_pool_index *rpi, void *arg, bool *done)
repo_find_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
{
struct repo_pool_fpkg *rpf = arg;
@@ -106,24 +103,23 @@ repo_find_pkg_cb(struct repository_pool_index *rpi, void *arg, bool *done)
if (rpf->exact) {
/* exact match by pkgver */
rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(rpi->rpi_repo,
rpf->pattern);
rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(rpi->repo,
rpf->pattern, NULL);
} else if (rpf->bypattern) {
/* match by pkgpattern in pkgver*/
rpf->pkgd = xbps_find_pkg_in_array_by_pattern(rpi->rpi_repo,
rpf->pattern);
rpf->pkgd = xbps_find_pkg_in_array_by_pattern(rpi->repo,
rpf->pattern, NULL);
} else {
/* match by pkgname */
rpf->pkgd = xbps_find_pkg_in_array_by_name(rpi->rpi_repo,
rpf->pattern);
rpf->pkgd = xbps_find_pkg_in_array_by_name(rpi->repo,
rpf->pattern, NULL);
}
if (rpf->pkgd) {
/*
* Package dictionary found, add the "repository"
* object with the URI.
*/
prop_dictionary_set_cstring(rpf->pkgd, "repository",
rpi->rpi_uri);
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->uri);
*done = true;
return 0;
}
@@ -132,9 +128,7 @@ repo_find_pkg_cb(struct repository_pool_index *rpi, void *arg, bool *done)
}
static int
repo_find_best_pkg_cb(struct repository_pool_index *rpi,
void *arg,
bool *done)
repo_find_best_pkg_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
{
struct repo_pool_fpkg *rpf = arg;
const char *repopkgver;
@@ -145,27 +139,27 @@ repo_find_best_pkg_cb(struct repository_pool_index *rpi,
(void)done;
if (rpf->bypattern) {
pkgd = xbps_find_pkg_in_array_by_pattern(rpi->rpi_repo,
rpf->pattern);
pkgd = xbps_find_pkg_in_array_by_pattern(rpi->repo,
rpf->pattern, NULL);
} else {
pkgd = xbps_find_pkg_in_array_by_name(rpi->rpi_repo,
rpf->pattern);
pkgd = xbps_find_pkg_in_array_by_name(rpi->repo,
rpf->pattern, NULL);
}
if (pkgd == NULL) {
if (errno && errno != ENOENT)
return errno;
xbps_dbg_printf("[rpool] Package '%s' not found in repository "
"'%s'.\n", rpf->pattern, rpi->rpi_uri);
"'%s'.\n", rpf->pattern, rpi->uri);
return 0;
}
prop_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &repopkgver);
if (rpf->bestpkgver == NULL) {
xbps_dbg_printf("[rpool] Found best match '%s' (%s).\n",
repopkgver, rpi->rpi_uri);
repopkgver, rpi->uri);
rpf->pkgd = pkgd;
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->rpi_uri);
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->uri);
rpf->bestpkgver = repopkgver;
return 0;
}
@@ -175,9 +169,9 @@ repo_find_best_pkg_cb(struct repository_pool_index *rpi,
*/
if (xbps_cmpver(repopkgver, rpf->bestpkgver) == 1) {
xbps_dbg_printf("[rpool] Found best match '%s' (%s).\n",
repopkgver, rpi->rpi_uri);
repopkgver, rpi->uri);
rpf->pkgd = pkgd;
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->rpi_uri);
prop_dictionary_set_cstring(rpf->pkgd, "repository", rpi->uri);
rpf->bestpkgver = repopkgver;
}
return 0;

View File

@@ -108,7 +108,7 @@ xbps_transaction_package_replace(prop_dictionary_t transd)
* transaction and it's going to be updated.
*/
reppkgd = xbps_find_pkg_in_array_by_name(
transd_unsorted, curpkgname);
transd_unsorted, curpkgname, NULL);
if (reppkgd) {
xbps_dbg_printf("found replaced pkg "
"in transaction\n");

View File

@@ -159,7 +159,7 @@ pkgdep_end(prop_array_t sorted)
* same transaction reason into the sorted array.
*/
sorted_pkgd =
xbps_find_pkg_in_array_by_name(sorted, pd->name);
xbps_find_pkg_in_array_by_name(sorted, pd->name, NULL);
if (sorted_pkgd == NULL) {
/* find virtualpkg if no match */
sorted_pkgd =

View File

@@ -34,6 +34,7 @@
#include <string.h>
#include <errno.h>
#include <fnmatch.h>
#include <sys/utsname.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -246,7 +247,7 @@ char *
xbps_path_from_repository_uri(prop_dictionary_t pkg_repod, const char *repoloc)
{
struct xbps_handle *xhp;
const char *filen;
const char *filen, *arch;
char *lbinpkg = NULL;
assert(prop_object_type(pkg_repod) == PROP_TYPE_DICTIONARY);
@@ -268,10 +269,13 @@ xbps_path_from_repository_uri(prop_dictionary_t pkg_repod, const char *repoloc)
return lbinpkg;
free(lbinpkg);
if (!prop_dictionary_get_cstring_nocopy(pkg_repod,
"architecture", &arch))
return NULL;
/*
* Local and remote repositories use the same path.
*/
return xbps_xasprintf("%s/%s", repoloc, filen);
return xbps_xasprintf("%s/%s/%s", repoloc, arch, filen);
}
bool
@@ -289,6 +293,22 @@ xbps_pkg_has_rundeps(prop_dictionary_t pkgd)
return false;
}
bool
xbps_pkg_arch_match(const char *orig, const char *target)
{
struct utsname un;
if (target == NULL) {
uname(&un);
if (strcmp(orig, "noarch") && strcmp(orig, un.machine))
return false;
} else {
if (strcmp(orig, "noarch") && strcmp(orig, target))
return false;
}
return true;
}
char *
xbps_xasprintf(const char *fmt, ...)
{