From faf0fd6a086d681d2a0b666dafae61938f4dbd2d Mon Sep 17 00:00:00 2001 From: Juan RP Date: Thu, 20 Dec 2012 06:15:56 +0100 Subject: [PATCH] xbps-query: print pkg state in -l, --list-packages mode. --- NEWS | 11 +++++++++++ bin/xbps-query/list.c | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 172cb399..e198f029 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,16 @@ xbps-0.19.1 (???): + * xbps-query(8): -l, --list-packages option now prints pkg state as follows: + + STATE PKGVER DESCRIPTION + + Where STATE can be any of the following package states: + + ii = installed + uu = unpacked + hr = half-removed + ?? = unknown + * xbps-reconfigure(8): fixed regression introduced in 0.19 when processing all packages with '-a, --all'. Found by pancake. diff --git a/bin/xbps-query/list.c b/bin/xbps-query/list.c index b7c2fd16..f186ca22 100644 --- a/bin/xbps-query/list.c +++ b/bin/xbps-query/list.c @@ -56,10 +56,11 @@ list_pkgs_in_dict(struct xbps_handle *xhp, bool *loop_done) { struct list_pkgver_cb *lpc = arg; - const char *pkgver, *short_desc, *arch; + const char *pkgver, *short_desc, *arch, *state_str; char tmp[255], *out = NULL; size_t i, len = 0, maxcols; bool chkarch; + pkg_state_t state; (void)xhp; (void)loop_done; @@ -73,8 +74,19 @@ list_pkgs_in_dict(struct xbps_handle *xhp, if (!pkgver && !short_desc) return EINVAL; - strncpy(tmp, pkgver, sizeof(tmp)); - for (i = strlen(pkgver); i < lpc->pkgver_len; i++) + xbps_pkg_state_dictionary(obj, &state); + + if (state == XBPS_PKG_STATE_INSTALLED) + state_str = "ii"; + else if (state == XBPS_PKG_STATE_UNPACKED) + state_str = "uu"; + else if (state == XBPS_PKG_STATE_HALF_REMOVED) + state_str = "hr"; + else + state_str = "??"; + + snprintf(tmp, sizeof(tmp), "%s %s", state_str, pkgver); + for (i = strlen(pkgver) + 3; i < lpc->pkgver_len; i++) tmp[i] = ' '; tmp[i] = '\0';