Skip to content

Commit 82e8acd

Browse files
committed
lib/rpool.c: xbps_rpool_sync: return error if there are no repos
1 parent e216133 commit 82e8acd

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

bin/xbps-install/main.c

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

234234
/* Sync remote repository data and import keys from remote repos */
235235
if (syncf && !drun) {
236-
if ((rv = xbps_rpool_sync(&xh)) != 0)
237-
exit(rv);
236+
if ((rv = xbps_rpool_sync(&xh)) < 0) {
237+
fprintf(stderr, "Failed to sync repository pool: %s\n",
238+
strerror(-rv));
239+
exit(-rv);
240+
}
238241
rv = xbps_rpool_foreach(&xh, repo_import_key_cb, NULL);
239242
if (rv != 0)
240243
exit(rv);

include/xbps.h.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,8 +1462,9 @@ void xbps_rpool_release(struct xbps_handle *xhp);
14621462
*
14631463
* @param[in] xhp Pointer to the xbps_handle struct.
14641464
*
1465-
* @return 0 on success, ENOTSUP if no repositories were found in
1465+
* @return 0 on success or a negative errno otherwise.
14661466
* the configuration file.
1467+
* @retval -ENOENT There are no repositories to sync.
14671468
*/
14681469
int xbps_rpool_sync(struct xbps_handle *xhp);
14691470

lib/rpool.c

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

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

0 commit comments

Comments
 (0)