From 742af691855c3115c49a6f05ab39039a244d4cc1 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 29 Sep 2014 15:25:09 +0200 Subject: [PATCH] Fix libxbps/update_shlibs:shlib_bump_revdep_diff test. How to reproduce it: - A-1.0_1 provides liba.so.1 - B-1.0_1 provides libb.so.1 - C-1.0_1 requires liba.so.1 and libb.so.1 - A-2.0_1 provides liba.so.2 - C-2.0_1 required liba.so.2 This test case failed because it was checking the required shared libraries from current installed package, rather than the updated pkg in transaction. --- lib/transaction_shlibs.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/lib/transaction_shlibs.c b/lib/transaction_shlibs.c index a1fb2d08..913dd9f6 100644 --- a/lib/transaction_shlibs.c +++ b/lib/transaction_shlibs.c @@ -72,7 +72,7 @@ shlib_trans_matched(struct xbps_handle *xhp, const char *pkgver, const char *shl } static bool -shlib_matched(struct xbps_handle *xhp, xbps_array_t mshlibs, +shlib_matched(struct xbps_handle *xhp, xbps_array_t unsorted, xbps_array_t mshlibs, const char *pkgver, const char *shlib) { xbps_array_t revdeps; @@ -96,10 +96,29 @@ shlib_matched(struct xbps_handle *xhp, xbps_array_t mshlibs, for (unsigned int i = 0; i < xbps_array_count(revdeps); i++) { xbps_array_t shrequires; xbps_dictionary_t pkgd; - const char *rpkgver; + const char *trans, *rpkgver; + char *rpkgname; xbps_array_get_cstring_nocopy(revdeps, i, &rpkgver); - pkgd = xbps_pkgdb_get_pkg(xhp, rpkgver); + rpkgname = xbps_pkg_name(rpkgver); + assert(rpkgname); + /* + * First check if this revdep has been queued in transaction; + * otherwise process the current installed pkg. + */ + pkgd = xbps_find_pkg_in_array(unsorted, rpkgname, NULL); + free(rpkgname); + if (pkgd) { + /* + * Make sure pkg in transaction is an update. + */ + xbps_dictionary_get_cstring_nocopy(pkgd, "transaction", &trans); + if (strcmp(trans, "update")) + pkgd = NULL; + } + if (!pkgd) + pkgd = xbps_pkgdb_get_pkg(xhp, rpkgver); + shrequires = xbps_dictionary_get(pkgd, "shlib-requires"); for (unsigned int x = 0; x < xbps_array_count(shrequires); x++) { @@ -187,7 +206,7 @@ xbps_transaction_shlibs(struct xbps_handle *xhp) * Check that all shlibs provided by this pkg are used by * its revdeps. */ - if (!shlib_matched(xhp, mshlibs, pkgver, shlib)) + if (!shlib_matched(xhp, unsorted, mshlibs, pkgver, shlib)) unmatched = true; } }