Fix #43 (xbps-install: unhelpful message for invalid dependency)

If a package that is going to be installed or updated contains invalid
dependencies return ENXIO and XBPS_STATE_INVALID_DEP xbps state to clients.

This improves the error messages returned to the clients when such
condition happens.
This commit is contained in:
Juan RP 2014-07-02 10:59:25 +02:00
parent 21f32a75c5
commit e60677116d
5 changed files with 35 additions and 6 deletions

11
NEWS
View File

@ -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),

View File

@ -159,8 +159,12 @@ state_cb(struct xbps_state_cb_data *xscd, void *cbdata _unused)
}
break;
default:
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;
}

View File

@ -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));

View File

@ -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);

View File

@ -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;
}
/*