diff --git a/include/xbps_api.h b/include/xbps_api.h index be491265..65f138c5 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -259,7 +259,6 @@ struct xbps_handle { * - Initialize the debug printfs. * - Internalize the proplib dictionary in config file. * - Internalize the regpkgdb dictionary (if available). - * - Initialize the repository pool interface (if available). * * @param[in] xh Pointer to an xbps_handle structure. It's * assumed that this pointer is not NULL. diff --git a/lib/initend.c b/lib/initend.c index c410a9de..03bcb5c4 100644 --- a/lib/initend.c +++ b/lib/initend.c @@ -123,20 +123,6 @@ xbps_init(struct xbps_handle *xh) xbps_dbg_printf("%s: fetch_timeout: %zu\n", __func__, xhp->fetch_timeout); - /* - * Initialize repository pool. - */ - if ((rv = xbps_repository_pool_init()) != 0) { - if (rv == ENOTSUP) { - xbps_dbg_printf("%s: empty repository list.\n", - __func__); - } else if (rv != ENOENT && rv != ENOTSUP) { - xbps_dbg_printf("%s: couldn't initialize " - "repository pool: %s\n", __func__, strerror(rv)); - xbps_end(); - return rv; - } - } /* * Initialize regpkgdb dictionary. */ diff --git a/lib/repository_pool.c b/lib/repository_pool.c index 64a6ffe4..8b0b54c4 100644 --- a/lib/repository_pool.c +++ b/lib/repository_pool.c @@ -111,7 +111,7 @@ xbps_repository_pool_init(void) xbps_printf("Synchronizing package index for " "`%s'...\n", repouri); rv = xbps_repository_sync_pkg_index(repouri); - if (rv != 0) { + if (rv == -1) { xbps_error_printf("failed to sync `%s'" ": %s %s\n", repouri, strerror(errno), @@ -225,7 +225,20 @@ xbps_repository_pool_foreach( bool done = false; assert(fn != NULL); - assert(repolist_initialized != false); + /* + * Initialize repository pool. + */ + if ((rv = xbps_repository_pool_init()) != 0) { + if (rv == ENOTSUP) { + xbps_dbg_printf("%s: empty repository list.\n", + __func__); + } else if (rv != ENOENT && rv != ENOTSUP) { + xbps_dbg_printf("%s: couldn't initialize " + "repository pool: %s\n", __func__, strerror(rv)); + } + xbps_end(); + return rv; + } SIMPLEQ_FOREACH_SAFE(rpool, &rpool_queue, rp_entries, rpool_new) { rv = (*fn)(rpool->rpi, arg, &done); @@ -356,7 +369,20 @@ xbps_repository_pool_find_pkg(const char *pkg, bool bypattern, bool best) int rv = 0; assert(pkg != NULL); - assert(repolist_initialized != false); + /* + * Initialize repository pool. + */ + if ((rv = xbps_repository_pool_init()) != 0) { + if (rv == ENOTSUP) { + xbps_dbg_printf("%s: empty repository list.\n", + __func__); + } else if (rv != ENOENT && rv != ENOTSUP) { + xbps_dbg_printf("%s: couldn't initialize " + "repository pool: %s\n", __func__, strerror(rv)); + } + xbps_end(); + return NULL; + } rpf = calloc(1, sizeof(*rpf)); if (rpf == NULL) @@ -417,7 +443,6 @@ xbps_repository_pool_dictionary_metadata_plist(const char *pkgname, assert(pkgname != NULL); assert(plistf != NULL); - assert(repolist_initialized != false); /* * Iterate over the the repository pool and search for a plist file