lib/repo: add xbps_repo_remove and use it in xbps_rpool_foreach
https://github.com/void-linux/xbps/issues/3
This commit is contained in:
parent
2ae5dc304b
commit
b2f5afd02e
@ -48,7 +48,7 @@
|
|||||||
*
|
*
|
||||||
* This header documents the full API for the XBPS Library.
|
* This header documents the full API for the XBPS Library.
|
||||||
*/
|
*/
|
||||||
#define XBPS_API_VERSION "20190614"
|
#define XBPS_API_VERSION "20190615"
|
||||||
|
|
||||||
#ifndef XBPS_VERSION
|
#ifndef XBPS_VERSION
|
||||||
#define XBPS_VERSION "UNSET"
|
#define XBPS_VERSION "UNSET"
|
||||||
@ -1476,6 +1476,16 @@ xbps_dictionary_t xbps_rpool_get_pkg_plist(struct xbps_handle *xhp,
|
|||||||
*/
|
*/
|
||||||
bool xbps_repo_store(struct xbps_handle *xhp, const char *url);
|
bool xbps_repo_store(struct xbps_handle *xhp, const char *url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes repository \a url from the repository pool.
|
||||||
|
*
|
||||||
|
* @param[in] xhp Pointer to the xbps_handle struct.
|
||||||
|
* @param[in] uri Repository URI to remove.
|
||||||
|
*
|
||||||
|
* @return True on success, false otherwise.
|
||||||
|
*/
|
||||||
|
bool xbps_repo_remove(struct xbps_handle *xhp, const char *url);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a lock for a local repository to obtain exclusive access (write).
|
* Creates a lock for a local repository to obtain exclusive access (write).
|
||||||
*
|
*
|
||||||
|
23
lib/repo.c
23
lib/repo.c
@ -294,6 +294,29 @@ xbps_repo_store(struct xbps_handle *xhp, const char *repo)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
xbps_repo_remove(struct xbps_handle *xhp, const char *repo)
|
||||||
|
{
|
||||||
|
char *url;
|
||||||
|
bool rv = false;
|
||||||
|
|
||||||
|
assert(xhp);
|
||||||
|
assert(repo);
|
||||||
|
|
||||||
|
if (xhp->repositories == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
url = strdup(repo);
|
||||||
|
if (xbps_remove_string_from_array(xhp->repositories, repo)) {
|
||||||
|
if (url)
|
||||||
|
xbps_dbg_printf(xhp, "[repo] `%s' removed\n", url);
|
||||||
|
rv = true;
|
||||||
|
}
|
||||||
|
free(url);
|
||||||
|
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
struct xbps_repo *
|
struct xbps_repo *
|
||||||
xbps_repo_stage_open(struct xbps_handle *xhp, const char *url)
|
xbps_repo_stage_open(struct xbps_handle *xhp, const char *url)
|
||||||
{
|
{
|
||||||
|
@ -148,8 +148,10 @@ xbps_rpool_foreach(struct xbps_handle *xhp,
|
|||||||
xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri);
|
xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri);
|
||||||
if ((repo = xbps_rpool_get_repo(repouri)) == NULL) {
|
if ((repo = xbps_rpool_get_repo(repouri)) == NULL) {
|
||||||
repo = xbps_repo_open(xhp, repouri);
|
repo = xbps_repo_open(xhp, repouri);
|
||||||
if (!repo)
|
if (!repo) {
|
||||||
|
xbps_repo_remove(xhp, repouri);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
SIMPLEQ_INSERT_TAIL(&rpool_queue, repo, entries);
|
SIMPLEQ_INSERT_TAIL(&rpool_queue, repo, entries);
|
||||||
xbps_dbg_printf(xhp, "[rpool] `%s' registered.\n", repouri);
|
xbps_dbg_printf(xhp, "[rpool] `%s' registered.\n", repouri);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user