Use a single file to store repository data.
This is just the starting point to extend repositories with PGP signatures.
This commit is contained in:
@@ -162,13 +162,13 @@ list_pkgs_pkgdb(struct xbps_handle *xhp)
|
||||
}
|
||||
|
||||
static int
|
||||
repo_list_uri_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
repo_list_uri_cb(struct xbps_repo *repo, void *arg, bool *done)
|
||||
{
|
||||
(void)arg;
|
||||
(void)done;
|
||||
|
||||
printf("%s (%zu packages)\n", rpi->uri,
|
||||
(size_t)prop_dictionary_count(rpi->repod));
|
||||
printf("%s (%zu packages)\n", repo->uri,
|
||||
(size_t)prop_dictionary_count(repo->idx));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -123,21 +123,18 @@ ownedby(struct xbps_handle *xhp, int npatterns, char **patterns)
|
||||
}
|
||||
|
||||
static void
|
||||
repo_match_files_by_pattern(prop_dictionary_t pkgd,
|
||||
struct ffdata *ffd)
|
||||
repo_match_files_by_pattern(prop_array_t files,
|
||||
const char *pkgver,
|
||||
struct ffdata *ffd)
|
||||
{
|
||||
prop_array_t array;
|
||||
const char *filestr, *pkgver;
|
||||
const char *filestr;
|
||||
size_t i;
|
||||
int x;
|
||||
|
||||
array = prop_dictionary_get(pkgd, "files");
|
||||
for (i = 0; i < prop_array_count(array); i++) {
|
||||
prop_array_get_cstring_nocopy(array, i, &filestr);
|
||||
for (i = 0; i < prop_array_count(files); i++) {
|
||||
prop_array_get_cstring_nocopy(files, i, &filestr);
|
||||
for (x = 0; x < ffd->npatterns; x++) {
|
||||
if ((fnmatch(ffd->patterns[x], filestr, FNM_PERIOD)) == 0) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
printf("%s: %s (%s)\n",
|
||||
pkgver, filestr, ffd->repouri);
|
||||
}
|
||||
@@ -146,35 +143,26 @@ repo_match_files_by_pattern(prop_dictionary_t pkgd,
|
||||
}
|
||||
|
||||
static int
|
||||
repo_ownedby_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
repo_ownedby_cb(struct xbps_repo *repo, void *arg, bool *done)
|
||||
{
|
||||
prop_array_t allkeys;
|
||||
prop_dictionary_t pkgd, idxfiles;
|
||||
prop_array_t allkeys, pkgar;
|
||||
prop_dictionary_t filesd;
|
||||
prop_dictionary_keysym_t ksym;
|
||||
struct ffdata *ffd = arg;
|
||||
char *plist;
|
||||
const char *pkgver;
|
||||
unsigned int i;
|
||||
|
||||
(void)done;
|
||||
|
||||
if ((plist = xbps_pkg_index_files_plist(rpi->xhp, rpi->uri)) == NULL)
|
||||
return ENOMEM;
|
||||
|
||||
if ((idxfiles = prop_dictionary_internalize_from_zfile(plist)) == NULL) {
|
||||
if (errno == ENOENT) {
|
||||
fprintf(stderr, "%s: index-files missing! "
|
||||
"ignoring...\n", rpi->uri);
|
||||
return 0;
|
||||
}
|
||||
return errno;
|
||||
}
|
||||
ffd->repouri = rpi->uri;
|
||||
allkeys = prop_dictionary_all_keys(idxfiles);
|
||||
filesd = xbps_repo_get_plist(repo, XBPS_PKGINDEX_FILES);
|
||||
ffd->repouri = repo->uri;
|
||||
allkeys = prop_dictionary_all_keys(filesd);
|
||||
|
||||
for (i = 0; i < prop_array_count(allkeys); i++) {
|
||||
ksym = prop_array_get(allkeys, i);
|
||||
pkgd = prop_dictionary_get_keysym(idxfiles, ksym);
|
||||
repo_match_files_by_pattern(pkgd, ffd);
|
||||
pkgar = prop_dictionary_get_keysym(filesd, ksym);
|
||||
pkgver = prop_dictionary_keysym_cstring_nocopy(ksym);
|
||||
repo_match_files_by_pattern(pkgar, pkgver, ffd);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -96,7 +96,7 @@ print_results(struct xbps_handle *xhp, struct search_data *sd)
|
||||
}
|
||||
|
||||
static int
|
||||
search_pkgs_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
search_pkgs_cb(struct xbps_repo *repo, void *arg, bool *done)
|
||||
{
|
||||
prop_array_t allkeys;
|
||||
prop_dictionary_t pkgd;
|
||||
@@ -108,12 +108,12 @@ search_pkgs_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
|
||||
(void)done;
|
||||
|
||||
allkeys = prop_dictionary_all_keys(rpi->repod);
|
||||
allkeys = prop_dictionary_all_keys(repo->idx);
|
||||
for (i = 0; i < prop_array_count(allkeys); i++) {
|
||||
prop_array_t provides = NULL;
|
||||
|
||||
ksym = prop_array_get(allkeys, i);
|
||||
pkgd = prop_dictionary_get_keysym(rpi->repod, ksym);
|
||||
pkgd = prop_dictionary_get_keysym(repo->idx, ksym);
|
||||
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
|
||||
prop_dictionary_get_cstring_nocopy(pkgd, "short_desc", &desc);
|
||||
|
||||
@@ -128,7 +128,7 @@ repo_show_pkg_deps(struct xbps_handle *xhp, const char *pattern, bool full)
|
||||
}
|
||||
|
||||
static int
|
||||
repo_revdeps_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
repo_revdeps_cb(struct xbps_repo *repo, void *arg, bool *done)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
prop_array_t pkgdeps;
|
||||
@@ -138,10 +138,10 @@ repo_revdeps_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
|
||||
(void)done;
|
||||
|
||||
iter = prop_dictionary_iterator(rpi->repod);
|
||||
iter = prop_dictionary_iterator(repo->idx);
|
||||
assert(iter);
|
||||
while ((obj = prop_object_iterator_next(iter))) {
|
||||
pkgd = prop_dictionary_get_keysym(rpi->repod, obj);
|
||||
pkgd = prop_dictionary_get_keysym(repo->idx, obj);
|
||||
pkgdeps = prop_dictionary_get(pkgd, "run_depends");
|
||||
if (pkgdeps == NULL || prop_array_count(pkgdeps) == 0)
|
||||
continue;
|
||||
@@ -149,7 +149,7 @@ repo_revdeps_cb(struct xbps_rindex *rpi, void *arg, bool *done)
|
||||
if (xbps_match_pkgdep_in_array(pkgdeps, pattern)) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"architecture", &arch);
|
||||
if (xbps_pkg_arch_match(rpi->xhp, arch, NULL)) {
|
||||
if (xbps_pkg_arch_match(repo->xhp, arch, NULL)) {
|
||||
prop_dictionary_get_cstring_nocopy(pkgd,
|
||||
"pkgver", &pkgver);
|
||||
printf("%s\n", pkgver);
|
||||
|
||||
Reference in New Issue
Block a user