Repository index 1.4 -- see NEWS file for info.

This commit is contained in:
Juan RP
2012-01-19 12:26:40 +01:00
parent 9147488b19
commit 9a088937b5
13 changed files with 118 additions and 156 deletions

5
NEWS
View File

@ -1,5 +1,10 @@
xbps-0.12.0 (???): xbps-0.12.0 (???):
* Repository index 1.4: the file is now externalized to a proplib array
and has been renamed to "rindex.plist" to not break compatibility
with previous XBPS versions. This helps in simplifying the API
implementation substantially.
* Added a pkg-config file to simplify writing code with libxbps. * Added a pkg-config file to simplify writing code with libxbps.
* libxbps: improved support for finding newest package versions available * libxbps: improved support for finding newest package versions available

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009-2011 Juan Romero Pardines. * Copyright (c) 2009-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -102,7 +102,7 @@ void show_pkg_info(prop_dictionary_t);
void show_pkg_info_one(prop_dictionary_t, const char *); void show_pkg_info_one(prop_dictionary_t, const char *);
int list_strings_in_array(prop_object_t, void *, bool *); int list_strings_in_array(prop_object_t, void *, bool *);
int list_strings_sep_in_array(prop_object_t, void *, bool *); int list_strings_sep_in_array(prop_object_t, void *, bool *);
size_t find_longest_pkgver(prop_dictionary_t); size_t find_longest_pkgver(prop_object_t);
void print_package_line(const char *, bool); void print_package_line(const char *, bool);
/* from list.c */ /* from list.c */

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2008-2011 Juan Romero Pardines. * Copyright (c) 2008-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -186,12 +186,12 @@ _find_longest_pkgver_cb(prop_object_t obj, void *arg, bool *loop_done)
} }
size_t size_t
find_longest_pkgver(prop_dictionary_t d) find_longest_pkgver(prop_object_t o)
{ {
size_t len = 0; size_t len = 0;
if (prop_object_type(d) == PROP_TYPE_DICTIONARY) if (prop_object_type(o) == PROP_TYPE_ARRAY)
(void)xbps_callback_array_iter_in_dict(d, "packages", (void)xbps_callback_array_iter(o,
_find_longest_pkgver_cb, &len); _find_longest_pkgver_cb, &len);
else else
(void)xbps_regpkgdb_foreach_pkg_cb( (void)xbps_regpkgdb_foreach_pkg_cb(

View File

@ -33,7 +33,7 @@
#include "defs.h" #include "defs.h"
struct index_files_data { struct index_files_data {
prop_dictionary_t idxdict; prop_array_t idx;
prop_array_t idxfiles; prop_array_t idxfiles;
prop_array_t obsoletes; prop_array_t obsoletes;
const char *pkgdir; const char *pkgdir;
@ -44,7 +44,6 @@ struct index_files_data {
static int static int
rmobsoletes_files_cb(prop_object_t obj, void *arg, bool *done) rmobsoletes_files_cb(prop_object_t obj, void *arg, bool *done)
{ {
prop_array_t array;
prop_string_t ps; prop_string_t ps;
struct index_files_data *ifd = arg; struct index_files_data *ifd = arg;
const char *pkgver; const char *pkgver;
@ -52,8 +51,7 @@ rmobsoletes_files_cb(prop_object_t obj, void *arg, bool *done)
(void)done; (void)done;
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
array = prop_dictionary_get(ifd->idxdict, "packages"); if (xbps_find_pkg_in_array_by_pkgver(ifd->idx, pkgver)) {
if (xbps_find_pkg_in_array_by_pkgver(array, pkgver)) {
/* pkg found, do nothing */ /* pkg found, do nothing */
return 0; return 0;
} }
@ -195,9 +193,9 @@ start:
int int
repo_genindex_files(const char *pkgdir) repo_genindex_files(const char *pkgdir)
{ {
prop_dictionary_t idxdict; prop_array_t idx;
struct index_files_data *ifd = NULL; struct index_files_data *ifd = NULL;
size_t idx; size_t i;
const char *pkgver; const char *pkgver;
char *plist; char *plist;
int rv; int rv;
@ -207,8 +205,8 @@ repo_genindex_files(const char *pkgdir)
return ENOMEM; return ENOMEM;
/* internalize repository index plist */ /* internalize repository index plist */
idxdict = prop_dictionary_internalize_from_zfile(plist); idx = prop_array_internalize_from_zfile(plist);
if (idxdict == NULL) { if (idx == NULL) {
free(plist); free(plist);
return errno; return errno;
} }
@ -227,7 +225,7 @@ repo_genindex_files(const char *pkgdir)
} }
ifd->pkgdir = pkgdir; ifd->pkgdir = pkgdir;
ifd->idxfiles = prop_array_internalize_from_zfile(plist); ifd->idxfiles = prop_array_internalize_from_zfile(plist);
ifd->idxdict = prop_dictionary_copy(idxdict); ifd->idx = prop_array_copy(idx);
ifd->obsoletes = prop_array_create(); ifd->obsoletes = prop_array_create();
if (ifd->idxfiles == NULL) { if (ifd->idxfiles == NULL) {
/* missing file, create new one */ /* missing file, create new one */
@ -236,8 +234,7 @@ repo_genindex_files(const char *pkgdir)
} }
/* iterate over index.plist packages array */ /* iterate over index.plist packages array */
rv = xbps_callback_array_iter_in_dict(idxdict, rv = xbps_callback_array_iter(idx, genindex_files_cb, ifd);
"packages", genindex_files_cb, ifd);
if (rv != 0) if (rv != 0)
goto out; goto out;
@ -247,9 +244,9 @@ repo_genindex_files(const char *pkgdir)
rmobsoletes_files_cb, ifd); rmobsoletes_files_cb, ifd);
if (rv != 0) if (rv != 0)
goto out; goto out;
for (idx = 0; idx < prop_array_count(ifd->obsoletes); idx++) { for (i = 0; i < prop_array_count(ifd->obsoletes); i++) {
prop_array_get_cstring_nocopy(ifd->obsoletes, prop_array_get_cstring_nocopy(ifd->obsoletes,
idx, &pkgver); i, &pkgver);
if (!xbps_remove_pkg_from_array_by_pkgver( if (!xbps_remove_pkg_from_array_by_pkgver(
ifd->idxfiles, pkgver)) { ifd->idxfiles, pkgver)) {
rv = EINVAL; rv = EINVAL;
@ -274,14 +271,14 @@ out:
prop_object_release(ifd->obsoletes); prop_object_release(ifd->obsoletes);
if (ifd->idxfiles != NULL) if (ifd->idxfiles != NULL)
prop_object_release(ifd->idxfiles); prop_object_release(ifd->idxfiles);
if (ifd->idxdict != NULL) if (ifd->idx != NULL)
prop_object_release(ifd->idxdict); prop_object_release(ifd->idx);
if (plist != NULL) if (plist != NULL)
free(plist); free(plist);
if (ifd != NULL) if (ifd != NULL)
free(ifd); free(ifd);
if (idxdict != NULL) if (idx != NULL)
prop_object_release(idxdict); prop_object_release(idx);
return rv; return rv;
} }

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009-2011 Juan Romero Pardines. * Copyright (c) 2009-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -43,8 +43,8 @@
static int static int
remove_missing_binpkg_entries(const char *repodir) remove_missing_binpkg_entries(const char *repodir)
{ {
prop_array_t pkgarray; prop_array_t array;
prop_dictionary_t idxd, pkgd; prop_dictionary_t pkgd;
const char *filen; const char *filen;
char *binpkg, *plist; char *binpkg, *plist;
size_t i; size_t i;
@ -55,8 +55,8 @@ remove_missing_binpkg_entries(const char *repodir)
if (plist == NULL) if (plist == NULL)
return -1; return -1;
idxd = prop_dictionary_internalize_from_zfile(plist); array = prop_array_internalize_from_zfile(plist);
if (idxd == NULL) { if (array == NULL) {
if (errno != ENOENT) { if (errno != ENOENT) {
xbps_error_printf("xbps-repo: cannot read `%s': %s\n", xbps_error_printf("xbps-repo: cannot read `%s': %s\n",
plist, strerror(errno)); plist, strerror(errno));
@ -68,12 +68,8 @@ remove_missing_binpkg_entries(const char *repodir)
} }
again: again:
pkgarray = prop_dictionary_get(idxd, "packages"); for (i = 0; i < prop_array_count(array); i++) {
if (prop_object_type(pkgarray) != PROP_TYPE_ARRAY) pkgd = prop_array_get(array, i);
return -1;
for (i = 0; i < prop_array_count(pkgarray); i++) {
pkgd = prop_array_get(pkgarray, i);
prop_dictionary_get_cstring_nocopy(pkgd, "filename", &filen); prop_dictionary_get_cstring_nocopy(pkgd, "filename", &filen);
binpkg = xbps_xasprintf("%s/%s", repodir, filen); binpkg = xbps_xasprintf("%s/%s", repodir, filen);
if (binpkg == NULL) { if (binpkg == NULL) {
@ -85,7 +81,7 @@ again:
xbps_warn_printf("xbps-repo: `%s' unavailable, " xbps_warn_printf("xbps-repo: `%s' unavailable, "
"removing entry from index... (%s)\n", "removing entry from index... (%s)\n",
filen, strerror(errno)); filen, strerror(errno));
prop_array_remove(pkgarray, i); prop_array_remove(array, i);
free(binpkg); free(binpkg);
found = true; found = true;
goto again; goto again;
@ -93,10 +89,7 @@ again:
free(binpkg); free(binpkg);
} }
if (found) { if (found) {
prop_dictionary_set_uint64(idxd, "total-pkgs", if (!prop_array_externalize_to_zfile(array, plist))
prop_array_count(pkgarray));
prop_dictionary_set(idxd, "packages", pkgarray);
if (!prop_dictionary_externalize_to_zfile(idxd, plist))
rv = errno; rv = errno;
} }
free(plist); free(plist);
@ -104,14 +97,12 @@ again:
return rv; return rv;
} }
static prop_dictionary_t static prop_array_t
repoidx_getdict(const char *pkgdir) repoidx_get(const char *pkgdir)
{ {
prop_dictionary_t dict;
prop_array_t array; prop_array_t array;
char *plist; char *plist;
int rv; int rv;
/* /*
* Remove entries in repositories index for unexistent * Remove entries in repositories index for unexistent
* packages, i.e dangling entries. * packages, i.e dangling entries.
@ -123,50 +114,25 @@ repoidx_getdict(const char *pkgdir)
if (plist == NULL) if (plist == NULL)
return NULL; return NULL;
dict = prop_dictionary_internalize_from_zfile(plist); array = prop_array_internalize_from_zfile(plist);
if (dict == NULL) {
dict = prop_dictionary_create();
if (dict == NULL)
goto out;
array = prop_array_create();
if (array == NULL) {
prop_object_release(dict);
goto out;
}
if (!prop_dictionary_set(dict, "packages", array)) {
prop_object_release(dict);
prop_object_release(array);
goto out;
}
prop_object_release(array);
if (!prop_dictionary_set_cstring_nocopy(dict,
"pkgindex-version", XBPS_PKGINDEX_VERSION)) {
prop_object_release(dict);
goto out;
}
}
out:
free(plist); free(plist);
return dict; if (array == NULL)
array = prop_array_create();
return array;
} }
static int static int
add_binpkg_to_index(prop_dictionary_t idxdict, add_binpkg_to_index(prop_array_t idx,
const char *filedir, const char *filedir,
const char *file) const char *file)
{ {
prop_dictionary_t newpkgd, curpkgd; prop_dictionary_t newpkgd, curpkgd;
prop_array_t pkgar;
struct stat st; struct stat st;
const char *pkgname, *version, *regver, *oldfilen, *oldpkgver; const char *pkgname, *version, *regver, *oldfilen, *oldpkgver;
char *sha256, *filen, *tmpfilen, *oldfilepath, *buf; char *sha256, *filen, *tmpfilen, *oldfilepath, *buf;
int rv = 0; int rv = 0;
if (idxdict == NULL || file == NULL)
return EINVAL;
tmpfilen = strdup(file); tmpfilen = strdup(file);
if (tmpfilen == NULL) if (tmpfilen == NULL)
return errno; return errno;
@ -191,7 +157,7 @@ add_binpkg_to_index(prop_dictionary_t idxdict,
* than current registered package, update the index; otherwise * than current registered package, update the index; otherwise
* pass to the next one. * pass to the next one.
*/ */
curpkgd = xbps_find_pkg_in_dict_by_name(idxdict, "packages", pkgname); curpkgd = xbps_find_pkg_in_array_by_name(idx, pkgname);
if (curpkgd == NULL) { if (curpkgd == NULL) {
if (errno && errno != ENOENT) { if (errno && errno != ENOENT) {
prop_object_release(newpkgd); prop_object_release(newpkgd);
@ -240,8 +206,7 @@ add_binpkg_to_index(prop_dictionary_t idxdict,
goto out; goto out;
} }
free(oldfilepath); free(oldfilepath);
if (!xbps_remove_pkg_from_dict_by_name(idxdict, if (!xbps_remove_pkg_from_array_by_name(idx, pkgname)) {
"packages", pkgname)) {
xbps_error_printf("failed to remove `%s' " xbps_error_printf("failed to remove `%s' "
"from plist index: %s\n", pkgname, strerror(errno)); "from plist index: %s\n", pkgname, strerror(errno));
prop_object_release(newpkgd); prop_object_release(newpkgd);
@ -286,28 +251,16 @@ add_binpkg_to_index(prop_dictionary_t idxdict,
rv = errno; rv = errno;
goto out; goto out;
} }
/* Get package array in repo index file */
pkgar = prop_dictionary_get(idxdict, "packages");
if (pkgar == NULL) {
prop_object_release(newpkgd);
rv = errno;
goto out;
}
/* /*
* Add dictionary into the index and update package count. * Add dictionary into the index and update package count.
*/ */
if (!xbps_add_obj_to_array(pkgar, newpkgd)) { if (!xbps_add_obj_to_array(idx, newpkgd)) {
prop_object_release(newpkgd);
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
printf("Registered `%s-%s' (%s) in repository index.\n", printf("Registered `%s-%s' (%s) in repository index.\n",
pkgname, version, filen); pkgname, version, filen);
if (!prop_dictionary_set_uint64(idxdict, "total-pkgs",
prop_array_count(pkgar)))
rv = errno;
out: out:
if (tmpfilen) if (tmpfilen)
free(tmpfilen); free(tmpfilen);
@ -318,10 +271,9 @@ out:
int int
repo_genindex(const char *pkgdir) repo_genindex(const char *pkgdir)
{ {
prop_dictionary_t idxdict = NULL; prop_array_t idx = NULL;
struct dirent *dp; struct dirent *dp;
DIR *dirp; DIR *dirp;
uint64_t npkgcnt = 0;
char *binfile, *plist; char *binfile, *plist;
int rv = 0; int rv = 0;
bool registered_newpkgs = false, foundpkg = false; bool registered_newpkgs = false, foundpkg = false;
@ -329,13 +281,13 @@ repo_genindex(const char *pkgdir)
/* /*
* Create or read existing package index plist file. * Create or read existing package index plist file.
*/ */
idxdict = repoidx_getdict(pkgdir); idx = repoidx_get(pkgdir);
if (idxdict == NULL) if (idx == NULL)
return errno; return errno;
plist = xbps_pkg_index_plist(pkgdir); plist = xbps_pkg_index_plist(pkgdir);
if (plist == NULL) { if (plist == NULL) {
prop_object_release(idxdict); prop_object_release(idx);
return errno; return errno;
} }
@ -362,7 +314,7 @@ repo_genindex(const char *pkgdir)
rv = errno; rv = errno;
goto out; goto out;
} }
rv = add_binpkg_to_index(idxdict, pkgdir, binfile); rv = add_binpkg_to_index(idx, pkgdir, binfile);
free(binfile); free(binfile);
if (rv == EEXIST) { if (rv == EEXIST) {
rv = 0; rv = 0;
@ -383,8 +335,8 @@ repo_genindex(const char *pkgdir)
/* /*
* Show total count registered packages. * Show total count registered packages.
*/ */
prop_dictionary_get_uint64(idxdict, "total-pkgs", &npkgcnt); printf("%zu packages registered in repository index.\n",
printf("%ju packages registered in repository index.\n", npkgcnt); (size_t)prop_array_count(idx));
/* /*
* Don't write plist file if no packages were registered. * Don't write plist file if no packages were registered.
*/ */
@ -394,12 +346,12 @@ repo_genindex(const char *pkgdir)
* If any package was registered in package index, write * If any package was registered in package index, write
* plist file to storage. * plist file to storage.
*/ */
if (!prop_dictionary_externalize_to_zfile(idxdict, plist)) if (!prop_array_externalize_to_zfile(idx, plist))
rv = errno; rv = errno;
} }
out: out:
free(plist); free(plist);
prop_object_release(idxdict); prop_object_release(idx);
return rv; return rv;
} }

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2011 Juan Romero Pardines. * Copyright (c) 2011-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -49,29 +49,22 @@ repo_pkg_list_cb(struct repository_pool_index *rpi, void *arg, bool *done)
} }
lpc.check_state = false; lpc.check_state = false;
lpc.state = 0; lpc.state = 0;
lpc.pkgver_len = find_longest_pkgver(rpi->rpi_repod); lpc.pkgver_len = find_longest_pkgver(rpi->rpi_repo);
printf("From %s repository ...\n", rpi->rpi_uri); printf("From %s repository ...\n", rpi->rpi_uri);
(void)xbps_callback_array_iter_in_dict(rpi->rpi_repod, (void)xbps_callback_array_iter(rpi->rpi_repo, list_pkgs_in_dict, &lpc);
"packages", list_pkgs_in_dict, &lpc);
return 0; return 0;
} }
int int
repo_list_uri_cb(struct repository_pool_index *rpi, void *arg, bool *done) repo_list_uri_cb(struct repository_pool_index *rpi, void *arg, bool *done)
{ {
const char *pkgidx;
uint64_t npkgs;
(void)arg; (void)arg;
(void)done; (void)done;
prop_dictionary_get_cstring_nocopy(rpi->rpi_repod, printf("[%u] %s (%zu packages)\n",
"pkgindex-version", &pkgidx); rpi->rpi_index, rpi->rpi_uri,
prop_dictionary_get_uint64(rpi->rpi_repod, "total-pkgs", &npkgs); (size_t)prop_array_count(rpi->rpi_repo));
printf("[%u] %s (index %s, " "%" PRIu64 " packages)\n",
rpi->rpi_index, rpi->rpi_uri, pkgidx, npkgs);
return 0; return 0;
} }
@ -82,11 +75,9 @@ repo_search_pkgs_cb(struct repository_pool_index *rpi, void *arg, bool *done)
struct repo_search_data *rsd = arg; struct repo_search_data *rsd = arg;
(void)done; (void)done;
rsd->pkgver_len = find_longest_pkgver(rpi->rpi_repod); rsd->pkgver_len = find_longest_pkgver(rpi->rpi_repo);
printf("From %s repository ...\n", rpi->rpi_uri); printf("From %s repository ...\n", rpi->rpi_uri);
(void)xbps_callback_array_iter_in_dict(rpi->rpi_repod, (void)xbps_callback_array_iter(rpi->rpi_repo, show_pkg_namedesc, rsd);
"packages", show_pkg_namedesc, rsd);
return 0; return 0;
} }

View File

@ -43,7 +43,7 @@
# #
# By default we use the official "public" repositories. You can add # By default we use the official "public" repositories. You can add
# your own repositories by specifying the path to the directory # your own repositories by specifying the path to the directory
# where the index.plist file is stored. # where the plist index file (rindex.plist) is stored.
# #
# Repositories not matching the host architecture are simply ignored. # Repositories not matching the host architecture are simply ignored.
# #

View File

@ -54,9 +54,9 @@
* @def XBPS_PKGINDEX_VERSION * @def XBPS_PKGINDEX_VERSION
* Current version for the repository package index format. * Current version for the repository package index format.
*/ */
#define XBPS_PKGINDEX_VERSION "1.3" #define XBPS_PKGINDEX_VERSION "1.4"
#define XBPS_API_VERSION "20120118" #define XBPS_API_VERSION "20120119"
#define XBPS_VERSION "0.12" #define XBPS_VERSION "0.12"
/** /**
@ -101,13 +101,13 @@
* @def XBPS_PKGINDEX * @def XBPS_PKGINDEX
* Filename for the repository package index property list. * Filename for the repository package index property list.
*/ */
#define XBPS_PKGINDEX "index.plist" #define XBPS_PKGINDEX "rindex.plist"
/** /**
* @def XBPS_PKGINDEX_FILES * @def XBPS_PKGINDEX_FILES
* Filename for the repository package index files property list. * Filename for the repository package index files property list.
*/ */
#define XBPS_PKGINDEX_FILES "index-files.plist" #define XBPS_PKGINDEX_FILES "rindex-files.plist"
/** /**
* @def XBPS_SYSCONF_PATH * @def XBPS_SYSCONF_PATH
@ -1388,12 +1388,12 @@ prop_dictionary_t xbps_dictionary_metadata_plist_by_url(const char *url,
*/ */
struct repository_pool_index { struct repository_pool_index {
/** /**
* @var rpi_repod * @var rpi_repo
* *
* Internalized Proplib dictionary of the index plist file * Internalized proplib array of the index plist file
* associated with repository. * associated with repository.
*/ */
prop_dictionary_t rpi_repod; prop_array_t rpi_repo;
/** /**
* @var rpi_uri * @var rpi_uri
* *

View File

@ -175,11 +175,15 @@ prop_dictionary_t HIDDEN
xbps_find_virtualpkg_in_dict_by_pattern(prop_dictionary_t, xbps_find_virtualpkg_in_dict_by_pattern(prop_dictionary_t,
const char *, const char *,
const char *); const char *);
prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_array_by_name(prop_array_t, const char *);
prop_dictionary_t HIDDEN prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_dict_by_name(prop_dictionary_t, xbps_find_virtualpkg_conf_in_dict_by_name(prop_dictionary_t,
const char *, const char *,
const char *); const char *);
prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_array_by_pattern(prop_array_t,
const char *);
prop_dictionary_t HIDDEN prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_dict_by_pattern(prop_dictionary_t, xbps_find_virtualpkg_conf_in_dict_by_pattern(prop_dictionary_t,
const char *, const char *,

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2008-2011 Juan Romero Pardines. * Copyright (c) 2008-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -211,6 +211,18 @@ find_virtualpkg_user_in_array(prop_array_t array,
return find_pkg_in_array(array, vpkgname, false, false); return find_pkg_in_array(array, vpkgname, false, false);
} }
prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_array_by_name(prop_array_t array, const char *name)
{
return find_virtualpkg_user_in_array(array, name, false);
}
prop_dictionary_t HIDDEN
xbps_find_virtualpkg_conf_in_array_by_pattern(prop_array_t array, const char *p)
{
return find_virtualpkg_user_in_array(array, p, true);
}
static prop_dictionary_t static prop_dictionary_t
find_virtualpkg_user_in_dict(prop_dictionary_t d, find_virtualpkg_user_in_dict(prop_dictionary_t d,
const char *key, const char *key,

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009-2011 Juan Romero Pardines. * Copyright (c) 2009-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -122,7 +122,7 @@ xbps_repository_pool_init(struct xbps_handle *xhp)
goto out; goto out;
} }
if (!xbps_add_obj_to_dict(d, if (!xbps_add_obj_to_dict(d,
prop_dictionary_internalize_from_zfile(plist), prop_array_internalize_from_zfile(plist),
"index")) { "index")) {
rv = EINVAL; rv = EINVAL;
prop_object_release(d); prop_object_release(d);
@ -194,7 +194,7 @@ xbps_repository_pool_sync(const struct xbps_handle *xhp)
continue; continue;
} }
/* /*
* Fetch repository index.plist. * Fetch repository plist index.
*/ */
rv = xbps_repository_sync_pkg_index(repouri, XBPS_PKGINDEX); rv = xbps_repository_sync_pkg_index(repouri, XBPS_PKGINDEX);
if (rv == -1) { if (rv == -1) {
@ -204,7 +204,7 @@ xbps_repository_pool_sync(const struct xbps_handle *xhp)
continue; continue;
} }
/* /*
* Fetch repository index-files.plist. * Fetch repository plist files index.
*/ */
rv = xbps_repository_sync_pkg_index(repouri, rv = xbps_repository_sync_pkg_index(repouri,
XBPS_PKGINDEX_FILES); XBPS_PKGINDEX_FILES);
@ -249,7 +249,7 @@ xbps_repository_pool_foreach(
d = prop_array_get(xhp->repo_pool, i); d = prop_array_get(xhp->repo_pool, i);
prop_dictionary_get_cstring_nocopy(d, "uri", &rpi->rpi_uri); prop_dictionary_get_cstring_nocopy(d, "uri", &rpi->rpi_uri);
rpi->rpi_repod = prop_dictionary_get(d, "index"); rpi->rpi_repo = prop_dictionary_get(d, "index");
rpi->rpi_index = i; rpi->rpi_index = i;
rv = (*fn)(rpi, arg, &done); rv = (*fn)(rpi, arg, &done);

View File

@ -54,12 +54,12 @@ repo_find_virtualpkg_cb(struct repository_pool_index *rpi, void *arg, bool *done
if (rpf->bypattern) { if (rpf->bypattern) {
rpf->pkgd = rpf->pkgd =
xbps_find_virtualpkg_conf_in_dict_by_pattern(rpi->rpi_repod, xbps_find_virtualpkg_conf_in_array_by_pattern(rpi->rpi_repo,
"packages", rpf->pattern); rpf->pattern);
} else { } else {
rpf->pkgd = rpf->pkgd =
xbps_find_virtualpkg_conf_in_dict_by_name(rpi->rpi_repod, xbps_find_virtualpkg_conf_in_array_by_name(rpi->rpi_repo,
"packages", rpf->pattern); rpf->pattern);
} }
if (rpf->pkgd) { if (rpf->pkgd) {
#ifdef DEBUG #ifdef DEBUG
@ -88,25 +88,25 @@ repo_find_pkg_cb(struct repository_pool_index *rpi, void *arg, bool *done)
return 0; return 0;
} }
/* exact match by pkgver */ /* exact match by pkgver */
rpf->pkgd = xbps_find_pkg_in_dict_by_pkgver(rpi->rpi_repod, rpf->pkgd = xbps_find_pkg_in_array_by_pkgver(rpi->rpi_repo,
"packages", rpf->pattern); rpf->pattern);
} else if (rpf->bypattern) { } else if (rpf->bypattern) {
/* match by pkgpattern in pkgver*/ /* match by pkgpattern in pkgver*/
rpf->pkgd = xbps_find_pkg_in_dict_by_pattern(rpi->rpi_repod, rpf->pkgd = xbps_find_pkg_in_array_by_pattern(rpi->rpi_repo,
"packages", rpf->pattern); rpf->pattern);
/* If no pkg exists matching pattern, look for virtual packages */ /* If no pkg exists matching pattern, look for virtual packages */
if (rpf->pkgd == NULL) { if (rpf->pkgd == NULL) {
rpf->pkgd = xbps_find_virtualpkg_in_dict_by_pattern( rpf->pkgd = xbps_find_virtualpkg_in_array_by_pattern(
rpi->rpi_repod, "packages", rpf->pattern); rpi->rpi_repo, rpf->pattern);
} }
} else { } else {
/* match by pkgname */ /* match by pkgname */
rpf->pkgd = xbps_find_pkg_in_dict_by_name(rpi->rpi_repod, rpf->pkgd = xbps_find_pkg_in_array_by_name(rpi->rpi_repo,
"packages", rpf->pattern); rpf->pattern);
/* If no pkg exists matching pattern, look for virtual packages */ /* If no pkg exists matching pattern, look for virtual packages */
if (rpf->pkgd == NULL) { if (rpf->pkgd == NULL) {
rpf->pkgd = xbps_find_virtualpkg_in_dict_by_name( rpf->pkgd = xbps_find_virtualpkg_in_array_by_name(
rpi->rpi_repod, "packages", rpf->pattern); rpi->rpi_repo, rpf->pattern);
} }
} }
if (rpf->pkgd) { if (rpf->pkgd) {
@ -136,11 +136,11 @@ repo_find_best_pkg_cb(struct repository_pool_index *rpi,
(void)done; (void)done;
if (rpf->bypattern) { if (rpf->bypattern) {
rpf->pkgd = xbps_find_pkg_in_dict_by_pattern(rpi->rpi_repod, rpf->pkgd = xbps_find_pkg_in_array_by_pattern(rpi->rpi_repo,
"packages", rpf->pattern); rpf->pattern);
} else { } else {
rpf->pkgd = xbps_find_pkg_in_dict_by_name(rpi->rpi_repod, rpf->pkgd = xbps_find_pkg_in_array_by_name(rpi->rpi_repo,
"packages", rpf->pattern); rpf->pattern);
} }
if (rpf->pkgd == NULL) { if (rpf->pkgd == NULL) {
if (errno && errno != ENOENT) if (errno && errno != ENOENT)

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009-2011 Juan Romero Pardines. * Copyright (c) 2009-2012 Juan Romero Pardines.
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -130,7 +130,7 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
goto out; goto out;
} }
/* /*
* Remote repository index.plist full URL. * Remote repository plist index full URL.
*/ */
rpidx = xbps_xasprintf("%s/%s", uri, plistf); rpidx = xbps_xasprintf("%s/%s", uri, plistf);
if (rpidx == NULL) { if (rpidx == NULL) {
@ -147,7 +147,8 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
goto out; goto out;
} }
/* /*
* Full path to repository directory to store the index.plist file. * Full path to repository directory to store the plist
* index file.
*/ */
lrepodir = xbps_xasprintf("%s/%s/%s", lrepodir = xbps_xasprintf("%s/%s/%s",
xhp->rootdir, XBPS_META_PATH, uri_fixedp); xhp->rootdir, XBPS_META_PATH, uri_fixedp);
@ -156,7 +157,7 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
goto out; goto out;
} }
/* /*
* If directory exists probably the index.plist file * If directory exists probably the plist index file
* was downloaded previously... * was downloaded previously...
*/ */
rv = stat(lrepodir, &st); rv = stat(lrepodir, &st);
@ -170,7 +171,7 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
xbps_set_cb_state(XBPS_STATE_REPOSYNC, 0, NULL, NULL, xbps_set_cb_state(XBPS_STATE_REPOSYNC, 0, NULL, NULL,
"Synchronizing index for `%s'...", uri); "Synchronizing index for `%s'...", uri);
/* /*
* Download index.plist file from repository. * Download plist index file from repository.
*/ */
if (xbps_fetch_file(rpidx, fetch_outputdir, true, NULL) == -1) { if (xbps_fetch_file(rpidx, fetch_outputdir, true, NULL) == -1) {
/* reposync error cb */ /* reposync error cb */
@ -206,7 +207,7 @@ xbps_repository_sync_pkg_index(const char *uri, const char *plistf)
goto out; goto out;
} }
/* /*
* Create local repodir to store index.plist file. * Create local repodir to store plist index file.
*/ */
if ((rv = xbps_mkpath(lrepodir, 0755)) == -1) { if ((rv = xbps_mkpath(lrepodir, 0755)) == -1) {
xbps_set_cb_state(XBPS_STATE_REPOSYNC_FAIL, errno, NULL, NULL, xbps_set_cb_state(XBPS_STATE_REPOSYNC_FAIL, errno, NULL, NULL,