xbps-query: print pkg state in -l, --list-packages mode.

This commit is contained in:
Juan RP 2012-12-20 06:15:56 +01:00
parent 2a7700bc94
commit faf0fd6a08
2 changed files with 26 additions and 3 deletions

11
NEWS
View File

@ -1,5 +1,16 @@
xbps-0.19.1 (???): 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 * xbps-reconfigure(8): fixed regression introduced in 0.19 when processing
all packages with '-a, --all'. Found by pancake. all packages with '-a, --all'. Found by pancake.

View File

@ -56,10 +56,11 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
bool *loop_done) bool *loop_done)
{ {
struct list_pkgver_cb *lpc = arg; 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; char tmp[255], *out = NULL;
size_t i, len = 0, maxcols; size_t i, len = 0, maxcols;
bool chkarch; bool chkarch;
pkg_state_t state;
(void)xhp; (void)xhp;
(void)loop_done; (void)loop_done;
@ -73,8 +74,19 @@ list_pkgs_in_dict(struct xbps_handle *xhp,
if (!pkgver && !short_desc) if (!pkgver && !short_desc)
return EINVAL; return EINVAL;
strncpy(tmp, pkgver, sizeof(tmp)); xbps_pkg_state_dictionary(obj, &state);
for (i = strlen(pkgver); i < lpc->pkgver_len; i++)
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] = ' ';
tmp[i] = '\0'; tmp[i] = '\0';