Merge branch 'installed-info-to-Sg' into 'master'

Add [installed] information to -Sg/-Sgg output

See merge request pacman/pacman!44
This commit is contained in:
Taro Tanaka 2025-06-23 03:50:25 +00:00
commit 9fb7ca55bc
4 changed files with 38 additions and 14 deletions

View file

@ -353,10 +353,10 @@ Query Options (apply to '-Q')[[QO]]
pacman's output is processed in a script. Search will only show package pacman's output is processed in a script. Search will only show package
names and not version, group, and description information; owns will names and not version, group, and description information; owns will
only show package names instead of "file is owned by pkg" messages; group 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 will only show package names and omit group names and package versions;
files and omit package names; check will only show pairs of package names list will only show files and omit package names; check will only show
and missing files; a bare query will only show package names pairs of package names and missing files; a bare query will only show
rather than names and versions. package names rather than names and versions.
*-s, \--search* <regexp>:: *-s, \--search* <regexp>::
Search each locally-installed package for names or descriptions that Search each locally-installed package for names or descriptions that
@ -436,7 +436,7 @@ linkman:pacman.conf[5].
pacman's output is processed in a script. Search will only show package pacman's output is processed in a script. Search will only show package
names and not repository, version, group, and description information; list names and not repository, version, group, and description information; list
will only show package names and omit databases and versions; group will 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* <regexp>:: *-s, \--search* <regexp>::
This will search each package in the sync databases for names or This will search each package in the sync databases for names or

View file

@ -322,7 +322,7 @@ _pacman_completions_all_packages() {
_pacman_completions_installed_groups() { _pacman_completions_installed_groups() {
local -a cmd groups local -a cmd groups
_pacman_get_command _pacman_get_command
groups=(${(o)${(f)"$(_call_program groups $cmd[@] -Qg)"}% *}) groups=(${(o)${(f)"$(_call_program groups $cmd[@] -Qg)"}%% *})
typeset -U groups typeset -U groups
compadd "$@" -a groups compadd "$@" -a groups
} }

View file

@ -352,9 +352,10 @@ static int display(alpm_pkg_t *pkg)
static int query_group(alpm_list_t *targets) static int query_group(alpm_list_t *targets)
{ {
alpm_list_t *i, *j; 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; const char *grpname = NULL;
int ret = 0; int ret = 0;
alpm_db_t *db_local = alpm_get_localdb(config->handle);
if(targets == NULL) { if(targets == NULL) {
for(j = alpm_db_get_groupcache(db_local); j; j = alpm_list_next(j)) { for(j = alpm_db_get_groupcache(db_local); j; j = alpm_list_next(j)) {
@ -366,7 +367,14 @@ static int query_group(alpm_list_t *targets)
if(!filter(pkg)) { if(!filter(pkg)) {
continue; continue;
} }
printf("%s %s\n", grp->name, alpm_pkg_get_name(pkg)); 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 { } else {
@ -381,8 +389,10 @@ static int query_group(alpm_list_t *targets)
continue; continue;
} }
if(!config->quiet) { if(!config->quiet) {
printf("%s %s\n", grpname, printf("%s%s %s%s %s%s%s\n", colstr->groups, grpname,
alpm_pkg_get_name(p->data)); colstr->title, alpm_pkg_get_name(p->data),
colstr->version, alpm_pkg_get_version(p->data),
colstr->nocolor);
} else { } else {
printf("%s\n", alpm_pkg_get_name(p->data)); printf("%s\n", alpm_pkg_get_name(p->data));
} }

View file

@ -339,6 +339,8 @@ 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) static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
{ {
alpm_list_t *i, *j, *k, *s = NULL; 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; int ret = 0;
if(targets) { if(targets) {
@ -355,8 +357,12 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
/* get names of packages in group */ /* get names of packages in group */
for(k = grp->packages; k; k = alpm_list_next(k)) { for(k = grp->packages; k; k = alpm_list_next(k)) {
if(!config->quiet) { if(!config->quiet) {
printf("%s %s\n", grpname, printf("%s%s %s%s %s%s%s", colstr->groups, grpname,
alpm_pkg_get_name(k->data)); 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 { } else {
printf("%s\n", alpm_pkg_get_name(k->data)); printf("%s\n", alpm_pkg_get_name(k->data));
} }
@ -378,8 +384,16 @@ static int sync_group(int level, alpm_list_t *syncs, alpm_list_t *targets)
if(level > 1) { if(level > 1) {
for(k = grp->packages; k; k = alpm_list_next(k)) { for(k = grp->packages; k; k = alpm_list_next(k)) {
printf("%s %s\n", grp->name, if(!config->quiet) {
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");
} else {
printf("%s\n", alpm_pkg_get_name(k->data));
}
} }
} else { } else {
/* print grp names only, no package names */ /* print grp names only, no package names */