Skip to content

Commit 77fc4b4

Browse files
committed
lib/rpool.c: xbps_rpool_sync: return error if there are no repos
1 parent fbc5777 commit 77fc4b4

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

bin/xbps-install/main.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,11 @@ main(int argc, char **argv)
238238

239239
/* Sync remote repository data and import keys from remote repos */
240240
if (syncf && !drun) {
241-
if ((rv = xbps_rpool_sync(&xh)) != 0)
242-
exit(rv);
241+
if ((rv = xbps_rpool_sync(&xh)) < 0) {
242+
fprintf(stderr, "Failed to sync repository pool: %s\n",
243+
strerror(-rv));
244+
exit(-rv);
245+
}
243246
rv = xbps_rpool_foreach(&xh, repo_import_key_cb, NULL);
244247
if (rv != 0)
245248
exit(rv);

include/xbps.h.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,8 +1486,8 @@ void xbps_rpool_release(struct xbps_handle *xhp);
14861486
*
14871487
* @param[in] xhp Pointer to the xbps_handle struct.
14881488
*
1489-
* @return 0 on success, ENOTSUP if no repositories were found in
1490-
* the configuration file.
1489+
* @return 0 on success or a negative errno otherwise.
1490+
* @retval -ENOENT There are no repositories to sync.
14911491
*/
14921492
int xbps_rpool_sync(struct xbps_handle *xhp);
14931493

lib/rpool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ xbps_rpool_sync(struct xbps_handle *xhp)
6363
{
6464
const char *repouri = NULL;
6565

66+
if (xbps_array_count(xhp->repositories) == 0)
67+
return -ENOENT;
68+
6669
for (unsigned int i = 0; i < xbps_array_count(xhp->repositories); i++) {
6770
xbps_array_get_cstring_nocopy(xhp->repositories, i, &repouri);
6871
if (xbps_repo_sync(xhp, repouri) == -1) {

0 commit comments

Comments
 (0)