[pacman-dev] [PATCH 03/11] Load color configs

Daniel Wallace daniel.wallace at gatech.edu
Sun Aug 5 05:46:39 EDT 2012


can use --color or have Color in pacman.conf
Signed-off-by: Daniel Wallace <daniel.wallace at gatech.edu>
---
 src/pacman/Makefile.am | 3 +++
 src/pacman/conf.c      | 2 ++
 src/pacman/conf.h      | 1 +
 src/pacman/pacman.c    | 5 +++++
 4 files changed, 11 insertions(+)

diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am
index c8ce977..cad67a6 100644
--- a/src/pacman/Makefile.am
+++ b/src/pacman/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = po
 
 # paths set at make time
 conffile  = ${sysconfdir}/pacman.conf
+colorfile  = ${sysconfdir}/pacman.d/color.conf
 dbpath    = ${localstatedir}/lib/pacman/
 gpgdir    = ${sysconfdir}/pacman.d/gnupg/
 cachedir  = ${localstatedir}/cache/pacman/pkg/
@@ -11,6 +12,7 @@ bin_PROGRAMS = pacman
 
 DEFS = -DLOCALEDIR=\"@localedir@\" \
        -DCONFFILE=\"$(conffile)\" \
+       -DCOLORFILE=\"$(colorfile)\" \
        -DDBPATH=\"$(dbpath)\" \
        -DGPGDIR=\"$(gpgdir)\" \
        -DCACHEDIR=\"$(cachedir)\" \
@@ -30,6 +32,7 @@ endif
 
 pacman_SOURCES = \
 	conf.h conf.c \
+	color.h color.c \
 	database.c \
 	deptest.c \
 	package.h package.c \
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 3b3d3df..a0d1be3 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -52,6 +52,7 @@ config_t *config_new(void)
 	newconfig->op = PM_OP_MAIN;
 	newconfig->logmask = ALPM_LOG_ERROR | ALPM_LOG_WARNING;
 	newconfig->configfile = strdup(CONFFILE);
+	newconfig->colorfile = strdup(COLORFILE);
 	newconfig->deltaratio = 0.0;
 	if(alpm_capabilities() & ALPM_CAPABILITY_SIGNATURES) {
 		newconfig->siglevel = ALPM_SIG_PACKAGE | ALPM_SIG_PACKAGE_OPTIONAL |
@@ -76,6 +77,7 @@ int config_free(config_t *oldconfig)
 	FREELIST(oldconfig->noupgrade);
 	FREELIST(oldconfig->noextract);
 	free(oldconfig->configfile);
+	free(oldconfig->colorfile);
 	free(oldconfig->rootdir);
 	free(oldconfig->dbpath);
 	free(oldconfig->logfile);
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 3e17155..62343cb 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -41,6 +41,7 @@ typedef struct __config_t {
 	 * because they can come from both the command line or config file, and we
 	 * need to ensure we get the order of preference right. */
 	char *configfile;
+	char *colorfile;
 	char *rootdir;
 	char *dbpath;
 	char *logfile;
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 732d7f3..0708dbf 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -46,6 +46,7 @@
 #include "pacman.h"
 #include "util.h"
 #include "conf.h"
+#include "color.h"
 
 /* list of targets specified on command line */
 static alpm_list_t *pm_targets;
@@ -868,6 +869,10 @@ int main(int argc, char *argv[])
 		cleanup(ret);
 	}
 
+	/* parse colors if specified  */
+	if (config->color) {
+		parsecolorconfig();
+	}
 	/* noask is meant to be non-interactive */
 	if(config->noask) {
 		config->noconfirm = 1;
-- 
1.7.11.4



More information about the pacman-dev mailing list