Rename struct repository_data to repository_pool.

--HG--
extra : convert_revision : xtraeme%40gmail.com-20091130112404-mlrt6x08thdvmrsn
This commit is contained in:
Juan RP 2009-11-30 12:24:04 +01:00
parent 91aeac4dad
commit d90a248244
7 changed files with 66 additions and 66 deletions

View File

@ -71,7 +71,7 @@ int
main(int argc, char **argv) main(int argc, char **argv)
{ {
prop_dictionary_t pkgd; prop_dictionary_t pkgd;
struct repository_data *rdata; struct repository_pool *rpool;
char *root; char *root;
int c, rv = 0; int c, rv = 0;
@ -120,8 +120,8 @@ main(int argc, char **argv)
if (argc != 1) if (argc != 1)
usage(); usage();
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) SIMPLEQ_FOREACH(rpool, &repopool_queue, chain)
printf("%s\n", rdata->rd_uri); printf("%s\n", rpool->rp_uri);
} else if ((strcasecmp(argv[0], "rm") == 0) || } else if ((strcasecmp(argv[0], "rm") == 0) ||
(strcasecmp(argv[0], "remove") == 0)) { (strcasecmp(argv[0], "remove") == 0)) {
@ -139,9 +139,9 @@ main(int argc, char **argv)
if (argc != 2) if (argc != 2)
usage(); usage();
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) { SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
printf("From %s repository ...\n", rdata->rd_uri); printf("From %s repository ...\n", rpool->rp_uri);
(void)xbps_callback_array_iter_in_dict(rdata->rd_repod, (void)xbps_callback_array_iter_in_dict(rpool->rp_repod,
"packages", show_pkg_namedesc, argv[1]); "packages", show_pkg_namedesc, argv[1]);
} }

View File

@ -198,13 +198,13 @@ out:
int int
show_pkg_info_from_repolist(const char *pkgname) show_pkg_info_from_repolist(const char *pkgname)
{ {
struct repository_data *rd; struct repository_pool *rd;
prop_dictionary_t repo_pkgd, pkg_propsd; prop_dictionary_t repo_pkgd, pkg_propsd;
int rv = 0; int rv = 0;
SIMPLEQ_FOREACH(rd, &repodata_queue, chain) { SIMPLEQ_FOREACH(rd, &repopool_queue, chain) {
char *url = NULL; char *url = NULL;
repo_pkgd = xbps_find_pkg_in_dict(rd->rd_repod, repo_pkgd = xbps_find_pkg_in_dict(rd->rp_repod,
"packages", pkgname); "packages", pkgname);
if (repo_pkgd == NULL) { if (repo_pkgd == NULL) {
if (errno && errno != ENOENT) { if (errno && errno != ENOENT) {
@ -213,12 +213,12 @@ show_pkg_info_from_repolist(const char *pkgname)
} }
continue; continue;
} }
url = xbps_get_path_from_pkg_dict_repo(repo_pkgd, rd->rd_uri); url = xbps_get_path_from_pkg_dict_repo(repo_pkgd, rd->rp_uri);
if (url == NULL) { if (url == NULL) {
rv = errno; rv = errno;
break; break;
} }
printf("Fetching info from: %s\n", rd->rd_uri); printf("Fetching info from: %s\n", rd->rp_uri);
pkg_propsd = xbps_get_pkg_plist_dict_from_url(url, pkg_propsd = xbps_get_pkg_plist_dict_from_url(url,
XBPS_PKGPROPS); XBPS_PKGPROPS);
if (pkg_propsd == NULL) { if (pkg_propsd == NULL) {
@ -238,13 +238,13 @@ show_pkg_info_from_repolist(const char *pkgname)
int int
show_pkg_deps_from_repolist(const char *pkgname) show_pkg_deps_from_repolist(const char *pkgname)
{ {
struct repository_data *rd; struct repository_pool *rd;
prop_dictionary_t pkgd; prop_dictionary_t pkgd;
const char *ver; const char *ver;
int rv = 0; int rv = 0;
SIMPLEQ_FOREACH(rd, &repodata_queue, chain) { SIMPLEQ_FOREACH(rd, &repopool_queue, chain) {
pkgd = xbps_find_pkg_in_dict(rd->rd_repod, "packages", pkgname); pkgd = xbps_find_pkg_in_dict(rd->rp_repod, "packages", pkgname);
if (pkgd == NULL) { if (pkgd == NULL) {
if (errno != ENOENT) { if (errno != ENOENT) {
rv = errno; rv = errno;
@ -257,7 +257,7 @@ show_pkg_deps_from_repolist(const char *pkgname)
rv = errno; rv = errno;
break; break;
} }
printf("Repository %s [pkgver: %s]\n", rd->rd_uri, ver); printf("Repository %s [pkgver: %s]\n", rd->rp_uri, ver);
(void)xbps_callback_array_iter_in_dict(pkgd, (void)xbps_callback_array_iter_in_dict(pkgd,
"run_depends", list_strings_sep_in_array, NULL); "run_depends", list_strings_sep_in_array, NULL);
} }
@ -268,16 +268,16 @@ show_pkg_deps_from_repolist(const char *pkgname)
int int
repository_sync(void) repository_sync(void)
{ {
struct repository_data *rd; struct repository_pool *rp;
char *plist; char *plist;
int rv = 0; int rv = 0;
SIMPLEQ_FOREACH(rd, &repodata_queue, chain) { SIMPLEQ_FOREACH(rp, &repopool_queue, chain) {
if (!xbps_check_is_repo_string_remote(rd->rd_uri)) if (!xbps_check_is_repo_string_remote(rp->rp_uri))
continue; continue;
printf("Syncing package index from: %s\n", rd->rd_uri); printf("Syncing package index from: %s\n", rp->rp_uri);
rv = xbps_repository_sync_pkg_index(rd->rd_uri); rv = xbps_repository_sync_pkg_index(rp->rp_uri);
if (rv == -1) { if (rv == -1) {
printf("Failed! returned: %s\n", printf("Failed! returned: %s\n",
xbps_fetch_error_string()); xbps_fetch_error_string());
@ -286,11 +286,11 @@ repository_sync(void)
printf("Package index file is already up to date.\n"); printf("Package index file is already up to date.\n");
continue; continue;
} }
if ((plist = xbps_get_pkg_index_plist(rd->rd_uri)) == NULL) { if ((plist = xbps_get_pkg_index_plist(rp->rp_uri)) == NULL) {
rv = EINVAL; rv = EINVAL;
break; break;
} }
(void)pkgindex_verify(plist, rd->rd_uri, true); (void)pkgindex_verify(plist, rp->rp_uri, true);
free(plist); free(plist);
} }

View File

@ -213,12 +213,12 @@ prop_dictionary_t SYMEXPORT
xbps_get_pkg_plist_dict_from_url(const char *, const char *); xbps_get_pkg_plist_dict_from_url(const char *, const char *);
/* From lib/repository_pool.c */ /* From lib/repository_pool.c */
struct repository_data { struct repository_pool {
SIMPLEQ_ENTRY(repository_data) chain; SIMPLEQ_ENTRY(repository_pool) chain;
prop_dictionary_t rd_repod; prop_dictionary_t rp_repod;
char *rd_uri; char *rp_uri;
}; };
SYMEXPORT SIMPLEQ_HEAD(, repository_data) repodata_queue; SYMEXPORT SIMPLEQ_HEAD(, repository_pool) repopool_queue;
int SYMEXPORT xbps_repository_pool_init(void); int SYMEXPORT xbps_repository_pool_init(void);
void SYMEXPORT xbps_repository_pool_release(void); void SYMEXPORT xbps_repository_pool_release(void);

View File

@ -240,7 +240,7 @@ int SYMEXPORT
xbps_repository_find_pkg_deps(prop_dictionary_t master, prop_dictionary_t pkg) xbps_repository_find_pkg_deps(prop_dictionary_t master, prop_dictionary_t pkg)
{ {
prop_array_t pkg_rdeps, missing_rdeps; prop_array_t pkg_rdeps, missing_rdeps;
struct repository_data *rdata; struct repository_pool *rpool;
const char *pkgname; const char *pkgname;
int rv = 0; int rv = 0;
@ -262,14 +262,14 @@ xbps_repository_find_pkg_deps(prop_dictionary_t master, prop_dictionary_t pkg)
* Iterate over the repository pool and find out if we have * Iterate over the repository pool and find out if we have
* all available binary packages. * all available binary packages.
*/ */
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) { SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
/* /*
* This will find direct and indirect deps, * This will find direct and indirect deps,
* if any of them is not there it will be added * if any of them is not there it will be added
* into the missing_deps array. * into the missing_deps array.
*/ */
if ((rv = find_repo_deps(master, rdata->rd_repod, if ((rv = find_repo_deps(master, rpool->rp_repod,
rdata->rd_uri, pkg_rdeps)) != 0) { rpool->rp_uri, pkg_rdeps)) != 0) {
DPRINTF(("Error '%s' while checking rundeps!\n", DPRINTF(("Error '%s' while checking rundeps!\n",
strerror(rv))); strerror(rv)));
goto out; goto out;
@ -288,9 +288,9 @@ xbps_repository_find_pkg_deps(prop_dictionary_t master, prop_dictionary_t pkg)
* that were found in previous pass. * that were found in previous pass.
*/ */
DPRINTF(("Checking for missing deps in %s.\n", pkgname)); DPRINTF(("Checking for missing deps in %s.\n", pkgname));
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) { SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
if ((rv = find_repo_deps(master, rdata->rd_repod, if ((rv = find_repo_deps(master, rpool->rp_repod,
rdata->rd_uri, missing_rdeps)) != 0) { rpool->rp_uri, missing_rdeps)) != 0) {
DPRINTF(("Error '%s' while checking for " DPRINTF(("Error '%s' while checking for "
"missing rundeps!\n", strerror(rv))); "missing rundeps!\n", strerror(rv)));
goto out; goto out;

View File

@ -159,7 +159,7 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg)
{ {
prop_dictionary_t pkgrd = NULL; prop_dictionary_t pkgrd = NULL;
prop_array_t unsorted; prop_array_t unsorted;
struct repository_data *rdata; struct repository_pool *rpool;
const char *repover, *instver; const char *repover, *instver;
int rv = 0; int rv = 0;
bool newpkg_found = false; bool newpkg_found = false;
@ -173,12 +173,12 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg)
if ((rv = xbps_repository_pool_init()) != 0) if ((rv = xbps_repository_pool_init()) != 0)
return rv; return rv;
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) { SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
/* /*
* Get the package dictionary from current repository. * Get the package dictionary from current repository.
* If it's not there, pass to the next repository. * If it's not there, pass to the next repository.
*/ */
pkgrd = xbps_find_pkg_in_dict(rdata->rd_repod, pkgrd = xbps_find_pkg_in_dict(rpool->rp_repod,
"packages", pkgname); "packages", pkgname);
if (pkgrd == NULL) { if (pkgrd == NULL) {
if (errno && errno != ENOENT) { if (errno && errno != ENOENT) {
@ -186,7 +186,7 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg)
break; break;
} }
DPRINTF(("Package %s not found in repo %s.\n", DPRINTF(("Package %s not found in repo %s.\n",
pkgname, rdata->rd_uri)); pkgname, rpool->rp_uri));
} else if (pkgrd != NULL) { } else if (pkgrd != NULL) {
/* /*
* Check if version in repository is greater than * Check if version in repository is greater than
@ -204,12 +204,12 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg)
} }
if (xbps_cmpver(repover, instver) > 0) { if (xbps_cmpver(repover, instver) > 0) {
DPRINTF(("Found %s-%s in repo %s.\n", DPRINTF(("Found %s-%s in repo %s.\n",
pkgname, repover, rdata->rd_uri)); pkgname, repover, rpool->rp_uri));
newpkg_found = true; newpkg_found = true;
break; break;
} }
DPRINTF(("Skipping %s-%s in repo %s.\n", DPRINTF(("Skipping %s-%s in repo %s.\n",
pkgname, repover, rdata->rd_uri)); pkgname, repover, rpool->rp_uri));
continue; continue;
} }
} }
@ -231,7 +231,7 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg)
/* /*
* Set repository in pkg dictionary. * Set repository in pkg dictionary.
*/ */
if (!prop_dictionary_set_cstring(pkgrd, "repository", rdata->rd_uri)) { if (!prop_dictionary_set_cstring(pkgrd, "repository", rpool->rp_uri)) {
rv = errno; rv = errno;
goto out; goto out;
} }
@ -302,7 +302,7 @@ xbps_repository_install_pkg(const char *pkgname)
{ {
prop_dictionary_t origin_pkgrd = NULL, pkgrd = NULL; prop_dictionary_t origin_pkgrd = NULL, pkgrd = NULL;
prop_array_t pkgs_array; prop_array_t pkgs_array;
struct repository_data *rdata; struct repository_pool *rpool;
int rv = 0; int rv = 0;
assert(pkgname != NULL); assert(pkgname != NULL);
@ -310,12 +310,12 @@ xbps_repository_install_pkg(const char *pkgname)
if ((rv = xbps_repository_pool_init()) != 0) if ((rv = xbps_repository_pool_init()) != 0)
return rv; return rv;
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) { SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
/* /*
* Get the package dictionary from current repository. * Get the package dictionary from current repository.
* If it's not there, pass to the next repository. * If it's not there, pass to the next repository.
*/ */
pkgrd = xbps_find_pkg_in_dict(rdata->rd_repod, pkgrd = xbps_find_pkg_in_dict(rpool->rp_repod,
"packages", pkgname); "packages", pkgname);
if (pkgrd == NULL) { if (pkgrd == NULL) {
if (errno && errno != ENOENT) { if (errno && errno != ENOENT) {
@ -339,7 +339,7 @@ xbps_repository_install_pkg(const char *pkgname)
/* /*
* Set repository in pkg dictionary. * Set repository in pkg dictionary.
*/ */
if (!prop_dictionary_set_cstring(pkgrd, "repository", rdata->rd_uri)) { if (!prop_dictionary_set_cstring(pkgrd, "repository", rpool->rp_uri)) {
rv = errno; rv = errno;
goto out; goto out;
} }

View File

@ -220,7 +220,7 @@ prop_dictionary_t SYMEXPORT
xbps_get_pkg_plist_dict_from_repo(const char *pkgname, const char *plistf) xbps_get_pkg_plist_dict_from_repo(const char *pkgname, const char *plistf)
{ {
prop_dictionary_t plistd = NULL, pkgd; prop_dictionary_t plistd = NULL, pkgd;
struct repository_data *rdata; struct repository_pool *rpool;
char *url = NULL; char *url = NULL;
int rv = 0; int rv = 0;
@ -238,15 +238,15 @@ xbps_get_pkg_plist_dict_from_repo(const char *pkgname, const char *plistf)
* This will work locally and remotely, thanks to libarchive and * This will work locally and remotely, thanks to libarchive and
* libfetch! * libfetch!
*/ */
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) { SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
pkgd = xbps_find_pkg_in_dict(rdata->rd_repod, pkgd = xbps_find_pkg_in_dict(rpool->rp_repod,
"packages", pkgname); "packages", pkgname);
if (pkgd == NULL) { if (pkgd == NULL) {
if (errno != ENOENT) if (errno != ENOENT)
break; break;
continue; continue;
} }
url = xbps_get_path_from_pkg_dict_repo(pkgd, rdata->rd_uri); url = xbps_get_path_from_pkg_dict_repo(pkgd, rpool->rp_uri);
if (url == NULL) if (url == NULL)
break; break;
plistd = xbps_get_pkg_plist_dict_from_url(url, plistf); plistd = xbps_get_pkg_plist_dict_from_url(url, plistf);

View File

@ -41,7 +41,7 @@ xbps_repository_pool_init(void)
prop_array_t array; prop_array_t array;
prop_object_t obj; prop_object_t obj;
prop_object_iterator_t iter = NULL; prop_object_iterator_t iter = NULL;
struct repository_data *rdata; struct repository_pool *rpool;
size_t ntotal = 0, nmissing = 0; size_t ntotal = 0, nmissing = 0;
char *plist; char *plist;
int rv = 0; int rv = 0;
@ -51,7 +51,7 @@ xbps_repository_pool_init(void)
return 0; return 0;
} }
SIMPLEQ_INIT(&repodata_queue); SIMPLEQ_INIT(&repopool_queue);
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(), plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
XBPS_META_PATH, XBPS_REPOLIST); XBPS_META_PATH, XBPS_REPOLIST);
@ -93,24 +93,24 @@ xbps_repository_pool_init(void)
goto out; goto out;
} }
rdata = malloc(sizeof(struct repository_data)); rpool = malloc(sizeof(struct repository_pool));
if (rdata == NULL) { if (rpool == NULL) {
rv = errno; rv = errno;
goto out; goto out;
} }
rdata->rd_uri = prop_string_cstring(obj); rpool->rp_uri = prop_string_cstring(obj);
if (rdata->rd_uri == NULL) { if (rpool->rp_uri == NULL) {
free(plist); free(plist);
rv = errno; rv = errno;
goto out; goto out;
} }
rdata->rd_repod = prop_dictionary_internalize_from_file(plist); rpool->rp_repod = prop_dictionary_internalize_from_file(plist);
if (rdata->rd_repod == NULL) { if (rpool->rp_repod == NULL) {
free(plist); free(plist);
if (errno == ENOENT) { if (errno == ENOENT) {
free(rdata->rd_uri); free(rpool->rp_uri);
free(rdata); free(rpool);
errno = 0; errno = 0;
nmissing++; nmissing++;
continue; continue;
@ -119,7 +119,7 @@ xbps_repository_pool_init(void)
goto out; goto out;
} }
free(plist); free(plist);
SIMPLEQ_INSERT_TAIL(&repodata_queue, rdata, chain); SIMPLEQ_INSERT_TAIL(&repopool_queue, rpool, chain);
} }
if (ntotal - nmissing == 0) if (ntotal - nmissing == 0)
@ -143,16 +143,16 @@ out:
void SYMEXPORT void SYMEXPORT
xbps_repository_pool_release(void) xbps_repository_pool_release(void)
{ {
struct repository_data *rdata; struct repository_pool *rpool;
if (--repolist_refcnt > 0) if (--repolist_refcnt > 0)
return; return;
while ((rdata = SIMPLEQ_FIRST(&repodata_queue)) != NULL) { while ((rpool = SIMPLEQ_FIRST(&repopool_queue)) != NULL) {
SIMPLEQ_REMOVE(&repodata_queue, rdata, repository_data, chain); SIMPLEQ_REMOVE(&repopool_queue, rpool, repository_pool, chain);
prop_object_release(rdata->rd_repod); prop_object_release(rpool->rp_repod);
free(rdata->rd_uri); free(rpool->rp_uri);
free(rdata); free(rpool);
} }
repolist_refcnt = 0; repolist_refcnt = 0;
repolist_initialized = false; repolist_initialized = false;