diff --git a/bin/xbps-install/main.c b/bin/xbps-install/main.c index 221a5ad96..97f8c2ab0 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)) != 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) { fprintf(stderr, "Failed to initialize rpool: %s\n", diff --git a/include/xbps.h.in b/include/xbps.h.in index 54b50a813..ddf9b1996 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -1462,8 +1462,9 @@ void xbps_rpool_release(struct xbps_handle *xhp); * * @param[in] xhp Pointer to the xbps_handle struct. * - * @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); diff --git a/lib/rpool.c b/lib/rpool.c index 503cbe264..167afd8ba 100644 --- a/lib/rpool.c +++ b/lib/rpool.c @@ -62,6 +62,9 @@ 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 (xbps_repo_sync(xhp, repouri) == -1) {