diff --git a/NEWS b/NEWS index 8d9df697..be5e3081 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,11 @@ xbps-0.44 (???): + * xbps-query(8): in the ownedby mode, do not follow symbolic links and if the + matching file is a symlink print its target file too: + + $ xbps-query -o `which whatis` + mdocml-1.13.2_5: /usr/bin/whatis -> /usr/bin/mandoc (link) + * xbps-install(8): add additional actions to the column output: "downgrade" and "reinstall", as well as current installed version and new version. Implement https://github.com/voidlinux/xbps/issues/72 diff --git a/bin/xbps-query/ownedby.c b/bin/xbps-query/ownedby.c index ca89b2e3..40e0e69c 100644 --- a/bin/xbps-query/ownedby.c +++ b/bin/xbps-query/ownedby.c @@ -51,8 +51,7 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd, const char *pkgver) { xbps_array_t array; - xbps_object_t obj; - const char *keyname, *filestr, *typestr; + const char *keyname, *typestr; keyname = xbps_dictionary_keysym_cstring_nocopy(key); @@ -67,18 +66,28 @@ match_files_by_pattern(xbps_dictionary_t pkg_filesd, array = xbps_dictionary_get_keysym(pkg_filesd, key); for (unsigned int i = 0; i < xbps_array_count(array); i++) { + xbps_object_t obj; + const char *filestr = NULL, *tgt = NULL; + obj = xbps_array_get(array, i); - filestr = NULL; xbps_dictionary_get_cstring_nocopy(obj, "file", &filestr); if (filestr == NULL) continue; + xbps_dictionary_get_cstring_nocopy(obj, "target", &tgt); if (ffd->rematch) { if (regexec(&ffd->regex, filestr, 0, 0, 0) == 0) { - printf("%s: %s (%s)\n", pkgver, filestr, typestr); + printf("%s: %s ", pkgver, filestr); + if (tgt) + printf("-> %s ", tgt); + printf("(%s)\n", typestr); } } else { - if ((fnmatch(ffd->pat, filestr, FNM_PERIOD)) == 0) - printf("%s: %s (%s)\n", pkgver, filestr, typestr); + if ((fnmatch(ffd->pat, filestr, FNM_PERIOD)) == 0) { + printf("%s: %s ", pkgver, filestr); + if (tgt) + printf("-> %s ", tgt); + printf("(%s)\n", typestr); + } } } } @@ -170,15 +179,11 @@ int ownedby(struct xbps_handle *xhp, const char *pat, bool repo, bool regex) { struct ffdata ffd; - char *rfile; int rv; ffd.rematch = false; ffd.pat = pat; - if ((rfile = realpath(pat, NULL)) != NULL) - ffd.pat = rfile; - if (regex) { ffd.rematch = true; if (regcomp(&ffd.regex, ffd.pat, REG_EXTENDED|REG_NOSUB|REG_ICASE) != 0)