[pacman-dev] [PATCH 09/14] Show list of optrequires with -Qtdn
Dan McGee
dpmcgee at gmail.com
Wed Nov 30 22:46:53 EST 2011
On Wed, Nov 23, 2011 at 9:51 AM, Benedikt Morbach
<benedikt.morbach at googlemail.com> wrote:
> Signed-off-by: Benedikt Morbach <benedikt.morbach at googlemail.com>
> ---
Can you provide some example output from this?
Overall, I'm not liking what I think this is, as it seems like an
extremely narrow implementation of
https://bugs.archlinux.org/task/25236 ...
> src/pacman/query.c | 11 ++++++++++-
> src/pacman/util.c | 27 ++++++++++++++++++++-------
> src/pacman/util.h | 1 +
> test/pacman/tests/query022.py | 14 ++++++++++++++
> 4 files changed, 45 insertions(+), 8 deletions(-)
> create mode 100644 test/pacman/tests/query022.py
>
> diff --git a/src/pacman/query.c b/src/pacman/query.c
> index fbff341..0017918 100644
> --- a/src/pacman/query.c
> +++ b/src/pacman/query.c
> @@ -488,7 +488,16 @@ static int display(alpm_pkg_t *pkg)
> if(!config->op_q_info && !config->op_q_list
> && !config->op_q_changelog && !config->op_q_check) {
> if(!config->quiet) {
> - printf("%s %s\n", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
> + printf("%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
> +
> + alpm_list_t *optrequires;
> + if(config->op_q_unrequired && config->op_q_optdeps &&
> + (optrequires = alpm_pkg_compute_requiredby(pkg, 1)) != NULL) {
> + list_display_extra(_(" (optdepend for:"), optrequires, ", ", ")");
> + FREELIST(optrequires);
> + } else {
> + printf("\n");
> + }
> } else {
> printf("%s\n", alpm_pkg_get_name(pkg));
> }
> diff --git a/src/pacman/util.c b/src/pacman/util.c
> index 1f89663..c54975e 100644
> --- a/src/pacman/util.c
> +++ b/src/pacman/util.c
> @@ -657,16 +657,24 @@ int table_display(const char *title, const alpm_list_t *header,
>
> void list_display(const char *title, const alpm_list_t *list)
> {
> + list_display_extra(title, list, NULL, NULL);
> +}
> +
> +void list_display_extra(const char *title, const alpm_list_t *list,
> + const char *delim, const char *after)
> +{
> const alpm_list_t *i;
> size_t len = 0;
>
> + delim = delim ? delim : " ";
> +
> if(title) {
> len = string_length(title) + 1;
> printf("%s ", title);
> }
>
> if(!list) {
> - printf("%s\n", _("None"));
> + printf("%s", _("None"));
> } else {
> const unsigned short maxcols = getcols();
> size_t cols = len;
> @@ -680,20 +688,25 @@ void list_display(const char *title, const alpm_list_t *list)
> if(maxcols > len && cols + s + 2 >= maxcols) {
> size_t j;
> cols = len;
> - printf("\n");
> + putchar('\n');
> for (j = 1; j <= len; j++) {
> - printf(" ");
> + putchar(' ');
> }
> } else if(cols != len) {
> - /* 2 spaces are added if this is not the first element on a line. */
> - printf(" ");
> - cols += 2;
> + /* delimiter is added if this is not the first element on a line. */
> + fputs(delim, stdout);
> + cols += strlen(delim);
> }
> fputs(str, stdout);
> cols += s;
> }
> - putchar('\n');
> }
> +
> + if(after) {
> + fputs(after, stdout);
> + }
> +
> + putchar('\n');
> }
>
> void list_display_linebreak(const char *title, const alpm_list_t *list)
> diff --git a/src/pacman/util.h b/src/pacman/util.h
> index ca33752..ffff4b5 100644
> --- a/src/pacman/util.h
> +++ b/src/pacman/util.h
> @@ -63,6 +63,7 @@ void string_display(const char *title, const char *string);
> double humanize_size(off_t bytes, const char target_unit, const char **label);
> int table_display(const char *title, const alpm_list_t *header, const alpm_list_t *rows);
> void list_display(const char *title, const alpm_list_t *list);
> +void list_display_extra(const char *title, const alpm_list_t *list, const char *delim, const char *after);
> void list_display_linebreak(const char *title, const alpm_list_t *list);
> void signature_display(const char *title, alpm_siglist_t *siglist);
> void display_targets(void);
> diff --git a/test/pacman/tests/query022.py b/test/pacman/tests/query022.py
> new file mode 100644
> index 0000000..f5e3458
> --- /dev/null
> +++ b/test/pacman/tests/query022.py
> @@ -0,0 +1,14 @@
> +self.description = "Query unneeded deps (installed optdeps not required)"
> +
> +pkg = pmpkg("dummy")
> +pkg.optdepends = ["dep: for foobar"]
> +self.addpkg2db("local", pkg)
> +
> +dep = pmpkg("dep")
> +self.addpkg2db("local", dep)
> +dep.reason = 1
> +
> +self.args = "-Qtdn"
> +
> +self.addrule("PACMAN_RETCODE=0")
> +self.addrule("PACMAN_OUTPUT=^dep.*dummy")
> --
> 1.7.7.3
>
>
More information about the pacman-dev
mailing list