summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-06-19 07:23:18 +0200
committerAllan McRae <allan@archlinux.org>2013-06-26 07:32:16 +0200
commitde7ccedbe7477ec520bb035b71e9fb97ebd028c4 (patch)
treef636f450c2d08663ac0114cd698a04a96040f0c5
parent2436351d6e745e5e9713709948c41b2db8ca201f (diff)
downloadpacman-de7ccedbe7477ec520bb035b71e9fb97ebd028c4.tar.gz
pacman-de7ccedbe7477ec520bb035b71e9fb97ebd028c4.tar.xz
query_group: allow package filters
Relocated query_group() to allow calling filter(). Fixes FS#19716 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--src/pacman/query.c88
1 files changed, 47 insertions, 41 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c
index e88b393b..25a3c5d2 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -257,47 +257,6 @@ static int query_search(alpm_list_t *targets)
return dump_pkg_search(db_local, targets, 0);
}
-static int query_group(alpm_list_t *targets)
-{
- alpm_list_t *i, *j;
- 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)) {
- alpm_group_t *grp = j->data;
- const alpm_list_t *p;
-
- for(p = grp->packages; p; p = alpm_list_next(p)) {
- alpm_pkg_t *pkg = p->data;
- printf("%s %s\n", grp->name, alpm_pkg_get_name(pkg));
- }
- }
- } else {
- for(i = targets; i; i = alpm_list_next(i)) {
- alpm_group_t *grp;
- grpname = i->data;
- grp = alpm_db_get_group(db_local, grpname);
- if(grp) {
- const alpm_list_t *p;
- for(p = grp->packages; p; p = alpm_list_next(p)) {
- if(!config->quiet) {
- printf("%s %s\n", grpname,
- alpm_pkg_get_name(p->data));
- } else {
- printf("%s\n", alpm_pkg_get_name(p->data));
- }
- }
- } else {
- pm_printf(ALPM_LOG_ERROR, _("group '%s' was not found\n"), grpname);
- ret++;
- }
- }
- }
- return ret;
-}
-
static unsigned short pkg_get_locality(alpm_pkg_t *pkg)
{
const char *pkgname = alpm_pkg_get_name(pkg);
@@ -392,6 +351,53 @@ static int display(alpm_pkg_t *pkg)
return ret;
}
+static int query_group(alpm_list_t *targets)
+{
+ alpm_list_t *i, *j;
+ 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)) {
+ alpm_group_t *grp = j->data;
+ const alpm_list_t *p;
+
+ for(p = grp->packages; p; p = alpm_list_next(p)) {
+ alpm_pkg_t *pkg = p->data;
+ if(!filter(pkg)) {
+ continue;
+ }
+ printf("%s %s\n", grp->name, alpm_pkg_get_name(pkg));
+ }
+ }
+ } else {
+ for(i = targets; i; i = alpm_list_next(i)) {
+ alpm_group_t *grp;
+ grpname = i->data;
+ grp = alpm_db_get_group(db_local, grpname);
+ if(grp) {
+ const alpm_list_t *p;
+ for(p = grp->packages; p; p = alpm_list_next(p)) {
+ if(!filter(p->data)) {
+ continue;
+ }
+ if(!config->quiet) {
+ printf("%s %s\n", grpname,
+ alpm_pkg_get_name(p->data));
+ } else {
+ printf("%s\n", alpm_pkg_get_name(p->data));
+ }
+ }
+ } else {
+ pm_printf(ALPM_LOG_ERROR, _("group '%s' was not found\n"), grpname);
+ ret++;
+ }
+ }
+ }
+ return ret;
+}
+
int pacman_query(alpm_list_t *targets)
{
int ret = 0;