From b25152dd46ea20e80a2d245344978940c3dc0704 Mon Sep 17 00:00:00 2001 From: Taro Tanaka Date: Fri, 6 Jan 2023 20:53:28 +0900 Subject: [PATCH 1/3] Add [installed] information to -Sg/-Sgg output This allows users to easily check which packages in a group are installed (or not). Signed-off-by: Taro Tanaka --- src/pacman/sync.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 1f2c8cba..f166347a 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -329,6 +329,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) { alpm_list_t *i, *j, *k, *s = NULL; + alpm_db_t *db_local = alpm_get_localdb(config->handle); int ret = 0; if(targets) { @@ -345,8 +346,10 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) /* get names of packages in group */ for(k = grp->packages; k; k = alpm_list_next(k)) { if(!config->quiet) { - printf("%s %s\n", grpname, + printf("%s %s", grpname, alpm_pkg_get_name(k->data)); + print_installed(db_local, k->data); + printf("\n"); } else { printf("%s\n", alpm_pkg_get_name(k->data)); } @@ -368,8 +371,10 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) if(level > 1) { for(k = grp->packages; k; k = alpm_list_next(k)) { - printf("%s %s\n", grp->name, + printf("%s %s", grp->name, alpm_pkg_get_name(k->data)); + print_installed(db_local, k->data); + printf("\n"); } } else { /* print grp names only, no package names */ From 553d0a1249e1414ce8239e49a07305c7178e3df3 Mon Sep 17 00:00:00 2001 From: Taro Tanaka Date: Fri, 6 Jan 2023 21:01:38 +0900 Subject: [PATCH 2/3] Add version information and color to -Qg/-Sg/-Sgg output The output format is now in line with other query operations such as -Sl and -Q. This makes the colored [installed] labels added in the previous commit less obtrusive. Signed-off-by: Taro Tanaka --- doc/pacman.8.asciidoc | 10 +++++----- scripts/completion/zsh_completion.in | 2 +- src/pacman/query.c | 14 ++++++++++---- src/pacman/sync.c | 13 +++++++++---- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/doc/pacman.8.asciidoc b/doc/pacman.8.asciidoc index 630ff0d9..40695d07 100644 --- a/doc/pacman.8.asciidoc +++ b/doc/pacman.8.asciidoc @@ -347,10 +347,10 @@ Query Options (apply to '-Q')[[QO]] pacman's output is processed in a script. Search will only show package names and not version, group, and description information; owns will only show package names instead of "file is owned by pkg" messages; group - will only show package names and omit group names; list will only show - files and omit package names; check will only show pairs of package names - and missing files; a bare query will only show package names - rather than names and versions. + will only show package names and omit group names and package versions; + list will only show files and omit package names; check will only show + pairs of package names and missing files; a bare query will only show + package names rather than names and versions. *-s, \--search* :: Search each locally-installed package for names or descriptions that @@ -430,7 +430,7 @@ linkman:pacman.conf[5]. pacman's output is processed in a script. Search will only show package names and not repository, version, group, and description information; list will only show package names and omit databases and versions; group will - only show package names and omit group names. + only show package names and omit group names and package versions. *-s, \--search* :: This will search each package in the sync databases for names or diff --git a/scripts/completion/zsh_completion.in b/scripts/completion/zsh_completion.in index 3f81e9f7..463f550e 100644 --- a/scripts/completion/zsh_completion.in +++ b/scripts/completion/zsh_completion.in @@ -322,7 +322,7 @@ _pacman_completions_all_packages() { _pacman_completions_installed_groups() { local -a cmd groups _pacman_get_command - groups=(${(o)${(f)"$(_call_program groups $cmd[@] -Qg)"}% *}) + groups=(${(o)${(f)"$(_call_program groups $cmd[@] -Qg)"}%% *}) typeset -U groups compadd "$@" -a groups } diff --git a/src/pacman/query.c b/src/pacman/query.c index d75c4c80..a60bbf96 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -352,9 +352,10 @@ static int display(alpm_pkg_t *pkg) static int query_group(alpm_list_t *targets) { alpm_list_t *i, *j; + alpm_db_t *db_local = alpm_get_localdb(config->handle); + const colstr_t *colstr = &config->colstr; const char *grpname = NULL; int ret = 0; - alpm_db_t *db_local = alpm_get_localdb(config->handle); if(targets == NULL) { for(j = alpm_db_get_groupcache(db_local); j; j = alpm_list_next(j)) { @@ -366,7 +367,10 @@ static int query_group(alpm_list_t *targets) if(!filter(pkg)) { continue; } - printf("%s %s\n", grp->name, alpm_pkg_get_name(pkg)); + printf("%s%s %s%s %s%s%s\n", colstr->groups, grp->name, + colstr->title, alpm_pkg_get_name(pkg), + colstr->version, alpm_pkg_get_version(pkg), + colstr->nocolor); } } } else { @@ -381,8 +385,10 @@ static int query_group(alpm_list_t *targets) continue; } if(!config->quiet) { - printf("%s %s\n", grpname, - alpm_pkg_get_name(p->data)); + printf("%s%s %s%s %s%s%s\n", colstr->groups, grpname, + colstr->title, alpm_pkg_get_name(p->data), + colstr->version, alpm_pkg_get_version(p->data), + colstr->nocolor); } else { printf("%s\n", alpm_pkg_get_name(p->data)); } diff --git a/src/pacman/sync.c b/src/pacman/sync.c index f166347a..93225bab 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -330,6 +330,7 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) { alpm_list_t *i, *j, *k, *s = NULL; alpm_db_t *db_local = alpm_get_localdb(config->handle); + const colstr_t *colstr = &config->colstr; int ret = 0; if(targets) { @@ -346,8 +347,10 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) /* get names of packages in group */ for(k = grp->packages; k; k = alpm_list_next(k)) { if(!config->quiet) { - printf("%s %s", grpname, - alpm_pkg_get_name(k->data)); + printf("%s%s %s%s %s%s%s", colstr->groups, grpname, + colstr->title, alpm_pkg_get_name(k->data), + colstr->version, alpm_pkg_get_version(k->data), + colstr->nocolor); print_installed(db_local, k->data); printf("\n"); } else { @@ -371,8 +374,10 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) if(level > 1) { for(k = grp->packages; k; k = alpm_list_next(k)) { - printf("%s %s", grp->name, - alpm_pkg_get_name(k->data)); + printf("%s%s %s%s %s%s%s", colstr->groups, grp->name, + colstr->title, alpm_pkg_get_name(k->data), + colstr->version, alpm_pkg_get_version(k->data), + colstr->nocolor); print_installed(db_local, k->data); printf("\n"); } From 9f3235b2efc471a7ac362a621316cb2d3e0cef1c Mon Sep 17 00:00:00 2001 From: Taro Tanaka Date: Sun, 8 Jan 2023 23:48:15 +0900 Subject: [PATCH 3/3] Allow -q to argumentless -Qg/-Sgg as well Like other query operations. This may not be very useful, but even -Qs/-Ss with no arguments accept -q, so let's follow the convention and be consistent. Signed-off-by: Taro Tanaka --- src/pacman/query.c | 12 ++++++++---- src/pacman/sync.c | 16 ++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/pacman/query.c b/src/pacman/query.c index a60bbf96..13003f5b 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -367,10 +367,14 @@ static int query_group(alpm_list_t *targets) if(!filter(pkg)) { continue; } - printf("%s%s %s%s %s%s%s\n", colstr->groups, grp->name, - colstr->title, alpm_pkg_get_name(pkg), - colstr->version, alpm_pkg_get_version(pkg), - colstr->nocolor); + if(!config->quiet) { + printf("%s%s %s%s %s%s%s\n", colstr->groups, grp->name, + colstr->title, alpm_pkg_get_name(pkg), + colstr->version, alpm_pkg_get_version(pkg), + colstr->nocolor); + } else { + printf("%s\n", alpm_pkg_get_name(pkg)); + } } } } else { diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 93225bab..ab55fa71 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -374,12 +374,16 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets) if(level > 1) { for(k = grp->packages; k; k = alpm_list_next(k)) { - printf("%s%s %s%s %s%s%s", colstr->groups, grp->name, - colstr->title, alpm_pkg_get_name(k->data), - colstr->version, alpm_pkg_get_version(k->data), - colstr->nocolor); - print_installed(db_local, k->data); - printf("\n"); + if(!config->quiet) { + printf("%s%s %s%s %s%s%s", colstr->groups, grp->name, + colstr->title, alpm_pkg_get_name(k->data), + colstr->version, alpm_pkg_get_version(k->data), + colstr->nocolor); + print_installed(db_local, k->data); + printf("\n"); + } else { + printf("%s\n", alpm_pkg_get_name(k->data)); + } } } else { /* print grp names only, no package names */