[pacman-dev] [PATCH] pacman: new config to highlight testing packages

Matthew Sexton wsdmatty at gmail.com
Tue Sep 10 09:53:52 UTC 2019


Only during Install/Upgrade, and not to verbosepkglist

Signed-off-by: Matthew Sexton <wsdmatty at gmail.com>
---
 src/pacman/conf.c        |  2 ++
 src/pacman/conf.h        |  2 ++
 src/pacman/pacman-conf.c |  1 +
 src/pacman/util.c        | 20 ++++++++++++++++----
 4 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 2d8518c4..70c8a4f4 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -494,6 +494,8 @@ static int _parse_options(const char *key, char *value,
 				config->color = isatty(fileno(stdout)) ? PM_COLOR_ON : PM_COLOR_OFF;
 				enable_colors(config->color);
 			}
+		} else if(strcmp(key, "HighlightTesting") == 0) {
+			config->highlighttesting = 1;
 		} else if(strcmp(key, "DisableDownloadTimeout") == 0) {
 			config->disable_dl_timeout = 1;
 		} else {
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index f45ed436..51fa5764 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -117,6 +117,8 @@ typedef struct __config_t {
 	unsigned short totaldownload;
 	/* select -Sc behavior */
 	unsigned short cleanmethod;
+	/* Highlight packages from testing repositories */
+	unsigned short highlighttesting;
 	alpm_list_t *holdpkg;
 	alpm_list_t *ignorepkg;
 	alpm_list_t *ignoregrp;
diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index df874029..1e40c138 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -260,6 +260,7 @@ static void dump_config(void)
 	show_bool("VerbosePkgLists", config->verbosepkglists);
 	show_bool("DisableDownloadTimeout", config->disable_dl_timeout);
 	show_bool("ILoveCandy", config->chomp);
+  show_bool("HighlightTesting", config->highlighttesting);
 
 	show_cleanmethod("CleanMethod", config->cleanmethod);
 
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 8f6290db..13ac0f25 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -898,15 +898,27 @@ static void _display_targets(alpm_list_t *targets, int verbose)
 
 	/* form data for both verbose and non-verbose display */
 	for(i = targets; i; i = alpm_list_next(i)) {
+		unsigned short testing = 0;
+		const char *repo;
 		pm_target_t *target = i->data;
-
+		alpm_db_t *db = alpm_pkg_get_db(target->install);
+		if(db) {
+			repo = alpm_db_get_name(db);
+			if (strcmp(repo, "testing") == 0 || strcmp(repo,"community-testing") == 0) {
+				testing = 1;
+			}
+		}
 		if(verbose) {
 			rows = alpm_list_add(rows, create_verbose_row(target));
 		}
-
 		if(target->install) {
-			pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->install),
-					alpm_pkg_get_version(target->install));
+			if (testing && config->highlighttesting) {
+				pm_asprintf(&str, "%s%s-%s%s", config->color == PM_COLOR_ON ? config->colstr.warn : "**",
+							alpm_pkg_get_name(target->install), alpm_pkg_get_version(target->install),
+							config->color == PM_COLOR_ON ? config->colstr.nocolor : "**");
+			} else {
+				pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->install), alpm_pkg_get_version(target->install));
+			}
 		} else if(isize == 0) {
 			pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(target->remove),
 					alpm_pkg_get_version(target->remove));
-- 
2.23.0


More information about the pacman-dev mailing list