diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index c626d407b..3fc0a4393 100644 --- a/bin/xbps-install/main.c +++ b/bin/xbps-install/main.c @@ -233,8 +233,11 @@ main(int argc, char **argv) /* Sync remote repository data and import keys from remote repos */ if (syncf && !drun) { - if ((rv = xbps_rpool_sync(&xh, NULL)) != 0) - exit(rv); + if ((rv = xbps_rpool_sync(&xh)) < 0) { + fprintf(stderr, "Failed to sync repository pool: %s\n", + strerror(-rv)); + exit(-rv); + } rv = xbps_rpool_foreach(&xh, repo_import_key_cb, NULL); if (rv != 0) exit(rv); diff --git a/bin/xbps-query/list.c b/bin/xbps-query/list.c index 6deaf1a1e..fc7d4906a 100644 --- a/bin/xbps-query/list.c +++ b/bin/xbps-query/list.c @@ -213,7 +213,7 @@ repo_list(struct xbps_handle *xhp) int rv; rv = xbps_rpool_foreach(xhp, repo_list_uri_cb, NULL); - if (rv != 0 && rv != ENOTSUP) { + if (rv != 0) { fprintf(stderr, "Failed to initialize rpool: %s\n", strerror(rv)); return rv; diff --git a/bin/xbps-query/ownedby.c b/bin/xbps-query/ownedby.c index 1b95d3612..a2a5acfe6 100644 --- a/bin/xbps-query/ownedby.c +++ b/bin/xbps-query/ownedby.c @@ -188,8 +188,13 @@ ownedby(struct xbps_handle *xhp, const char *pat, bool repo, bool regex) if (regex) { ffd.rematch = true; - if (regcomp(&ffd.regex, ffd.pat, REG_EXTENDED|REG_NOSUB|REG_ICASE) != 0) + rv = regcomp(&ffd.regex, ffd.pat, REG_EXTENDED|REG_NOSUB|REG_ICASE); + if (rv != 0) { + char errbuf[256]; + regerror(rv, &ffd.regex, errbuf, sizeof(errbuf)); + fprintf(stderr, "Failed to compile pattern: %s\n", errbuf); return EINVAL; + } } if (repo) rv = xbps_rpool_foreach(xhp, repo_ownedby_cb, &ffd); diff --git a/bin/xbps-query/search.c b/bin/xbps-query/search.c index bfc1a3962..85b3411ea 100644 --- a/bin/xbps-query/search.c +++ b/bin/xbps-query/search.c @@ -229,9 +229,15 @@ search(struct xbps_handle *xhp, bool repo_mode, const char *pat, const char *pro sd.regex = regex; if (regex) { - if (regcomp(&sd.regexp, pat, REG_EXTENDED|REG_NOSUB|REG_ICASE) != 0) - return errno; + rv = regcomp(&sd.regexp, pat, REG_EXTENDED|REG_NOSUB|REG_ICASE); + if (rv != 0) { + char errbuf[256]; + regerror(rv, &sd.regexp, errbuf, sizeof(errbuf)); + fprintf(stderr, "Failed to compile pattern: %s\n", errbuf); + return EINVAL; + } } + sd.repo_mode = repo_mode; sd.pat = pat; sd.prop = prop; @@ -246,7 +252,7 @@ search(struct xbps_handle *xhp, bool repo_mode, const char *pat, const char *pro if (repo_mode) { rv = xbps_rpool_foreach(xhp, search_repo_cb, &sd); - if (rv != 0 && rv != ENOTSUP) { + if (rv != 0) { fprintf(stderr, "Failed to initialize rpool: %s\n", strerror(rv)); return rv; diff --git a/include/xbps.h.in b/include/xbps.h.in index 23f73b213..375141c1a 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -1458,16 +1458,15 @@ void xbps_rpool_release(struct xbps_handle *xhp); /** * Synchronizes repository data for all remote repositories - * as specified in the configuration file or if \a uri argument is - * set, just sync for that repository. + * as specified in the configuration file. * * @param[in] xhp Pointer to the xbps_handle struct. - * @param[in] uri Repository URI to match for sync (optional). * - * @return 0 on success, ENOTSUP if no repositories were found in + * @return 0 on success or a negative errno otherwise. * the configuration file. + * @retval -ENOENT There are no repositories to sync. */ -int xbps_rpool_sync(struct xbps_handle *xhp, const char *uri); +int xbps_rpool_sync(struct xbps_handle *xhp); /** * Iterates over the repository pool and executes the \a fn function diff --git a/lib/rpool.c b/lib/rpool.c index 70e571262..167afd8ba 100644 --- a/lib/rpool.c +++ b/lib/rpool.c @@ -58,16 +58,15 @@ static SIMPLEQ_HEAD(rpool_head, xbps_repo) rpool_queue = */ int -xbps_rpool_sync(struct xbps_handle *xhp, const char *uri) +xbps_rpool_sync(struct xbps_handle *xhp) { const char *repouri = NULL; + if (xbps_array_count(xhp->repositories) == 0) + return -ENOENT; + for (unsigned int i = 0; i < xbps_array_count(xhp->repositories); i++) { xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri); - /* If argument was set just process that repository */ - if (uri && strcmp(repouri, uri)) - continue; - if (xbps_repo_sync(xhp, repouri) == -1) { xbps_dbg_printf(xhp, "[rpool] `%s' failed to fetch repository data: %s\n", @@ -142,7 +141,7 @@ xbps_rpool_foreach(struct xbps_handle *xhp, struct xbps_repo *repo = NULL; const char *repouri = NULL; int rv = 0; - bool foundrepo = false, done = false; + bool done = false; unsigned int n = 0; assert(fn != NULL); @@ -160,13 +159,10 @@ xbps_rpool_foreach(struct xbps_handle *xhp, SIMPLEQ_INSERT_TAIL(&rpool_queue, repo, entries); xbps_dbg_printf(xhp, "[rpool] `%s' registered.\n", repouri); } - foundrepo = true; rv = (*fn)(repo, arg, &done); if (rv != 0 || done) break; } - if (!foundrepo) - rv = ENOTSUP; return rv; }