[pacman-dev] [PATCH 07/14] Make package info show optional requirements

Benedikt Morbach benedikt.morbach at googlemail.com
Wed Nov 23 10:51:21 EST 2011


Signed-off-by: Benedikt Morbach <benedikt.morbach at googlemail.com>
---
 src/pacman/package.c          |    9 ++++++---
 test/pacman/tests/query012.py |   13 +++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 test/pacman/tests/query012.py

diff --git a/src/pacman/package.c b/src/pacman/package.c
index 642307c..53f44bc 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -67,8 +67,8 @@ static void optdeplist_display(const char *title,
 
 /**
  * Display the details of a package.
- * Extra information entails 'required by' info for sync packages and backup
- * files info for local packages.
+ * Extra information entails 'required by' and 'optrequired by' info
+ * for sync packages and backup files info for local packages.
  * @param pkg package to display information for
  * @param from the type of package we are dealing with
  * @param extra should we show extra information
@@ -81,6 +81,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
 	const char *label;
 	double size;
 	alpm_list_t *requiredby = NULL;
+	alpm_list_t *optrequiredby = NULL;
 	alpm_pkgfrom_t from;
 
 	from = alpm_pkg_get_origin(pkg);
@@ -109,7 +110,8 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
 
 	if(extra || from == PKG_FROM_LOCALDB) {
 		/* compute this here so we don't get a pause in the middle of output */
-		requiredby = alpm_pkg_compute_requiredby(pkg, 0);
+		requiredby    = alpm_pkg_compute_requiredby(pkg, 0);
+		optrequiredby = alpm_pkg_compute_requiredby(pkg, 1);
 	}
 
 	/* actual output */
@@ -127,6 +129,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra)
 	optdeplist_display(_("Optional Deps  :"), alpm_pkg_get_optdepends(pkg));
 	if(extra || from == PKG_FROM_LOCALDB) {
 		list_display(_("Required By    :"), requiredby);
+		list_display(_("Optional For   :"), optrequiredby);
 	}
 	deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg));
 	deplist_display(_("Replaces       :"), alpm_pkg_get_replaces(pkg));
diff --git a/test/pacman/tests/query012.py b/test/pacman/tests/query012.py
new file mode 100644
index 0000000..cdb7120
--- /dev/null
+++ b/test/pacman/tests/query012.py
@@ -0,0 +1,13 @@
+self.description = "Query info on a package (reverse optdeps)"
+
+pkg = pmpkg("dummy", "1.0-2")
+pkg.optdepends = ["dep: for foobar"]
+self.addpkg2db("local", pkg)
+
+dep = pmpkg("dep")
+self.addpkg2db("local", dep)
+
+self.args = "-Qi %s" % dep.name
+
+self.addrule("PACMAN_RETCODE=0")
+self.addrule("PACMAN_OUTPUT=^Optional For.*%s" % pkg.name)
-- 
1.7.7.3



More information about the pacman-dev mailing list