From 8081751f86987cb04e527e76de6915206b771e69 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Wed, 2 Sep 2015 18:56:20 +0200 Subject: [PATCH] libxbps: print in verbose mode what pkgs are added to the transaction. Useful to know why a transaction cannot be completed when there are unresolved reverse dependencies. Requested by @chris2. --- bin/xbps-install/state_cb.c | 4 ++++ include/xbps.h.in | 3 ++- include/xbps_api_impl.h | 2 +- lib/repo_pkgdeps.c | 4 ++-- lib/transaction_ops.c | 6 +++--- lib/transaction_store.c | 5 ++++- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/bin/xbps-install/state_cb.c b/bin/xbps-install/state_cb.c index 8fc35643..692fcbeb 100644 --- a/bin/xbps-install/state_cb.c +++ b/bin/xbps-install/state_cb.c @@ -65,6 +65,10 @@ state_cb(const struct xbps_state_cb_data *xscd, void *cbdata _unused) case XBPS_STATE_REPOSYNC: printf("[*] Updating `%s' ...\n", xscd->arg); break; + case XBPS_STATE_TRANS_ADDPKG: + if (xscd->xhp->flags & XBPS_FLAG_VERBOSE) + printf("%s\n", xscd->desc); + break; case XBPS_STATE_VERIFY: printf("%s\n", xscd->desc); break; diff --git a/include/xbps.h.in b/include/xbps.h.in index aa4e7fd6..3cda9ddd 100644 --- a/include/xbps.h.in +++ b/include/xbps.h.in @@ -327,7 +327,8 @@ typedef enum xbps_state { XBPS_STATE_SHOW_REMOVE_MSG, XBPS_STATE_UNPACK_FILE_PRESERVED, XBPS_STATE_PKGDB, - XBPS_STATE_PKGDB_DONE + XBPS_STATE_PKGDB_DONE, + XBPS_STATE_TRANS_ADDPKG } xbps_state_t; /** diff --git a/include/xbps_api_impl.h b/include/xbps_api_impl.h index 7c3d5b43..077abeff 100644 --- a/include/xbps_api_impl.h +++ b/include/xbps_api_impl.h @@ -129,7 +129,7 @@ bool HIDDEN xbps_transaction_shlibs(struct xbps_handle *, xbps_array_t, xbps_array_t); int HIDDEN xbps_transaction_init(struct xbps_handle *); int HIDDEN xbps_transaction_store(struct xbps_handle *, xbps_array_t, - xbps_dictionary_t, bool); + xbps_dictionary_t, const char *, bool); char HIDDEN *xbps_get_remote_repo_string(const char *); int HIDDEN xbps_repo_sync(struct xbps_handle *, const char *); int HIDDEN xbps_file_hash_check_dictionary(struct xbps_handle *, diff --git a/lib/repo_pkgdeps.c b/lib/repo_pkgdeps.c index 643cd904..1f864306 100644 --- a/lib/repo_pkgdeps.c +++ b/lib/repo_pkgdeps.c @@ -330,7 +330,7 @@ find_repo_deps(struct xbps_handle *xhp, * Package is on repo, add it into the transaction dictionary. */ xbps_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason); - rv = xbps_transaction_store(xhp, unsorted, curpkgd, true); + rv = xbps_transaction_store(xhp, unsorted, curpkgd, reason, true); if (rv != 0) { xbps_dbg_printf(xhp, "xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv)); break; @@ -359,7 +359,7 @@ find_repo_deps(struct xbps_handle *xhp, * Package is on repo, add it into the transaction dictionary. */ xbps_dictionary_set_cstring_nocopy(curpkgd, "transaction", reason); - rv = xbps_transaction_store(xhp, unsorted, curpkgd, true); + rv = xbps_transaction_store(xhp, unsorted, curpkgd, reason, true); if (rv != 0) { xbps_dbg_printf(xhp, "xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv)); break; diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index 46d129e8..cf3b882c 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -216,7 +216,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall, free(pkgname); return EINVAL; } - if ((rv = xbps_transaction_store(xhp, pkgs, pkg_repod, false)) != 0) { + if ((rv = xbps_transaction_store(xhp, pkgs, pkg_repod, reason, false)) != 0) { free(pkgname); return rv; } @@ -342,7 +342,7 @@ xbps_transaction_remove_pkg(struct xbps_handle *xhp, obj = xbps_array_get(orphans, i); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); xbps_dictionary_set_cstring_nocopy(obj, "transaction", "remove"); - if ((rv = xbps_transaction_store(xhp, pkgs, obj, false)) != 0) + if ((rv = xbps_transaction_store(xhp, pkgs, obj, "remove", false)) != 0) return EINVAL; xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver); } @@ -354,7 +354,7 @@ rmpkg: */ xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_set_cstring_nocopy(pkgd, "transaction", "remove"); - if ((rv = xbps_transaction_store(xhp, pkgs, pkgd, false)) != 0) + if ((rv = xbps_transaction_store(xhp, pkgs, pkgd, "remove", false)) != 0) return EINVAL; xbps_dbg_printf(xhp, "%s: added into transaction (remove).\n", pkgver); return rv; diff --git a/lib/transaction_store.c b/lib/transaction_store.c index 9fb16880..c38cb2fc 100644 --- a/lib/transaction_store.c +++ b/lib/transaction_store.c @@ -32,7 +32,7 @@ int HIDDEN xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs, - xbps_dictionary_t pkgd, bool autoinst) + xbps_dictionary_t pkgd, const char *tract, bool autoinst) { xbps_array_t replaces; const char *pkgver, *repo; @@ -70,6 +70,9 @@ xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs, if (!xbps_array_add(pkgs, pkgd)) return EINVAL; + xbps_set_cb_state(xhp, XBPS_STATE_TRANS_ADDPKG, 0, pkgver, + "Found %s (%s) in repository %s", pkgver, tract, repo); + xbps_dbg_printf(xhp, "Added `%s' into the dependency list (%s)\n", pkgver, repo);