diff --git a/NEWS b/NEWS index 244e123f..a05c1259 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,16 @@ xbps-0.38 (???): + * libxbps: return ENXIO and a meaningful error message if a package that is + going to be installed or updated has invalid dependencies, i.e: + + $ xbps-install --repository=$HOME/repo -n foo + ERROR: foo-1.0_1: can't guess pkgname for dependency '>=invalid-spec_1' + Package `foo' contains invalid dependencies, exiting. + $ + + This fixes #43 (xbps-install: unhelpful message for invalid dependency) + submitted by Dominik Honnef. + * libxbps: fixed a new issue with packages that provide/replace the same virtual package that is going to be replaced. The issue could be reproduced easily by installing any awk package (gawk, mawk, or nawk), diff --git a/bin/xbps-install/state_cb.c b/bin/xbps-install/state_cb.c index ba9accd3..d0aeb09c 100644 --- a/bin/xbps-install/state_cb.c +++ b/bin/xbps-install/state_cb.c @@ -159,8 +159,12 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused) } break; default: - xbps_dbg_printf(xscd->xhp, - "%s: unknown state %d\n", xscd->arg, xscd->state); + if (xscd->desc) + xbps_error_printf("%s\n", xscd->desc); + else + xbps_dbg_printf(xscd->xhp, + "%s: unknown state %d\n", xscd->arg, xscd->state); + break; } diff --git a/bin/xbps-install/transaction.c b/bin/xbps-install/transaction.c index 453bb13b..76429f59 100644 --- a/bin/xbps-install/transaction.c +++ b/bin/xbps-install/transaction.c @@ -224,6 +224,8 @@ install_new_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall) } else if (rv == ENOTSUP) { fprintf(stderr, "No repositories " "currently registered!\n"); + } else if (rv == ENXIO) { + fprintf(stderr, "Package `%s' contains invalid dependencies, exiting.\n", pkg); } else { fprintf(stderr, "Unexpected error: %s\n", strerror(rv)); diff --git a/include/xbps.h.in b/include/xbps.h.in index f4d88cba..cb67d323 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -48,7 +48,7 @@ * * This header documents the full API for the XBPS Library. */ -#define XBPS_API_VERSION "20140604" +#define XBPS_API_VERSION "20140702" #ifndef XBPS_VERSION #define XBPS_VERSION "UNSET" @@ -275,6 +275,7 @@ extern "C" { * - XBPS_STATE_UNPACK_FAIL: package unpack has failed. * - XBPS_STATE_REPOSYNC_FAIL: syncing remote repositories has failed. * - XBPS_STATE_REPO_KEY_IMPORT: repository is signed and needs to import pubkey. + * - XBPS_STATE_INVALID_DEP: package has an invalid dependency. */ typedef enum xbps_state { XBPS_STATE_UNKNOWN = 0, @@ -313,7 +314,8 @@ typedef enum xbps_state { XBPS_STATE_UNPACK_FAIL, XBPS_STATE_REPOSYNC_FAIL, XBPS_STATE_CONFIGURE_DONE, - XBPS_STATE_REPO_KEY_IMPORT + XBPS_STATE_REPO_KEY_IMPORT, + XBPS_STATE_INVALID_DEP } xbps_state_t; /** @@ -1035,6 +1037,7 @@ xbps_object_iterator_t xbps_array_iter_from_dict(xbps_dictionary_t dict, * @retval EEXIST Package is already installed (reinstall wasn't enabled). * @retval ENOENT Package not matched in repository pool. * @retval ENOTSUP No repositories are available. + * @retval ENXIO Package depends on invalid dependencies. * @retval EINVAL Any other error ocurred in the process. */ int xbps_transaction_install_pkg(struct xbps_handle *xhp, @@ -1051,6 +1054,11 @@ int xbps_transaction_install_pkg(struct xbps_handle *xhp, * @param[in] pkgname The package name to update. * * @return 0 on success, otherwise an errno value. + * @retval EEXIST Package is already up-to-date. + * @retval ENOENT Package not matched in repository pool. + * @retval ENOTSUP No repositories are available. + * @retval ENXIO Package depends on invalid dependencies. + * @retval EINVAL Any other error ocurred in the process. */ int xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkgname); @@ -1060,7 +1068,9 @@ int xbps_transaction_update_pkg(struct xbps_handle *xhp, const char *pkgname); * into the transaction dictionary. * * @param[in] xhp Pointer to the xbps_handle struct. + * * @return 0 on success, otherwise an errno value. + * @retval EEXIST All installed package are already up-to-date. */ int xbps_transaction_update_packages(struct xbps_handle *xhp); diff --git a/lib/repo_pkgdeps.c b/lib/repo_pkgdeps.c index 7a56b104..ca08d169 100644 --- a/lib/repo_pkgdeps.c +++ b/lib/repo_pkgdeps.c @@ -187,8 +187,10 @@ find_repo_deps(struct xbps_handle *xhp, } if (((pkgname = xbps_pkgpattern_name(reqpkg)) == NULL) && ((pkgname = xbps_pkg_name(reqpkg)) == NULL)) { - xbps_dbg_printf(xhp, "can't guess pkgname for %s\n", reqpkg); - rv = EINVAL; + xbps_dbg_printf(xhp, "%s: can't guess pkgname for dependency: %s\n", curpkg, reqpkg); + xbps_set_cb_state(xhp, XBPS_STATE_INVALID_DEP, ENXIO, NULL, + "%s: can't guess pkgname for dependency '%s'", curpkg, reqpkg); + rv = ENXIO; break; } /*