From 96e023c7bd0b1069878667278a45a34476c42472 Mon Sep 17 00:00:00 2001
From: Xavier Chantry <shiningxc@gmail.com>
Date: Thu, 31 Jul 2008 16:35:21 +0200
Subject: pacman: print optdepends on install and upgrade.

This implements FS#10630.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
---
 src/pacman/callback.c | 2 ++
 src/pacman/util.c     | 9 +++++++++
 src/pacman/util.h     | 1 +
 3 files changed, 12 insertions(+)

diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index b8e2d77e..8d4538c4 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -181,6 +181,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
 			alpm_logaction("installed %s (%s)\n",
 			         alpm_pkg_get_name(data1),
 			         alpm_pkg_get_version(data1));
+			display_optdepends(data1);
 			break;
 		case PM_TRANS_EVT_REMOVE_START:
 			if(config->noprogressbar) {
@@ -202,6 +203,7 @@ void cb_trans_evt(pmtransevt_t event, void *data1, void *data2)
 			         (char *)alpm_pkg_get_name(data1),
 			         (char *)alpm_pkg_get_version(data2),
 			         (char *)alpm_pkg_get_version(data1));
+			display_optdepends(data1);
 			break;
 		case PM_TRANS_EVT_INTEGRITY_START:
 			printf(_("checking package integrity...\n"));
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 1a74c9ea..8c4aeab8 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -609,6 +609,15 @@ void display_synctargets(const alpm_list_t *syncpkgs)
 	alpm_list_free(rpkglist);
 }
 
+void display_optdepends(pmpkg_t *pkg)
+{
+	alpm_list_t *optdeps = alpm_pkg_get_optdepends(pkg);
+	if(optdeps) {
+		printf(_("Optional dependencies for %s\n"), alpm_pkg_get_name(pkg));
+		list_display_linebreak("   ", optdeps);
+	}
+}
+
 /* presents a prompt and gets a Y/N answer */
 int yesno(short preset, char *fmt, ...)
 {
diff --git a/src/pacman/util.h b/src/pacman/util.h
index 209b2424..f94f0aed 100644
--- a/src/pacman/util.h
+++ b/src/pacman/util.h
@@ -54,6 +54,7 @@ void list_display(const char *title, const alpm_list_t *list);
 void list_display_linebreak(const char *title, const alpm_list_t *list);
 void display_targets(const alpm_list_t *pkgs, int install);
 void display_synctargets(const alpm_list_t *syncpkgs);
+void display_optdepends(pmpkg_t *pkg);
 int yesno(short preset, char *fmt, ...);
 int pm_printf(pmloglevel_t level, const char *format, ...) __attribute__((format(printf,2,3)));
 int pm_fprintf(FILE *stream, pmloglevel_t level, const char *format, ...) __attribute__((format(printf,3,4)));
-- 
cgit v1.2.3-70-g09d2