From 83ade3996015bf7f1ea1c52fc464f3d8e1cf5e5c Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 29 Mar 2015 09:56:28 +0200 Subject: [PATCH] xbps now autoupdates itself exclusively if there's an update. That was added for 0.21, but for some reason that I cannot remember it was disabled a bit later... looks like it's useful to have. --- lib/transaction_ops.c | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/transaction_ops.c b/lib/transaction_ops.c index 121f0d52..6d4ff445 100644 --- a/lib/transaction_ops.c +++ b/lib/transaction_ops.c @@ -227,23 +227,36 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool reinstall, int xbps_transaction_update_packages(struct xbps_handle *xhp) { + xbps_dictionary_t pkgd; xbps_object_t obj; xbps_object_iterator_t iter; - bool newpkg_found = false; + const char *pkgver; + char *pkgname; + bool hold, newpkg_found = false; int rv = 0; if ((rv = xbps_pkgdb_init(xhp)) != 0) return rv; + /* + * Check if there's a new update for XBPS before starting + * a full system upgrade. + */ + if ((pkgd = xbps_pkgdb_get_pkg(xhp, "xbps")) || + (pkgd = xbps_pkgdb_get_virtualpkg(xhp, "xbps"))) { + xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); + pkgname = xbps_pkg_name(pkgver); + assert(pkgname); + rv = trans_find_pkg(xhp, pkgname, false, false); + free(pkgname); + return rv; + } + iter = xbps_dictionary_iterator(xhp->pkgdb); assert(iter); while ((obj = xbps_object_iterator_next(iter))) { - xbps_dictionary_t pkgd; - const char *pkgver; - char *pkgname; - bool hold = false; - + hold = false; pkgd = xbps_dictionary_get_keysym(xhp->pkgdb, obj); xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver); xbps_dictionary_get_bool(pkgd, "hold", &hold);