Am Montag, den 17.05.2010, 19:16 +0200 schrieb Xavier Chantry:
> On Mon, May 17, 2010 at 6:15 PM, Marc - A. Dahlhaus <m...@wol.de> wrote:
> >
> > It would be very nice if Xavier or you could take a look at it as i
> > don't want to step on anybodies foots along the way if i change this...
> >
> 
> You really wouldn't. When you spot a regression caused by a commit
> that doesn't mention the regression anywhere (commit log or in the
> code), it's almost certainly unwanted. So a patch is welcome :)
> It's just as Dan said, the only use of Include I ever see if to
> include mirror list in Server section, so I overlooked your usage.
> 
> Can you please test the attached untested patch ?

This worked as expected.

As Dan allready merged it into master i rebased my patch to it and
attached is a tested and working version of include globbing.

Thanks,

Marc
>From 7d34f11dce2b25e7f30bf6fdbbc8f72edf2ae695 Mon Sep 17 00:00:00 2001
From: Marc-A. Dahlhaus <m...@wol.de>
Date: Tue, 18 May 2010 14:32:02 +0200
Subject: [PATCH] Allow to include a path containing wildcards


Signed-off-by: Marc-A. Dahlhaus <m...@wol.de>
---
 configure.ac          |    2 +-
 doc/pacman.conf.5.txt |    2 +-
 src/pacman/pacman.c   |   24 ++++++++++++++++++++++--
 3 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index 9760ba8..4307fb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,7 +155,7 @@ fi
 AM_CONDITIONAL(INTERNAL_DOWNLOAD, test "x$internaldownload" = "xyes")
 
 # Checks for header files.
-AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h])
+AC_CHECK_HEADERS([fcntl.h glob.h libintl.h limits.h locale.h string.h strings.h sys/ioctl.h sys/param.h sys/statvfs.h sys/syslimits.h sys/time.h syslog.h wchar.h])
 
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt
index 89c22a1..339019d 100644
--- a/doc/pacman.conf.5.txt
+++ b/doc/pacman.conf.5.txt
@@ -98,7 +98,7 @@ Options
 
 *Include =* path::
 	Include another config file. This file can include repositories or
-	general configuration  options.
+	general configuration options. Wildcards in path get expanded.
 
 *Architecture =* auto | i686 | x86_64 | ...::
 	If set, pacman will only allow installation of packages of the given
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 6ecda05..e519886 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -39,6 +39,7 @@
 #include <locale.h> /* setlocale */
 #include <time.h> /* time_t */
 #include <errno.h>
+#include <glob.h>
 #if defined(PACMAN_DEBUG) && defined(HAVE_MCHECK_H)
 #include <mcheck.h> /* debug tracing (mtrace) */
 #endif
@@ -967,9 +968,28 @@ static int _parseconfig(const char *file, const char *givensection,
 				ret = 1;
 				goto cleanup;
 			}
-			pm_printf(PM_LOG_DEBUG, "config: including %s\n", value);
 			/* Ignore include failures... assume non-critical */
-			_parseconfig(value, section, db);
+			int globret;
+			glob_t globbuf;
+			globret = glob(value, GLOB_NOCHECK, NULL, &globbuf);
+			switch(globret) {
+				case GLOB_NOSPACE:
+					pm_printf(PM_LOG_DEBUG, "config file %s, line %d: include globing out of space\n", file, linenum);
+				break;
+				case GLOB_ABORTED:
+					pm_printf(PM_LOG_DEBUG, "config file %s, line %d: include globing read error for %s\n", file, linenum, value);
+				break;
+				case GLOB_NOMATCH:
+					pm_printf(PM_LOG_DEBUG, "config file %s, line %d: no include found for %s\n", file, linenum, value);
+				break;
+				default:
+					for(int gindex = 0; gindex < globbuf.gl_pathc; gindex++) {
+						pm_printf(PM_LOG_DEBUG, "config file %s, line %d: including %s\n", file, linenum, globbuf.gl_pathv[gindex]);
+						_parseconfig(globbuf.gl_pathv[gindex], section, db);
+					}
+				break;
+			}
+			globfree(&globbuf);
 			continue;
 		}
 		if(strcmp(section, "options") == 0) {
-- 
1.7.0.5



Reply via email to