diff options
author | Olivier Brunel <i.am.jack.mail@gmail.com> | 2013-06-17 10:46:38 +0200 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2013-06-26 07:32:15 +0200 |
commit | 00513823dc9e15c4de12c02f8faa4dd72ca4ee4e (patch) | |
tree | 16b537418c0250a3cd84a6c06f97e0bb2491f4b2 /src | |
parent | d7d4f47d63e88a0b79eb2f77d83df218dfa359a0 (diff) | |
download | pacman-00513823dc9e15c4de12c02f8faa4dd72ca4ee4e.tar.gz pacman-00513823dc9e15c4de12c02f8faa4dd72ca4ee4e.tar.xz |
Make --unrequired filter packages that are optdep as well
Specify it twice to only filter direct dependencies.
Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/pacman/pacman.c | 5 | ||||
-rw-r--r-- | src/pacman/query.c | 11 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 7aa0271c..5ce8747b 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -146,7 +146,8 @@ static void usage(int op, const char * const myname) addlist(_(" -p, --file <package> query a package file instead of the database\n")); addlist(_(" -q, --quiet show less information for query and search\n")); addlist(_(" -s, --search <regex> search locally-installed packages for matching strings\n")); - addlist(_(" -t, --unrequired list packages not required by any package [filter]\n")); + addlist(_(" -t, --unrequired list packages not (optionally) required by any\n" + " package (-tt to ignore optdepends) [filter]\n")); addlist(_(" -u, --upgrades list outdated packages [filter]\n")); } else if(op == PM_OP_SYNC) { printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg); @@ -483,7 +484,7 @@ static int parsearg_query(int opt) case 'p': config->op_q_isfile = 1; break; case 'q': config->quiet = 1; break; case 's': config->op_q_search = 1; break; - case 't': config->op_q_unrequired = 1; break; + case 't': (config->op_q_unrequired)++; break; case 'u': config->op_q_upgrade = 1; break; default: return 1; } diff --git a/src/pacman/query.c b/src/pacman/query.c index f5862a2d..e88b393b 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -312,11 +312,16 @@ static unsigned short pkg_get_locality(alpm_pkg_t *pkg) return PKG_LOCALITY_FOREIGN; } -static int is_unrequired(alpm_pkg_t *pkg) +static int is_unrequired(alpm_pkg_t *pkg, unsigned short level) { alpm_list_t *requiredby = alpm_pkg_compute_requiredby(pkg); if(requiredby == NULL) { - return 1; + if(level == 1) { + requiredby = alpm_pkg_compute_optionalfor(pkg); + } + if(requiredby == NULL) { + return 1; + } } FREELIST(requiredby); return 0; @@ -339,7 +344,7 @@ static int filter(alpm_pkg_t *pkg) return 0; } /* check if this pkg is unrequired */ - if(config->op_q_unrequired && !is_unrequired(pkg)) { + if(config->op_q_unrequired && !is_unrequired(pkg, config->op_q_unrequired)) { return 0; } /* check if this pkg is outdated */ |