xbps_repository_pool_init: ignore invalid repositories if always there
is one that is working, otherwise report an error. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091126204146-ikfwi8zvag1s3446
This commit is contained in:
parent
30fc7b050a
commit
0173a28aa2
@ -40,8 +40,9 @@ xbps_repository_pool_init(void)
|
|||||||
prop_dictionary_t dict = NULL;
|
prop_dictionary_t dict = NULL;
|
||||||
prop_array_t array;
|
prop_array_t array;
|
||||||
prop_object_t obj;
|
prop_object_t obj;
|
||||||
prop_object_iterator_t iter;
|
prop_object_iterator_t iter = NULL;
|
||||||
struct repository_data *rdata;
|
struct repository_data *rdata;
|
||||||
|
size_t ntotal = 0, nmissing = 0;
|
||||||
char *plist;
|
char *plist;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
@ -69,17 +70,18 @@ xbps_repository_pool_init(void)
|
|||||||
|
|
||||||
array = prop_dictionary_get(dict, "repository-list");
|
array = prop_dictionary_get(dict, "repository-list");
|
||||||
if (array == NULL) {
|
if (array == NULL) {
|
||||||
rv = EINVAL;
|
rv = errno;
|
||||||
goto out1;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
iter = prop_array_iterator(array);
|
iter = prop_array_iterator(array);
|
||||||
if (iter == NULL) {
|
if (iter == NULL) {
|
||||||
rv = ENOMEM;
|
rv = errno;
|
||||||
goto out1;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||||
|
ntotal++;
|
||||||
/*
|
/*
|
||||||
* Iterate over the repository pool and add the dictionary
|
* Iterate over the repository pool and add the dictionary
|
||||||
* for current repository into the queue.
|
* for current repository into the queue.
|
||||||
@ -88,39 +90,51 @@ xbps_repository_pool_init(void)
|
|||||||
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
|
||||||
if (plist == NULL) {
|
if (plist == NULL) {
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out2;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rdata = malloc(sizeof(struct repository_data));
|
rdata = malloc(sizeof(struct repository_data));
|
||||||
if (rdata == NULL) {
|
if (rdata == NULL) {
|
||||||
rv = errno;
|
rv = errno;
|
||||||
goto out2;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
rdata->rd_uri = prop_string_cstring(obj);
|
rdata->rd_uri = prop_string_cstring(obj);
|
||||||
if (rdata->rd_uri == NULL) {
|
if (rdata->rd_uri == NULL) {
|
||||||
free(plist);
|
free(plist);
|
||||||
rv = EINVAL;
|
rv = errno;
|
||||||
goto out2;
|
goto out;
|
||||||
}
|
}
|
||||||
rdata->rd_repod = prop_dictionary_internalize_from_file(plist);
|
rdata->rd_repod = prop_dictionary_internalize_from_file(plist);
|
||||||
if (rdata->rd_repod == NULL) {
|
if (rdata->rd_repod == NULL) {
|
||||||
free(plist);
|
free(plist);
|
||||||
|
if (errno == ENOENT) {
|
||||||
|
free(rdata->rd_uri);
|
||||||
|
free(rdata);
|
||||||
|
errno = 0;
|
||||||
|
nmissing++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
rv = errno;
|
rv = errno;
|
||||||
goto out2;
|
goto out;
|
||||||
}
|
}
|
||||||
free(plist);
|
free(plist);
|
||||||
SIMPLEQ_INSERT_TAIL(&repodata_queue, rdata, chain);
|
SIMPLEQ_INSERT_TAIL(&repodata_queue, rdata, chain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ntotal - nmissing == 0) {
|
||||||
|
rv = EINVAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
repolist_initialized = true;
|
repolist_initialized = true;
|
||||||
repolist_refcnt = 1;
|
repolist_refcnt = 1;
|
||||||
DPRINTF(("%s: initialized ok.\n", __func__));
|
DPRINTF(("%s: initialized ok.\n", __func__));
|
||||||
out2:
|
|
||||||
prop_object_iterator_release(iter);
|
|
||||||
out1:
|
|
||||||
prop_object_release(dict);
|
|
||||||
out:
|
out:
|
||||||
|
if (iter)
|
||||||
|
prop_object_iterator_release(iter);
|
||||||
|
if (dict)
|
||||||
|
prop_object_release(dict);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
xbps_repository_pool_release();
|
xbps_repository_pool_release();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user