Welcome "repository index format 1.5". See NEWS for information.
This commit is contained in:
parent
e155d9601a
commit
7289547432
23
NEWS
23
NEWS
@ -1,5 +1,28 @@
|
||||
xbps-0.16 (???):
|
||||
|
||||
* Repository index format 1.5. The files are now named properly:
|
||||
index.plist for XBPS_PKGINDEX and index-files.plist for XBPS_PKGINDEX_FILES.
|
||||
The difference in XBPS_PKGINDEX is that now a single plist file can store
|
||||
all metadata from any package with any architecture. XBPS_PKGINDEX_FILES
|
||||
has been modified to speed up 'xbps-repo find-files'. That means
|
||||
that in xbps.conf now you'd only have to use the directory where the
|
||||
index.plist is stored, i.e:
|
||||
|
||||
/path/to/my/repo <- 1st repository
|
||||
|-- i686
|
||||
|-- index-files.plist
|
||||
|-- index.plist
|
||||
|-- noarch
|
||||
|-- nonfree <- 2nd repository
|
||||
| |-- i686
|
||||
| |-- noarch
|
||||
| `-- x86_64
|
||||
`-- x86_64
|
||||
|
||||
Any other directory not named "noarch" or "$(uname -m)" must be specified
|
||||
as another different repository, such case is "nonfree" or any other with
|
||||
unmatched names.
|
||||
|
||||
* xbps-bin(8): new flag: -S which syncs rpool indexes before executing
|
||||
the "dist-upgrade", "install" or "update" targets.
|
||||
|
||||
|
@ -36,13 +36,18 @@ int
|
||||
list_pkgs_in_dict(prop_object_t obj, void *arg, bool *loop_done)
|
||||
{
|
||||
struct list_pkgver_cb *lpc = arg;
|
||||
const char *pkgver, *short_desc;
|
||||
const char *pkgver, *short_desc, *arch;
|
||||
char *tmp = NULL;
|
||||
pkg_state_t curstate;
|
||||
size_t i = 0;
|
||||
bool chkarch;
|
||||
|
||||
(void)loop_done;
|
||||
|
||||
chkarch = prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
if (chkarch && !xbps_pkg_arch_match(arch, NULL))
|
||||
return 0;
|
||||
|
||||
if (lpc->check_state) {
|
||||
if (xbps_pkg_state_dictionary(obj, &curstate))
|
||||
return EINVAL;
|
||||
|
@ -44,9 +44,9 @@ int repo_genindex_files(const char *);
|
||||
int repo_find_files_in_packages(int, char **);
|
||||
|
||||
/* From list.c */
|
||||
int repo_pkg_list_cb(struct repository_pool_index *, void *, bool *);
|
||||
int repo_list_uri_cb(struct repository_pool_index *, void *, bool *);
|
||||
int repo_search_pkgs_cb(struct repository_pool_index *, void *, bool *);
|
||||
int repo_pkg_list_cb(struct xbps_rpool_index *, void *, bool *);
|
||||
int repo_list_uri_cb(struct xbps_rpool_index *, void *, bool *);
|
||||
int repo_search_pkgs_cb(struct xbps_rpool_index *, void *, bool *);
|
||||
|
||||
/* From show.c */
|
||||
int show_pkg_info_from_repolist(const char *, const char *);
|
||||
|
@ -35,56 +35,38 @@
|
||||
struct ffdata {
|
||||
int npatterns;
|
||||
char **patterns;
|
||||
const char *repouri;
|
||||
};
|
||||
|
||||
static void
|
||||
match_files_by_pattern(prop_dictionary_t pkg_filesd, struct ffdata *ffd)
|
||||
{
|
||||
prop_object_iterator_t iter;
|
||||
prop_array_t array, allkeys;
|
||||
prop_object_t obj;
|
||||
prop_dictionary_keysym_t key;
|
||||
const char *keyname, *filestr, *typestr, *pkgver;
|
||||
prop_array_t array;
|
||||
const char *filestr, *pkgver, *arch;
|
||||
size_t i;
|
||||
int x;
|
||||
|
||||
allkeys = prop_dictionary_all_keys(pkg_filesd);
|
||||
for (i = 0; i < prop_array_count(allkeys); i++) {
|
||||
key = prop_array_get(allkeys, i);
|
||||
keyname = prop_dictionary_keysym_cstring_nocopy(key);
|
||||
array = prop_dictionary_get_keysym(pkg_filesd, key);
|
||||
if (prop_object_type(array) != PROP_TYPE_ARRAY)
|
||||
break;
|
||||
prop_dictionary_get_cstring_nocopy(pkg_filesd, "architecture", &arch);
|
||||
if (!xbps_pkg_arch_match(arch, NULL))
|
||||
return;
|
||||
|
||||
if (strcmp(keyname, "files") == 0)
|
||||
typestr = "regular file";
|
||||
else if (strcmp(keyname, "links") == 0)
|
||||
typestr = "link";
|
||||
else
|
||||
typestr = "configuration file";
|
||||
|
||||
iter = prop_array_iterator(array);
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "file", &filestr);
|
||||
for (x = 1; x < ffd->npatterns; x++) {
|
||||
if ((strcmp(filestr, ffd->patterns[x]) == 0) ||
|
||||
(strstr(filestr, ffd->patterns[x])) ||
|
||||
(xbps_pkgpattern_match(filestr,
|
||||
ffd->patterns[x]) == 1)) {
|
||||
prop_dictionary_get_cstring_nocopy(
|
||||
pkg_filesd, "pkgver", &pkgver);
|
||||
printf(" %s: %s (%s)\n",
|
||||
pkgver, filestr, typestr);
|
||||
}
|
||||
array = prop_dictionary_get(pkg_filesd, "files");
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
prop_array_get_cstring_nocopy(array, i, &filestr);
|
||||
for (x = 1; x < ffd->npatterns; x++) {
|
||||
if ((xbps_pkgpattern_match(filestr, ffd->patterns[x])) ||
|
||||
(strstr(filestr, ffd->patterns[x]))) {
|
||||
prop_dictionary_get_cstring_nocopy(pkg_filesd,
|
||||
"pkgver", &pkgver);
|
||||
printf("%s: %s (%s)\n",
|
||||
pkgver, filestr, ffd->repouri);
|
||||
}
|
||||
}
|
||||
prop_object_iterator_release(iter);
|
||||
}
|
||||
prop_object_release(allkeys);
|
||||
}
|
||||
|
||||
static int
|
||||
find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
find_files_in_package(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
{
|
||||
prop_array_t idxfiles;
|
||||
struct ffdata *ffd = arg;
|
||||
@ -93,17 +75,15 @@ find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
|
||||
(void)done;
|
||||
|
||||
printf("Looking in repository '%s', please wait...\n", rpi->rpi_uri);
|
||||
plist = xbps_pkg_index_files_plist(rpi->rpi_uri);
|
||||
if (plist == NULL)
|
||||
if ((plist = xbps_pkg_index_files_plist(rpi->uri)) == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
idxfiles = prop_array_internalize_from_zfile(plist);
|
||||
if (idxfiles == NULL) {
|
||||
if ((idxfiles = prop_array_internalize_from_zfile(plist)) == NULL) {
|
||||
free(plist);
|
||||
return errno;
|
||||
}
|
||||
free(plist);
|
||||
ffd->repouri = rpi->uri;
|
||||
|
||||
for (i = 0; i < prop_array_count(idxfiles); i++)
|
||||
match_files_by_pattern(prop_array_get(idxfiles, i), ffd);
|
||||
@ -115,16 +95,10 @@ find_files_in_package(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
int
|
||||
repo_find_files_in_packages(int npatterns, char **patterns)
|
||||
{
|
||||
struct ffdata *ffd;
|
||||
int rv;
|
||||
struct ffdata ffd;
|
||||
|
||||
ffd = malloc(sizeof(*ffd));
|
||||
if (ffd == NULL)
|
||||
return ENOMEM;
|
||||
ffd.npatterns = npatterns;
|
||||
ffd.patterns = patterns;
|
||||
|
||||
ffd->npatterns = npatterns;
|
||||
ffd->patterns = patterns;
|
||||
rv = xbps_rpool_foreach(find_files_in_package, ffd);
|
||||
free(ffd);
|
||||
return rv;
|
||||
return xbps_rpool_foreach(find_files_in_package, &ffd);
|
||||
}
|
||||
|
@ -46,12 +46,13 @@ rmobsoletes_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
{
|
||||
prop_string_t ps;
|
||||
struct index_files_data *ifd = arg;
|
||||
const char *pkgver;
|
||||
const char *pkgver, *arch;
|
||||
|
||||
(void)done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
if (xbps_find_pkg_in_array_by_pkgver(ifd->idx, pkgver)) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
if (xbps_find_pkg_in_array_by_pkgver(ifd->idx, pkgver, arch)) {
|
||||
/* pkg found, do nothing */
|
||||
return 0;
|
||||
}
|
||||
@ -68,17 +69,20 @@ rmobsoletes_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
static int
|
||||
genindex_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
{
|
||||
prop_object_t obj2, fileobj;
|
||||
prop_dictionary_t pkg_filesd, pkgd, regpkgd;
|
||||
prop_array_t array;
|
||||
prop_array_t array, files;
|
||||
struct index_files_data *ifd = arg;
|
||||
const char *binpkg, *pkgver, *rpkgver, *version;
|
||||
const char *binpkg, *pkgver, *rpkgver, *version, *arch;
|
||||
char *file, *pkgname, *pattern;
|
||||
bool found = false;
|
||||
size_t i;
|
||||
|
||||
(void)done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "filename", &binpkg);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
|
||||
if (ifd->new)
|
||||
goto start;
|
||||
@ -97,7 +101,7 @@ genindex_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
return ENOMEM;
|
||||
}
|
||||
free(pkgname);
|
||||
regpkgd = xbps_find_pkg_in_array_by_pattern(ifd->idxfiles, pattern);
|
||||
regpkgd = xbps_find_pkg_in_array_by_pattern(ifd->idxfiles, pattern, arch);
|
||||
if (regpkgd) {
|
||||
/*
|
||||
* pkg already registered, check if same version
|
||||
@ -111,12 +115,13 @@ genindex_files_cb(prop_object_t obj, void *arg, bool *done)
|
||||
return 0;
|
||||
}
|
||||
/* pkgver does not match, remove it from index-files */
|
||||
if (!xbps_remove_pkg_from_array_by_pkgver(ifd->idxfiles, rpkgver))
|
||||
if (!xbps_remove_pkg_from_array_by_pkgver(ifd->idxfiles,
|
||||
rpkgver, arch))
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
start:
|
||||
file = xbps_xasprintf("%s/%s", ifd->pkgdir, binpkg);
|
||||
file = xbps_xasprintf("%s/%s/%s", ifd->pkgdir, arch, binpkg);
|
||||
if (file == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
@ -129,39 +134,73 @@ start:
|
||||
free(file);
|
||||
|
||||
/* create pkg dictionary */
|
||||
pkgd = prop_dictionary_create();
|
||||
if (pkgd == NULL) {
|
||||
if ((pkgd = prop_dictionary_create()) == NULL) {
|
||||
prop_object_release(pkg_filesd);
|
||||
return ENOMEM;
|
||||
}
|
||||
/* add conf_files array in pkgd */
|
||||
/* add pkgver and architecture objects into pkg dictionary */
|
||||
if (!prop_dictionary_set_cstring(pkgd, "architecture", arch)) {
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(pkgd);
|
||||
return EINVAL;
|
||||
}
|
||||
if (!prop_dictionary_set_cstring(pkgd, "pkgver", pkgver)) {
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(pkgd);
|
||||
return EINVAL;
|
||||
}
|
||||
/* add files array obj into pkg dictionary */
|
||||
if ((files = prop_array_create()) == NULL) {
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(pkgd);
|
||||
return EINVAL;
|
||||
}
|
||||
if (!prop_dictionary_set(pkgd, "files", files)) {
|
||||
prop_object_release(pkg_filesd);
|
||||
prop_object_release(pkgd);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* add conf_files in pkgd */
|
||||
array = prop_dictionary_get(pkg_filesd, "conf_files");
|
||||
if (array != NULL && prop_array_count(array)) {
|
||||
found = true;
|
||||
if (!prop_dictionary_set(pkgd, "conf_files", array)) {
|
||||
prop_object_release(pkgd);
|
||||
prop_object_release(pkg_filesd);
|
||||
return EINVAL;
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
obj2 = prop_array_get(array, i);
|
||||
fileobj = prop_dictionary_get(obj2, "file");
|
||||
if (!prop_array_add(files, fileobj)) {
|
||||
prop_object_release(pkgd);
|
||||
prop_object_release(pkg_filesd);
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* add files array in pkgd */
|
||||
array = prop_dictionary_get(pkg_filesd, "files");
|
||||
if (array != NULL && prop_array_count(array)) {
|
||||
found = true;
|
||||
if (!prop_dictionary_set(pkgd, "files", array)) {
|
||||
prop_object_release(pkgd);
|
||||
prop_object_release(pkg_filesd);
|
||||
return EINVAL;
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
obj2 = prop_array_get(array, i);
|
||||
fileobj = prop_dictionary_get(obj2, "file");
|
||||
if (!prop_array_add(files, fileobj)) {
|
||||
prop_object_release(pkgd);
|
||||
prop_object_release(pkg_filesd);
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* add links array in pkgd */
|
||||
array = prop_dictionary_get(pkg_filesd, "links");
|
||||
if (array != NULL && prop_array_count(array)) {
|
||||
found = true;
|
||||
if (!prop_dictionary_set(pkgd, "links", array)) {
|
||||
prop_object_release(pkgd);
|
||||
prop_object_release(pkg_filesd);
|
||||
return EINVAL;
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
obj2 = prop_array_get(array, i);
|
||||
fileobj = prop_dictionary_get(obj2, "file");
|
||||
if (!prop_array_add(files, fileobj)) {
|
||||
prop_object_release(pkgd);
|
||||
prop_object_release(pkg_filesd);
|
||||
return EINVAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
prop_object_release(pkg_filesd);
|
||||
@ -169,12 +208,6 @@ start:
|
||||
prop_object_release(pkgd);
|
||||
return 0;
|
||||
}
|
||||
/* pkgver obj in pkgd */
|
||||
if (!prop_dictionary_set_cstring(pkgd, "pkgver", pkgver)) {
|
||||
prop_object_release(pkgd);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
/* add pkgd into provided array */
|
||||
if (!prop_array_add(ifd->idxfiles, pkgd)) {
|
||||
prop_object_release(pkgd);
|
||||
@ -233,7 +266,7 @@ repo_genindex_files(const char *pkgdir)
|
||||
ifd->new = true;
|
||||
}
|
||||
|
||||
/* iterate over index.plist packages array */
|
||||
/* iterate over index.plist array */
|
||||
rv = xbps_callback_array_iter(idx, genindex_files_cb, ifd);
|
||||
if (rv != 0)
|
||||
goto out;
|
||||
@ -248,7 +281,7 @@ repo_genindex_files(const char *pkgdir)
|
||||
prop_array_get_cstring_nocopy(ifd->obsoletes,
|
||||
i, &pkgver);
|
||||
if (!xbps_remove_pkg_from_array_by_pkgver(
|
||||
ifd->idxfiles, pkgver)) {
|
||||
ifd->idxfiles, pkgver, NULL)) {
|
||||
rv = EINVAL;
|
||||
goto out;
|
||||
}
|
||||
@ -258,7 +291,7 @@ repo_genindex_files(const char *pkgdir)
|
||||
if (!ifd->flush)
|
||||
goto out;
|
||||
|
||||
/* externalize index-files dictionary to the plist file */
|
||||
/* externalize index-files array */
|
||||
if (!prop_array_externalize_to_zfile(ifd->idxfiles, plist)) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
|
@ -30,12 +30,18 @@
|
||||
#include <errno.h>
|
||||
#include <dirent.h>
|
||||
#include <libgen.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <assert.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <xbps_api.h>
|
||||
#include "defs.h"
|
||||
|
||||
#ifndef __arraycount
|
||||
#define __arraycount(a) (sizeof(a) / sizeof(*a))
|
||||
#endif
|
||||
|
||||
static const char *archs[] = { "noarch", "i686", "x86_64" };
|
||||
|
||||
/*
|
||||
* Removes stalled pkg entries in repository's index.plist file, if any
|
||||
* binary package cannot be read (unavailable, not enough perms, etc).
|
||||
@ -45,7 +51,7 @@ remove_missing_binpkg_entries(const char *repodir)
|
||||
{
|
||||
prop_array_t array;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *filen, *pkgver;
|
||||
const char *filen, *pkgver, *arch;
|
||||
char *binpkg, *plist;
|
||||
size_t i;
|
||||
int rv = 0;
|
||||
@ -72,7 +78,8 @@ again:
|
||||
pkgd = prop_array_get(array, i);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "filename", &filen);
|
||||
binpkg = xbps_xasprintf("%s/%s", repodir, filen);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "architecture", &arch);
|
||||
binpkg = xbps_xasprintf("%s/%s/%s", repodir, arch, filen);
|
||||
if (binpkg == NULL) {
|
||||
errno = ENOMEM;
|
||||
rv = -1;
|
||||
@ -129,7 +136,7 @@ add_binpkg_to_index(prop_array_t idx,
|
||||
{
|
||||
prop_dictionary_t newpkgd, curpkgd;
|
||||
struct stat st;
|
||||
const char *pkgname, *version, *regver, *oldfilen, *oldpkgver;
|
||||
const char *pkgname, *version, *regver, *oldfilen, *oldpkgver, *arch;
|
||||
char *sha256, *filen, *tmpfilen, *oldfilepath, *buf;
|
||||
int rv = 0;
|
||||
|
||||
@ -151,20 +158,21 @@ add_binpkg_to_index(prop_array_t idx,
|
||||
}
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "version", &version);
|
||||
prop_dictionary_get_cstring_nocopy(newpkgd, "architecture", &arch);
|
||||
/*
|
||||
* Check if this package exists already in the index, but first
|
||||
* checking the version. If current package version is greater
|
||||
* than current registered package, update the index; otherwise
|
||||
* pass to the next one.
|
||||
*/
|
||||
curpkgd = xbps_find_pkg_in_array_by_name(idx, pkgname);
|
||||
curpkgd = xbps_find_pkg_in_array_by_name(idx, pkgname, arch);
|
||||
if (curpkgd == NULL) {
|
||||
if (errno && errno != ENOENT) {
|
||||
prop_object_release(newpkgd);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
} else if (curpkgd) {
|
||||
} else {
|
||||
prop_dictionary_get_cstring_nocopy(curpkgd, "version", ®ver);
|
||||
if (xbps_cmpver(version, regver) <= 0) {
|
||||
xbps_warn_printf("skipping `%s', `%s-%s' already "
|
||||
@ -206,7 +214,7 @@ add_binpkg_to_index(prop_array_t idx,
|
||||
goto out;
|
||||
}
|
||||
free(oldfilepath);
|
||||
if (!xbps_remove_pkg_from_array_by_name(idx, pkgname)) {
|
||||
if (!xbps_remove_pkg_from_array_by_name(idx, pkgname, arch)) {
|
||||
xbps_error_printf("failed to remove `%s' "
|
||||
"from plist index: %s\n", pkgname, strerror(errno));
|
||||
prop_object_release(newpkgd);
|
||||
@ -274,6 +282,8 @@ repo_genindex(const char *pkgdir)
|
||||
prop_array_t idx = NULL;
|
||||
struct dirent *dp;
|
||||
DIR *dirp;
|
||||
size_t i;
|
||||
char *curdir;
|
||||
char *binfile, *plist;
|
||||
int rv = 0;
|
||||
bool registered_newpkgs = false, foundpkg = false;
|
||||
@ -291,43 +301,51 @@ repo_genindex(const char *pkgdir)
|
||||
return errno;
|
||||
}
|
||||
|
||||
dirp = opendir(pkgdir);
|
||||
if (dirp == NULL) {
|
||||
xbps_error_printf("xbps-repo: cannot open `%s': %s\n",
|
||||
pkgdir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
for (i = 0; i < __arraycount(archs); i++) {
|
||||
curdir = xbps_xasprintf("%s/%s", pkgdir, archs[i]);
|
||||
assert(curdir != NULL);
|
||||
|
||||
dirp = opendir(curdir);
|
||||
if (dirp == NULL) {
|
||||
if (errno == ENOENT) {
|
||||
free(curdir);
|
||||
continue;
|
||||
}
|
||||
xbps_error_printf("xbps-repo: cannot open `%s': %s\n",
|
||||
curdir, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if ((strcmp(dp->d_name, ".") == 0) ||
|
||||
(strcmp(dp->d_name, "..") == 0))
|
||||
continue;
|
||||
/* Ignore unknown files */
|
||||
if (strstr(dp->d_name, ".xbps") == NULL)
|
||||
continue;
|
||||
|
||||
foundpkg = true;
|
||||
binfile = xbps_xasprintf("%s/%s", curdir, dp->d_name);
|
||||
if (binfile == NULL) {
|
||||
(void)closedir(dirp);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
rv = add_binpkg_to_index(idx, curdir, binfile);
|
||||
free(binfile);
|
||||
if (rv == EEXIST) {
|
||||
rv = 0;
|
||||
continue;
|
||||
} else if (rv != 0) {
|
||||
(void)closedir(dirp);
|
||||
free(curdir);
|
||||
goto out;
|
||||
}
|
||||
registered_newpkgs = true;
|
||||
}
|
||||
(void)closedir(dirp);
|
||||
free(curdir);
|
||||
}
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if ((strcmp(dp->d_name, ".") == 0) ||
|
||||
(strcmp(dp->d_name, "..") == 0))
|
||||
continue;
|
||||
|
||||
/* Ignore unknown files */
|
||||
if (strstr(dp->d_name, ".xbps") == NULL)
|
||||
continue;
|
||||
|
||||
foundpkg = true;
|
||||
binfile = xbps_xasprintf("%s/%s", pkgdir, dp->d_name);
|
||||
if (binfile == NULL) {
|
||||
(void)closedir(dirp);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
rv = add_binpkg_to_index(idx, pkgdir, binfile);
|
||||
free(binfile);
|
||||
if (rv == EEXIST) {
|
||||
rv = 0;
|
||||
continue;
|
||||
}
|
||||
else if (rv != 0) {
|
||||
(void)closedir(dirp);
|
||||
goto out;
|
||||
}
|
||||
registered_newpkgs = true;
|
||||
}
|
||||
(void)closedir(dirp);
|
||||
|
||||
if (foundpkg == false) {
|
||||
/* No packages were found in directory */
|
||||
rv = ENOENT;
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "../xbps-bin/defs.h"
|
||||
|
||||
int
|
||||
repo_pkg_list_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
repo_pkg_list_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
{
|
||||
struct list_pkgver_cb lpc;
|
||||
uint16_t idx;
|
||||
@ -44,42 +44,41 @@ repo_pkg_list_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
(void)done;
|
||||
if (arg != NULL) {
|
||||
idx = (uint16_t)strtoul(arg, &cp, 0);
|
||||
if (rpi->rpi_index != idx)
|
||||
if (rpi->index != idx)
|
||||
return 0;
|
||||
}
|
||||
lpc.check_state = false;
|
||||
lpc.state = 0;
|
||||
lpc.pkgver_len = find_longest_pkgver(rpi->rpi_repo);
|
||||
lpc.pkgver_len = find_longest_pkgver(rpi->repo);
|
||||
|
||||
if (arg == NULL)
|
||||
printf("From %s repository ...\n", rpi->rpi_uri);
|
||||
printf("From %s repository ...\n", rpi->uri);
|
||||
|
||||
(void)xbps_callback_array_iter(rpi->rpi_repo, list_pkgs_in_dict, &lpc);
|
||||
(void)xbps_callback_array_iter(rpi->repo, list_pkgs_in_dict, &lpc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
repo_list_uri_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
repo_list_uri_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
{
|
||||
(void)arg;
|
||||
(void)done;
|
||||
|
||||
printf("[%u] %s (%zu packages)\n",
|
||||
rpi->rpi_index, rpi->rpi_uri,
|
||||
(size_t)prop_array_count(rpi->rpi_repo));
|
||||
rpi->index, rpi->uri, (size_t)prop_array_count(rpi->repo));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
repo_search_pkgs_cb(struct repository_pool_index *rpi, void *arg, bool *done)
|
||||
repo_search_pkgs_cb(struct xbps_rpool_index *rpi, void *arg, bool *done)
|
||||
{
|
||||
struct repo_search_data *rsd = arg;
|
||||
(void)done;
|
||||
|
||||
rsd->pkgver_len = find_longest_pkgver(rpi->rpi_repo);
|
||||
rsd->pkgver_len = find_longest_pkgver(rpi->repo);
|
||||
|
||||
printf("From %s repository ...\n", rpi->rpi_uri);
|
||||
(void)xbps_callback_array_iter(rpi->rpi_repo, show_pkg_namedesc, rsd);
|
||||
printf("From %s repository ...\n", rpi->uri);
|
||||
(void)xbps_callback_array_iter(rpi->repo, show_pkg_namedesc, rsd);
|
||||
return 0;
|
||||
}
|
||||
|
@ -95,12 +95,16 @@ int
|
||||
show_pkg_namedesc(prop_object_t obj, void *arg, bool *loop_done)
|
||||
{
|
||||
struct repo_search_data *rsd = arg;
|
||||
const char *pkgver, *pkgname, *desc;
|
||||
const char *pkgver, *pkgname, *desc, *arch;
|
||||
char *tmp = NULL;
|
||||
size_t i, x;
|
||||
|
||||
(void)loop_done;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "architecture", &arch);
|
||||
if (!xbps_pkg_arch_match(arch, NULL))
|
||||
return 0;
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(obj, "short_desc", &desc);
|
||||
|
@ -48,12 +48,12 @@
|
||||
# Repositories not matching the host architecture are simply ignored.
|
||||
#
|
||||
repositories = {
|
||||
http://xbps.goodluckwith.us/binpkgs/i686,
|
||||
http://xbps.goodluckwith.us/binpkgs/noarch,
|
||||
http://xbps.goodluckwith.us/binpkgs/nonfree/i686,
|
||||
http://xbps.nopcode.org/repos/current/x86_64,
|
||||
http://xbps.nopcode.org/repos/current/noarch,
|
||||
http://xbps.nopcode.org/repos/current/nonfree/x86_64
|
||||
http://xbps.hosting-unlimited.org/binpkgs,
|
||||
#http://xbps.hosting-unlimited.org/binpkgs/nonfree,
|
||||
http://xbps.goodluckwith.us/binpkgs,
|
||||
#http://xbps.goodluckwith.us/binpkgs/nonfree,
|
||||
http://xbps.nopcode.org/repos/current,
|
||||
#http://xbps.nopcode.org/repos/current/nonfree
|
||||
}
|
||||
|
||||
# Packages on hold.
|
||||
|
@ -54,9 +54,9 @@
|
||||
* @def XBPS_PKGINDEX_VERSION
|
||||
* Current version for the repository package index format.
|
||||
*/
|
||||
#define XBPS_PKGINDEX_VERSION "1.4"
|
||||
#define XBPS_PKGINDEX_VERSION "1.5"
|
||||
|
||||
#define XBPS_API_VERSION "20120530-4"
|
||||
#define XBPS_API_VERSION "20120531"
|
||||
#define XBPS_VERSION "0.16"
|
||||
|
||||
/**
|
||||
@ -101,13 +101,13 @@
|
||||
* @def XBPS_PKGINDEX
|
||||
* Filename for the repository package index property list.
|
||||
*/
|
||||
#define XBPS_PKGINDEX "rindex.plist"
|
||||
#define XBPS_PKGINDEX "index.plist"
|
||||
|
||||
/**
|
||||
* @def XBPS_PKGINDEX_FILES
|
||||
* Filename for the repository package index files property list.
|
||||
*/
|
||||
#define XBPS_PKGINDEX_FILES "rindex-files.plist"
|
||||
#define XBPS_PKGINDEX_FILES "index-files.plist"
|
||||
|
||||
/**
|
||||
* @def XBPS_SYSCONF_PATH
|
||||
@ -1053,22 +1053,28 @@ bool xbps_match_any_virtualpkg_in_rundeps(prop_array_t rundeps,
|
||||
*
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] name The package name to match.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_array_by_name(prop_array_t array,
|
||||
const char *name);
|
||||
const char *name,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in a proplib array by matching a package pattern.
|
||||
*
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pattern The package pattern to match, i.e `foo>=0' or `foo<1'.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_array_by_pattern(prop_array_t array,
|
||||
const char *pattern);
|
||||
const char *pattern,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in a proplib array by matching a \a pkgver
|
||||
@ -1076,11 +1082,14 @@ prop_dictionary_t xbps_find_pkg_in_array_by_pattern(prop_array_t array,
|
||||
*
|
||||
* @param[in] array The proplib array to search on.
|
||||
* @param[in] pkgver The package name/version to match, i.e `foo-1.0'.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return The package dictionary, otherwise NULL is returned.
|
||||
*/
|
||||
prop_dictionary_t xbps_find_pkg_in_array_by_pkgver(prop_array_t array,
|
||||
const char *pkgver);
|
||||
const char *pkgver,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Finds a virtual package dictionary in a proplib array by matching a
|
||||
@ -1174,28 +1183,20 @@ prop_object_iterator_t xbps_array_iter_from_dict(prop_dictionary_t dict,
|
||||
prop_dictionary_t xbps_dictionary_from_metadata_plist(const char *pkgname,
|
||||
const char *plist);
|
||||
|
||||
/**
|
||||
* Removes the package's proplib dictionary matching \a pkgname
|
||||
* in a plist file.
|
||||
*
|
||||
* @param[in] pkgname Package name to match in plist's dictionary.
|
||||
* @param[in] plist Path to a plist file.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_dict_from_plist_by_name(const char *pkgname,
|
||||
const char *plist);
|
||||
|
||||
/**
|
||||
* Removes the package's proplib dictionary matching \a pkgname
|
||||
* in a proplib array.
|
||||
*
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] name Package name to match in the array.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_from_array_by_name(prop_array_t array, const char *name);
|
||||
bool xbps_remove_pkg_from_array_by_name(prop_array_t array,
|
||||
const char *name,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Removes the package's proplib dictionary matching the pkgver object
|
||||
@ -1203,11 +1204,14 @@ bool xbps_remove_pkg_from_array_by_name(prop_array_t array, const char *name);
|
||||
*
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] pattern Package pattern to match, i.e `foo>=0' or `foo<1'.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_from_array_by_pattern(prop_array_t array,
|
||||
const char *pattern);
|
||||
const char *pattern,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Removes the package's proplib dictionary matching the \a pkgver
|
||||
@ -1215,25 +1219,14 @@ bool xbps_remove_pkg_from_array_by_pattern(prop_array_t array,
|
||||
*
|
||||
* @param[in] array Proplib array where to look for.
|
||||
* @param[in] pkgver Package name/version to match, i.e `foo-1.0'.
|
||||
* @param[in] targetarch If set, package will be matched against this
|
||||
* architecture.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_from_array_by_pkgver(prop_array_t array,
|
||||
const char *pkgver);
|
||||
|
||||
/**
|
||||
* Removes the package's proplib dictionary matching \a pkgname,
|
||||
* in an array with key \a key stored in a proplib dictionary.
|
||||
*
|
||||
* @param[in] dict Proplib dictionary storing the proplib array.
|
||||
* @param[in] key Key associated with the proplib array.
|
||||
* @param[in] name Package name to match.
|
||||
*
|
||||
* @return true on success, false otherwise and errno is set appropiately.
|
||||
*/
|
||||
bool xbps_remove_pkg_from_dict_by_name(prop_dictionary_t dict,
|
||||
const char *key,
|
||||
const char *name);
|
||||
const char *pkgver,
|
||||
const char *targetarch);
|
||||
|
||||
/**
|
||||
* Removes a string from a proplib's array of strings.
|
||||
@ -1478,33 +1471,33 @@ prop_dictionary_t xbps_dictionary_metadata_plist_by_url(const char *url,
|
||||
/*@{*/
|
||||
|
||||
/**
|
||||
* @struct repository_pool_index xbps_api.h "xbps_api.h"
|
||||
* @struct xbps_rpool_index xbps_api.h "xbps_api.h"
|
||||
* @brief Repository pool dictionary structure
|
||||
*
|
||||
* Repository index object structure registered in a private simple queue.
|
||||
* The structure contains a dictionary and the URI associated with the
|
||||
* registered repository index.
|
||||
*/
|
||||
struct repository_pool_index {
|
||||
struct xbps_rpool_index {
|
||||
/**
|
||||
* @var rpi_repo
|
||||
*
|
||||
* Internalized proplib array of the index plist file
|
||||
* associated with repository.
|
||||
*/
|
||||
prop_array_t rpi_repo;
|
||||
prop_array_t repo;
|
||||
/**
|
||||
* @var rpi_uri
|
||||
*
|
||||
* URI string associated with repository.
|
||||
*/
|
||||
const char *rpi_uri;
|
||||
const char *uri;
|
||||
/**
|
||||
* @var rpi_index
|
||||
*
|
||||
* Repository index in pool.
|
||||
*/
|
||||
uint16_t rpi_index;
|
||||
uint16_t index;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -1530,9 +1523,7 @@ int xbps_rpool_sync(void);
|
||||
*
|
||||
* @return 0 on success, otherwise an errno value.
|
||||
*/
|
||||
int xbps_rpool_foreach(
|
||||
int (*fn)(struct repository_pool_index *, void *, bool *),
|
||||
void *arg);
|
||||
int xbps_rpool_foreach(int (*fn)(struct xbps_rpool_index *, void *, bool *), void *arg);
|
||||
|
||||
/**
|
||||
* Finds a package dictionary in the repository pool by specifying a
|
||||
@ -1908,8 +1899,11 @@ const char *xbps_pkgpattern_version(const char *pattern);
|
||||
* Package pattern matching.
|
||||
*
|
||||
* @param[in] pkgver Package name/version, i.e `foo-1.0'.
|
||||
* @param[in] pattern Package pattern to match against \a pkgver, i.e
|
||||
* `foo>=0' or `foo<1'.
|
||||
* @param[in] pattern Package pattern to match against \a pkgver.
|
||||
* There are 3 strategies for version matching:
|
||||
* - simple compare: pattern equals to pkgver.
|
||||
* - shell wildcards: see fnmatch(3).
|
||||
* - relational dewey matching: '>' '<' '>=' '<='.
|
||||
*
|
||||
* @return 1 if \a pkgver is matched against \a pattern, 0 if no match.
|
||||
*/
|
||||
@ -1934,6 +1928,17 @@ const char *xbps_pkg_revision(const char *pkg);
|
||||
*/
|
||||
bool xbps_pkg_has_rundeps(prop_dictionary_t dict);
|
||||
|
||||
/**
|
||||
* Returns true if provided string is valid for target architecture.
|
||||
*
|
||||
* @param[in] orig Architecture to match.
|
||||
* @param[in] target If not NULL, \a orig will be matched against it
|
||||
* rather than returned value of uname(2).
|
||||
*
|
||||
* @return True on match, false otherwise.
|
||||
*/
|
||||
bool xbps_pkg_arch_match(const char *orig, const char *target);
|
||||
|
||||
/**
|
||||
* Converts the 64 bits signed number specified in \a bytes to
|
||||
* a human parsable string buffer pointed to \a buf.
|
||||
|
@ -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;
|
||||
|
@ -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' "
|
||||
|
10
lib/pkgdb.c
10
lib/pkgdb.c
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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");
|
||||
|
@ -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 =
|
||||
|
24
lib/util.c
24
lib/util.c
@ -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, ...)
|
||||
{
|
||||
|
@ -69,7 +69,7 @@ ATF_TC_BODY(find_pkg_in_array_by_name_test, tc)
|
||||
ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY);
|
||||
|
||||
/* match by pkgname */
|
||||
dr = xbps_find_pkg_in_array_by_name(a, "foo");
|
||||
dr = xbps_find_pkg_in_array_by_name(a, "foo", NULL);
|
||||
ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY);
|
||||
}
|
||||
|
||||
@ -87,7 +87,7 @@ ATF_TC_BODY(find_pkg_in_array_by_pattern_test, tc)
|
||||
ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY);
|
||||
|
||||
/* match by pkgpattern */
|
||||
dr = xbps_find_pkg_in_array_by_pattern(a, "foo>=2.0");
|
||||
dr = xbps_find_pkg_in_array_by_pattern(a, "foo>=2.0", NULL);
|
||||
ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY);
|
||||
}
|
||||
|
||||
@ -105,7 +105,7 @@ ATF_TC_BODY(find_pkg_in_array_by_pkgver_test, tc)
|
||||
ATF_REQUIRE_EQ(prop_object_type(a), PROP_TYPE_ARRAY);
|
||||
|
||||
/* exact match by pkgver */
|
||||
dr = xbps_find_pkg_in_array_by_pkgver(a, "foo-2.0");
|
||||
dr = xbps_find_pkg_in_array_by_pkgver(a, "foo-2.0", NULL);
|
||||
ATF_REQUIRE_EQ(prop_object_type(dr), PROP_TYPE_DICTIONARY);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ ATF_TC_BODY(remove_pkg_from_array_by_name_test, tc)
|
||||
ATF_REQUIRE_EQ(prop_object_type(d2), PROP_TYPE_DICTIONARY);
|
||||
|
||||
a = prop_dictionary_get(d, "packages");
|
||||
ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_name(a, "afoo"), true);
|
||||
ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_name(a, "afoo", NULL), true);
|
||||
ATF_REQUIRE_EQ(prop_dictionary_equals(d, d2), true);
|
||||
}
|
||||
|
||||
@ -133,7 +133,7 @@ ATF_TC_BODY(remove_pkg_from_array_by_pattern_test, tc)
|
||||
ATF_REQUIRE_EQ(prop_object_type(d2), PROP_TYPE_DICTIONARY);
|
||||
|
||||
a = prop_dictionary_get(d, "packages");
|
||||
ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_pattern(a, "afoo>=1.0"), true);
|
||||
ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_pattern(a, "afoo>=1.0", NULL), true);
|
||||
ATF_REQUIRE_EQ(prop_dictionary_equals(d, d2), true);
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ ATF_TC_BODY(remove_pkg_from_array_by_pkgver_test, tc)
|
||||
ATF_REQUIRE_EQ(prop_object_type(d2), PROP_TYPE_DICTIONARY);
|
||||
|
||||
a = prop_dictionary_get(d, "packages");
|
||||
ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_pkgver(a, "afoo-1.1"), true);
|
||||
ATF_REQUIRE_EQ(xbps_remove_pkg_from_array_by_pkgver(a, "afoo-1.1", NULL), true);
|
||||
ATF_REQUIRE_EQ(prop_dictionary_equals(d, d2), true);
|
||||
}
|
||||
|
||||
@ -202,27 +202,6 @@ ATF_TC_BODY(remove_pkgname_from_array_test, tc)
|
||||
ATF_REQUIRE_EQ(prop_array_equals(a, a2), true);
|
||||
}
|
||||
|
||||
ATF_TC(remove_pkg_from_dict_by_name_test);
|
||||
|
||||
ATF_TC_HEAD(remove_pkg_from_dict_by_name_test, tc)
|
||||
{
|
||||
atf_tc_set_md_var(tc, "descr", "Test xbps_remove_pkg_from_dict_by_name");
|
||||
}
|
||||
|
||||
ATF_TC_BODY(remove_pkg_from_dict_by_name_test, tc)
|
||||
{
|
||||
prop_dictionary_t d, d2;
|
||||
|
||||
d = prop_dictionary_internalize(dictxml);
|
||||
ATF_REQUIRE_EQ(prop_object_type(d), PROP_TYPE_DICTIONARY);
|
||||
|
||||
d2 = prop_dictionary_internalize(dictxml2);
|
||||
ATF_REQUIRE_EQ(prop_object_type(d2), PROP_TYPE_DICTIONARY);
|
||||
|
||||
ATF_REQUIRE_EQ(xbps_remove_pkg_from_dict_by_name(d, "packages", "afoo"), true);
|
||||
ATF_REQUIRE_EQ(prop_dictionary_equals(d, d2), true);
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, remove_pkg_from_array_by_name_test);
|
||||
@ -230,7 +209,6 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, remove_pkg_from_array_by_pkgver_test);
|
||||
ATF_TP_ADD_TC(tp, remove_string_from_array_test);
|
||||
ATF_TP_ADD_TC(tp, remove_pkgname_from_array_test);
|
||||
ATF_TP_ADD_TC(tp, remove_pkg_from_dict_by_name_test);
|
||||
|
||||
return atf_no_error();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user