Skip to content

Commit

Permalink
lib/rpool.c: xbps_rpool_sync: return error if there are no repos
Browse files Browse the repository at this point in the history
  • Loading branch information
Duncaen committed Dec 29, 2021
1 parent 0412733 commit adae0d1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 5 additions & 2 deletions bin/xbps-install/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion include/xbps.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions lib/rpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit adae0d1

Please sign in to comment.