[pacman-dev] [PATCH] Add support for passing --unrequired twice (for optdep)
Passing two -t will restrict or filter output to packages also not set as optional dependency by any installed package. Makes it easy to spot potentially useless packages using -Qdttq Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> --- doc/pacman.8.txt | 4 +++- src/pacman/pacman.c | 2 +- src/pacman/query.c | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 1cc1eaa..6abd491 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -314,7 +314,9 @@ Query Options[[QO]] *-t, \--unrequired*:: Restrict or filter output to packages not required by any currently - installed package. + installed package. Passing two '--unrequired' or '-t' flags will restrict or + filter output to packages also not set as optional dependency by any + currently installed package. *-u, \--upgrades*:: Restrict or filter output to packages that are out-of-date on the local diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 7aa0271..4a94d32 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -483,7 +483,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 f5862a2..f15555a 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 */ -- 1.8.3.1
On 15/06/13 22:07, Olivier Brunel wrote:
Passing two -t will restrict or filter output to packages also not set as optional dependency by any installed package.
Makes it easy to spot potentially useless packages using -Qdttq
Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> --- doc/pacman.8.txt | 4 +++- src/pacman/pacman.c | 2 +- src/pacman/query.c | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 1cc1eaa..6abd491 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -314,7 +314,9 @@ Query Options[[QO]]
*-t, \--unrequired*:: Restrict or filter output to packages not required by any currently - installed package. + installed package. Passing two '--unrequired' or '-t' flags will restrict or + filter output to packages also not set as optional dependency by any + currently installed package.
I'd prefer the opposite: *-t, \--unrequired*:: Restrict or filter output to packages not required or optionally required by any currently installed package. Specify this option twice to only filter packages that are direct dependencies (i.e. do not filter optional dependencies).
*-u, \--upgrades*:: Restrict or filter output to packages that are out-of-date on the local diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 7aa0271..4a94d32 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -483,7 +483,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 f5862a2..f15555a 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 */
On 06/16/13 11:57, Allan McRae wrote:
On 15/06/13 22:07, Olivier Brunel wrote:
Passing two -t will restrict or filter output to packages also not set as optional dependency by any installed package.
Makes it easy to spot potentially useless packages using -Qdttq
Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> --- doc/pacman.8.txt | 4 +++- src/pacman/pacman.c | 2 +- src/pacman/query.c | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 1cc1eaa..6abd491 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -314,7 +314,9 @@ Query Options[[QO]]
*-t, \--unrequired*:: Restrict or filter output to packages not required by any currently - installed package. + installed package. Passing two '--unrequired' or '-t' flags will restrict or + filter output to packages also not set as optional dependency by any + currently installed package.
I'd prefer the opposite:
*-t, \--unrequired*:: Restrict or filter output to packages not required or optionally required by any currently installed package. Specify this option twice to only filter packages that are direct dependencies (i.e. do not filter optional dependencies).
Sure, quick question then: Should the help string (on -Qh) be modified to reflect this change? If so, I'm not sure how best to quickly describe it; this removes the "of any package" bit, but it should still be clear? "list packages not direct/opt (-tt direct only) dependencies [filter]"
*-u, \--upgrades*:: Restrict or filter output to packages that are out-of-date on the local diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 7aa0271..4a94d32 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -483,7 +483,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 f5862a2..f15555a 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 */
On 16/06/13 21:14, jjacky wrote:
On 06/16/13 11:57, Allan McRae wrote:
On 15/06/13 22:07, Olivier Brunel wrote:
Passing two -t will restrict or filter output to packages also not set as optional dependency by any installed package.
Makes it easy to spot potentially useless packages using -Qdttq
Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> --- doc/pacman.8.txt | 4 +++- src/pacman/pacman.c | 2 +- src/pacman/query.c | 11 ++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 1cc1eaa..6abd491 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -314,7 +314,9 @@ Query Options[[QO]]
*-t, \--unrequired*:: Restrict or filter output to packages not required by any currently - installed package. + installed package. Passing two '--unrequired' or '-t' flags will restrict or + filter output to packages also not set as optional dependency by any + currently installed package.
I'd prefer the opposite:
*-t, \--unrequired*:: Restrict or filter output to packages not required or optionally required by any currently installed package. Specify this option twice to only filter packages that are direct dependencies (i.e. do not filter optional dependencies).
Sure, quick question then: Should the help string (on -Qh) be modified to reflect this change?
If so, I'm not sure how best to quickly describe it; this removes the "of any package" bit, but it should still be clear?
"list packages not direct/opt (-tt direct only) dependencies [filter]"
Go over two lines: -t, --unrequired list packages not (optionally) required by any package (-tt to ignore optdepends) [filter]
Specify it twice to only filter direct dependencies. Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> --- doc/pacman.8.txt | 6 ++++-- src/pacman/pacman.c | 5 +++-- src/pacman/query.c | 11 ++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 1cc1eaa..574995c 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -313,8 +313,10 @@ Query Options[[QO]] with descriptions matching ALL of those terms are returned. *-t, \--unrequired*:: - Restrict or filter output to packages not required by any currently - installed package. + Restrict or filter output to packages not required or optionally required by + any currently installed package. Specify this option twice to only filter + packages that are direct dependencies (i.e. do not filter optional + dependencies). *-u, \--upgrades*:: Restrict or filter output to packages that are out-of-date on the local diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 7aa0271..5ce8747 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 f5862a2..e88b393 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 */ -- 1.8.3.1
On 17/06/13 18:46, Olivier Brunel wrote:
Specify it twice to only filter direct dependencies.
Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
Signed-off-by: Me
--- doc/pacman.8.txt | 6 ++++-- src/pacman/pacman.c | 5 +++-- src/pacman/query.c | 11 ++++++++--- 3 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 1cc1eaa..574995c 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -313,8 +313,10 @@ Query Options[[QO]] with descriptions matching ALL of those terms are returned.
*-t, \--unrequired*:: - Restrict or filter output to packages not required by any currently - installed package. + Restrict or filter output to packages not required or optionally required by + any currently installed package. Specify this option twice to only filter + packages that are direct dependencies (i.e. do not filter optional + dependencies).
*-u, \--upgrades*:: Restrict or filter output to packages that are out-of-date on the local diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 7aa0271..5ce8747 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 f5862a2..e88b393 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 */
participants (3)
-
Allan McRae
-
jjacky
-
Olivier Brunel