Rename struct repository_data to repository_pool.
--HG-- extra : convert_revision : xtraeme%40gmail.com-20091130112404-mlrt6x08thdvmrsn
This commit is contained in:
parent
91aeac4dad
commit
d90a248244
@ -71,7 +71,7 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
prop_dictionary_t pkgd;
|
||||
struct repository_data *rdata;
|
||||
struct repository_pool *rpool;
|
||||
char *root;
|
||||
int c, rv = 0;
|
||||
|
||||
@ -120,8 +120,8 @@ main(int argc, char **argv)
|
||||
if (argc != 1)
|
||||
usage();
|
||||
|
||||
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain)
|
||||
printf("%s\n", rdata->rd_uri);
|
||||
SIMPLEQ_FOREACH(rpool, &repopool_queue, chain)
|
||||
printf("%s\n", rpool->rp_uri);
|
||||
|
||||
} else if ((strcasecmp(argv[0], "rm") == 0) ||
|
||||
(strcasecmp(argv[0], "remove") == 0)) {
|
||||
@ -139,9 +139,9 @@ main(int argc, char **argv)
|
||||
if (argc != 2)
|
||||
usage();
|
||||
|
||||
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) {
|
||||
printf("From %s repository ...\n", rdata->rd_uri);
|
||||
(void)xbps_callback_array_iter_in_dict(rdata->rd_repod,
|
||||
SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
|
||||
printf("From %s repository ...\n", rpool->rp_uri);
|
||||
(void)xbps_callback_array_iter_in_dict(rpool->rp_repod,
|
||||
"packages", show_pkg_namedesc, argv[1]);
|
||||
}
|
||||
|
||||
|
@ -198,13 +198,13 @@ out:
|
||||
int
|
||||
show_pkg_info_from_repolist(const char *pkgname)
|
||||
{
|
||||
struct repository_data *rd;
|
||||
struct repository_pool *rd;
|
||||
prop_dictionary_t repo_pkgd, pkg_propsd;
|
||||
int rv = 0;
|
||||
|
||||
SIMPLEQ_FOREACH(rd, &repodata_queue, chain) {
|
||||
SIMPLEQ_FOREACH(rd, &repopool_queue, chain) {
|
||||
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);
|
||||
if (repo_pkgd == NULL) {
|
||||
if (errno && errno != ENOENT) {
|
||||
@ -213,12 +213,12 @@ show_pkg_info_from_repolist(const char *pkgname)
|
||||
}
|
||||
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) {
|
||||
rv = errno;
|
||||
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,
|
||||
XBPS_PKGPROPS);
|
||||
if (pkg_propsd == NULL) {
|
||||
@ -238,13 +238,13 @@ show_pkg_info_from_repolist(const char *pkgname)
|
||||
int
|
||||
show_pkg_deps_from_repolist(const char *pkgname)
|
||||
{
|
||||
struct repository_data *rd;
|
||||
struct repository_pool *rd;
|
||||
prop_dictionary_t pkgd;
|
||||
const char *ver;
|
||||
int rv = 0;
|
||||
|
||||
SIMPLEQ_FOREACH(rd, &repodata_queue, chain) {
|
||||
pkgd = xbps_find_pkg_in_dict(rd->rd_repod, "packages", pkgname);
|
||||
SIMPLEQ_FOREACH(rd, &repopool_queue, chain) {
|
||||
pkgd = xbps_find_pkg_in_dict(rd->rp_repod, "packages", pkgname);
|
||||
if (pkgd == NULL) {
|
||||
if (errno != ENOENT) {
|
||||
rv = errno;
|
||||
@ -257,7 +257,7 @@ show_pkg_deps_from_repolist(const char *pkgname)
|
||||
rv = errno;
|
||||
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,
|
||||
"run_depends", list_strings_sep_in_array, NULL);
|
||||
}
|
||||
@ -268,16 +268,16 @@ show_pkg_deps_from_repolist(const char *pkgname)
|
||||
int
|
||||
repository_sync(void)
|
||||
{
|
||||
struct repository_data *rd;
|
||||
struct repository_pool *rp;
|
||||
char *plist;
|
||||
int rv = 0;
|
||||
|
||||
SIMPLEQ_FOREACH(rd, &repodata_queue, chain) {
|
||||
if (!xbps_check_is_repo_string_remote(rd->rd_uri))
|
||||
SIMPLEQ_FOREACH(rp, &repopool_queue, chain) {
|
||||
if (!xbps_check_is_repo_string_remote(rp->rp_uri))
|
||||
continue;
|
||||
|
||||
printf("Syncing package index from: %s\n", rd->rd_uri);
|
||||
rv = xbps_repository_sync_pkg_index(rd->rd_uri);
|
||||
printf("Syncing package index from: %s\n", rp->rp_uri);
|
||||
rv = xbps_repository_sync_pkg_index(rp->rp_uri);
|
||||
if (rv == -1) {
|
||||
printf("Failed! returned: %s\n",
|
||||
xbps_fetch_error_string());
|
||||
@ -286,11 +286,11 @@ repository_sync(void)
|
||||
printf("Package index file is already up to date.\n");
|
||||
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;
|
||||
break;
|
||||
}
|
||||
(void)pkgindex_verify(plist, rd->rd_uri, true);
|
||||
(void)pkgindex_verify(plist, rp->rp_uri, true);
|
||||
free(plist);
|
||||
}
|
||||
|
||||
|
@ -213,12 +213,12 @@ prop_dictionary_t SYMEXPORT
|
||||
xbps_get_pkg_plist_dict_from_url(const char *, const char *);
|
||||
|
||||
/* From lib/repository_pool.c */
|
||||
struct repository_data {
|
||||
SIMPLEQ_ENTRY(repository_data) chain;
|
||||
prop_dictionary_t rd_repod;
|
||||
char *rd_uri;
|
||||
struct repository_pool {
|
||||
SIMPLEQ_ENTRY(repository_pool) chain;
|
||||
prop_dictionary_t rp_repod;
|
||||
char *rp_uri;
|
||||
};
|
||||
SYMEXPORT SIMPLEQ_HEAD(, repository_data) repodata_queue;
|
||||
SYMEXPORT SIMPLEQ_HEAD(, repository_pool) repopool_queue;
|
||||
|
||||
int SYMEXPORT xbps_repository_pool_init(void);
|
||||
void SYMEXPORT xbps_repository_pool_release(void);
|
||||
|
@ -240,7 +240,7 @@ int SYMEXPORT
|
||||
xbps_repository_find_pkg_deps(prop_dictionary_t master, prop_dictionary_t pkg)
|
||||
{
|
||||
prop_array_t pkg_rdeps, missing_rdeps;
|
||||
struct repository_data *rdata;
|
||||
struct repository_pool *rpool;
|
||||
const char *pkgname;
|
||||
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
|
||||
* all available binary packages.
|
||||
*/
|
||||
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) {
|
||||
SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
|
||||
/*
|
||||
* This will find direct and indirect deps,
|
||||
* if any of them is not there it will be added
|
||||
* into the missing_deps array.
|
||||
*/
|
||||
if ((rv = find_repo_deps(master, rdata->rd_repod,
|
||||
rdata->rd_uri, pkg_rdeps)) != 0) {
|
||||
if ((rv = find_repo_deps(master, rpool->rp_repod,
|
||||
rpool->rp_uri, pkg_rdeps)) != 0) {
|
||||
DPRINTF(("Error '%s' while checking rundeps!\n",
|
||||
strerror(rv)));
|
||||
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.
|
||||
*/
|
||||
DPRINTF(("Checking for missing deps in %s.\n", pkgname));
|
||||
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) {
|
||||
if ((rv = find_repo_deps(master, rdata->rd_repod,
|
||||
rdata->rd_uri, missing_rdeps)) != 0) {
|
||||
SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
|
||||
if ((rv = find_repo_deps(master, rpool->rp_repod,
|
||||
rpool->rp_uri, missing_rdeps)) != 0) {
|
||||
DPRINTF(("Error '%s' while checking for "
|
||||
"missing rundeps!\n", strerror(rv)));
|
||||
goto out;
|
||||
|
@ -159,7 +159,7 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg)
|
||||
{
|
||||
prop_dictionary_t pkgrd = NULL;
|
||||
prop_array_t unsorted;
|
||||
struct repository_data *rdata;
|
||||
struct repository_pool *rpool;
|
||||
const char *repover, *instver;
|
||||
int rv = 0;
|
||||
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)
|
||||
return rv;
|
||||
|
||||
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) {
|
||||
SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
|
||||
/*
|
||||
* Get the package dictionary from current 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);
|
||||
if (pkgrd == NULL) {
|
||||
if (errno && errno != ENOENT) {
|
||||
@ -186,7 +186,7 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg)
|
||||
break;
|
||||
}
|
||||
DPRINTF(("Package %s not found in repo %s.\n",
|
||||
pkgname, rdata->rd_uri));
|
||||
pkgname, rpool->rp_uri));
|
||||
} else if (pkgrd != NULL) {
|
||||
/*
|
||||
* 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) {
|
||||
DPRINTF(("Found %s-%s in repo %s.\n",
|
||||
pkgname, repover, rdata->rd_uri));
|
||||
pkgname, repover, rpool->rp_uri));
|
||||
newpkg_found = true;
|
||||
break;
|
||||
}
|
||||
DPRINTF(("Skipping %s-%s in repo %s.\n",
|
||||
pkgname, repover, rdata->rd_uri));
|
||||
pkgname, repover, rpool->rp_uri));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -231,7 +231,7 @@ xbps_repository_update_pkg(const char *pkgname, prop_dictionary_t instpkg)
|
||||
/*
|
||||
* 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;
|
||||
goto out;
|
||||
}
|
||||
@ -302,7 +302,7 @@ xbps_repository_install_pkg(const char *pkgname)
|
||||
{
|
||||
prop_dictionary_t origin_pkgrd = NULL, pkgrd = NULL;
|
||||
prop_array_t pkgs_array;
|
||||
struct repository_data *rdata;
|
||||
struct repository_pool *rpool;
|
||||
int rv = 0;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
@ -310,12 +310,12 @@ xbps_repository_install_pkg(const char *pkgname)
|
||||
if ((rv = xbps_repository_pool_init()) != 0)
|
||||
return rv;
|
||||
|
||||
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) {
|
||||
SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
|
||||
/*
|
||||
* Get the package dictionary from current 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);
|
||||
if (pkgrd == NULL) {
|
||||
if (errno && errno != ENOENT) {
|
||||
@ -339,7 +339,7 @@ xbps_repository_install_pkg(const char *pkgname)
|
||||
/*
|
||||
* 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;
|
||||
goto out;
|
||||
}
|
||||
|
@ -220,7 +220,7 @@ prop_dictionary_t SYMEXPORT
|
||||
xbps_get_pkg_plist_dict_from_repo(const char *pkgname, const char *plistf)
|
||||
{
|
||||
prop_dictionary_t plistd = NULL, pkgd;
|
||||
struct repository_data *rdata;
|
||||
struct repository_pool *rpool;
|
||||
char *url = NULL;
|
||||
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
|
||||
* libfetch!
|
||||
*/
|
||||
SIMPLEQ_FOREACH(rdata, &repodata_queue, chain) {
|
||||
pkgd = xbps_find_pkg_in_dict(rdata->rd_repod,
|
||||
SIMPLEQ_FOREACH(rpool, &repopool_queue, chain) {
|
||||
pkgd = xbps_find_pkg_in_dict(rpool->rp_repod,
|
||||
"packages", pkgname);
|
||||
if (pkgd == NULL) {
|
||||
if (errno != ENOENT)
|
||||
break;
|
||||
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)
|
||||
break;
|
||||
plistd = xbps_get_pkg_plist_dict_from_url(url, plistf);
|
||||
|
@ -41,7 +41,7 @@ xbps_repository_pool_init(void)
|
||||
prop_array_t array;
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter = NULL;
|
||||
struct repository_data *rdata;
|
||||
struct repository_pool *rpool;
|
||||
size_t ntotal = 0, nmissing = 0;
|
||||
char *plist;
|
||||
int rv = 0;
|
||||
@ -51,7 +51,7 @@ xbps_repository_pool_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SIMPLEQ_INIT(&repodata_queue);
|
||||
SIMPLEQ_INIT(&repopool_queue);
|
||||
|
||||
plist = xbps_xasprintf("%s/%s/%s", xbps_get_rootdir(),
|
||||
XBPS_META_PATH, XBPS_REPOLIST);
|
||||
@ -93,24 +93,24 @@ xbps_repository_pool_init(void)
|
||||
goto out;
|
||||
}
|
||||
|
||||
rdata = malloc(sizeof(struct repository_data));
|
||||
if (rdata == NULL) {
|
||||
rpool = malloc(sizeof(struct repository_pool));
|
||||
if (rpool == NULL) {
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
|
||||
rdata->rd_uri = prop_string_cstring(obj);
|
||||
if (rdata->rd_uri == NULL) {
|
||||
rpool->rp_uri = prop_string_cstring(obj);
|
||||
if (rpool->rp_uri == NULL) {
|
||||
free(plist);
|
||||
rv = errno;
|
||||
goto out;
|
||||
}
|
||||
rdata->rd_repod = prop_dictionary_internalize_from_file(plist);
|
||||
if (rdata->rd_repod == NULL) {
|
||||
rpool->rp_repod = prop_dictionary_internalize_from_file(plist);
|
||||
if (rpool->rp_repod == NULL) {
|
||||
free(plist);
|
||||
if (errno == ENOENT) {
|
||||
free(rdata->rd_uri);
|
||||
free(rdata);
|
||||
free(rpool->rp_uri);
|
||||
free(rpool);
|
||||
errno = 0;
|
||||
nmissing++;
|
||||
continue;
|
||||
@ -119,7 +119,7 @@ xbps_repository_pool_init(void)
|
||||
goto out;
|
||||
}
|
||||
free(plist);
|
||||
SIMPLEQ_INSERT_TAIL(&repodata_queue, rdata, chain);
|
||||
SIMPLEQ_INSERT_TAIL(&repopool_queue, rpool, chain);
|
||||
}
|
||||
|
||||
if (ntotal - nmissing == 0)
|
||||
@ -143,16 +143,16 @@ out:
|
||||
void SYMEXPORT
|
||||
xbps_repository_pool_release(void)
|
||||
{
|
||||
struct repository_data *rdata;
|
||||
struct repository_pool *rpool;
|
||||
|
||||
if (--repolist_refcnt > 0)
|
||||
return;
|
||||
|
||||
while ((rdata = SIMPLEQ_FIRST(&repodata_queue)) != NULL) {
|
||||
SIMPLEQ_REMOVE(&repodata_queue, rdata, repository_data, chain);
|
||||
prop_object_release(rdata->rd_repod);
|
||||
free(rdata->rd_uri);
|
||||
free(rdata);
|
||||
while ((rpool = SIMPLEQ_FIRST(&repopool_queue)) != NULL) {
|
||||
SIMPLEQ_REMOVE(&repopool_queue, rpool, repository_pool, chain);
|
||||
prop_object_release(rpool->rp_repod);
|
||||
free(rpool->rp_uri);
|
||||
free(rpool);
|
||||
}
|
||||
repolist_refcnt = 0;
|
||||
repolist_initialized = false;
|
||||
|
Loading…
Reference in New Issue
Block a user