commit f1b816b72e895bab13041ca570d7f72fb72987ed
Author: Jose A. Lopes <jabolopes@google.com>
Date:   Fri Oct 11 10:12:32 2013 +0200

    Fix several search path configure options
    
    Fix several search path configure options to properly handle
    separators.
    
    Signed-off-by: Jose A. Lopes <jabolopes@google.com>
    Reviewed-by: Klaus Aehlig <aehlig@google.com>

diff --git a/Makefile.am b/Makefile.am
index 5b1b351..d00379d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1794,15 +1794,15 @@ src/AutoConf.hs: Makefile src/AutoConf.hs.in | stamp-directories
 	    -DSSH_LOGIN_USER="$(SSH_LOGIN_USER)" \
 	    -DSSH_CONSOLE_USER="$(SSH_CONSOLE_USER)" \
 	    -DEXPORT_DIR="$(EXPORT_DIR)" \
-	    -DOS_SEARCH_PATH="$(foreach i,$(OS_SEARCH_PATH),\"$(i)\":)" \
-	    -DES_SEARCH_PATH="$(foreach i,$(ES_SEARCH_PATH),\"$(i)\":)" \
+	    -DOS_SEARCH_PATH="\"$(OS_SEARCH_PATH)\"" \
+	    -DES_SEARCH_PATH="\"$(ES_SEARCH_PATH)\"" \
 	    -DXEN_BOOTLOADER="$(XEN_BOOTLOADER)" \
 	    -DXEN_CONFIG_DIR="$(XEN_CONFIG_DIR)" \
 	    -DXEN_KERNEL="$(XEN_KERNEL)" \
 	    -DXEN_INITRD="$(XEN_INITRD)" \
 	    -DKVM_KERNEL="$(KVM_KERNEL)" \
 	    -DSHARED_FILE_STORAGE_DIR="$(SHARED_FILE_STORAGE_DIR)" \
-	    -DIALLOCATOR_SEARCH_PATH="$(foreach i,$(IALLOCATOR_SEARCH_PATH),\"$(i)\":)" \
+	    -DIALLOCATOR_SEARCH_PATH="\"$(IALLOCATOR_SEARCH_PATH)\"" \
 	    -DKVM_PATH="$(KVM_PATH)" \
 	    -DIP_PATH="$(IP_PATH)" \
 	    -DSOCAT_PATH="$(SOCAT)" \
diff --git a/configure.ac b/configure.ac
index 2443a64..c08385a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,36 +91,33 @@ AC_ARG_WITH([xen-config-dir],
 AC_SUBST(XEN_CONFIG_DIR, $xen_config_dir)
 
 # --with-os-search-path=...
-# do a bit of black sed magic to for quoting of the strings in the list
 AC_ARG_WITH([os-search-path],
   [AS_HELP_STRING([--with-os-search-path=LIST],
     [comma separated list of directories to]
     [ search for OS images (default is /srv/ganeti/os)]
   )],
-  [os_search_path=`echo -n "$withval" | sed -e "s/\([[^,]]*\)/\1/g"`],
+  [os_search_path="$withval"],
   [os_search_path="/srv/ganeti/os"])
 AC_SUBST(OS_SEARCH_PATH, $os_search_path)
 
 # --with-extstorage-search-path=...
-# same black sed magic for quoting of the strings in the list
 AC_ARG_WITH([extstorage-search-path],
   [AS_HELP_STRING([--with-extstorage-search-path=LIST],
     [comma separated list of directories to]
     [ search for External Storage Providers]
     [ (default is /srv/ganeti/extstorage)]
   )],
-  [es_search_path=`echo -n "$withval" | sed -e "s/\([[^,]]*\)/\1/g"`],
+  [es_search_path="$withval"],
   [es_search_path="/srv/ganeti/extstorage"])
 AC_SUBST(ES_SEARCH_PATH, $es_search_path)
 
 # --with-iallocator-search-path=...
-# do a bit of black sed magic to for quoting of the strings in the list
 AC_ARG_WITH([iallocator-search-path],
   [AS_HELP_STRING([--with-iallocator-search-path=LIST],
     [comma separated list of directories to]
     [ search for instance allocators (default is $libdir/ganeti/iallocators)]
   )],
-  [iallocator_search_path=`echo -n "$withval" | sed -e "s/\([[^,]]*\)/\1/g"`],
+  [iallocator_search_path="$withval"],
   [iallocator_search_path="$libdir/$PACKAGE_NAME/iallocators"])
 AC_SUBST(IALLOCATOR_SEARCH_PATH, $iallocator_search_path)
 
diff --git a/src/AutoConf.hs.in b/src/AutoConf.hs.in
index eb7f0da..9c00056 100644
--- a/src/AutoConf.hs.in
+++ b/src/AutoConf.hs.in
@@ -28,6 +28,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
 module AutoConf where
 
+split :: String -> [String]
+split str =
+  case span (/= ',') str of
+    (x, []) -> [x]
+    (x, _:xs) -> x:split xs
+
 packageVersion :: String
 packageVersion = "PACKAGE_VERSION"
 
@@ -68,10 +74,10 @@ exportDir :: String
 exportDir = "EXPORT_DIR"
 
 osSearchPath :: [String]
-osSearchPath = OS_SEARCH_PATH[]
+osSearchPath = split OS_SEARCH_PATH
 
 esSearchPath :: [String]
-esSearchPath = ES_SEARCH_PATH[]
+esSearchPath = split ES_SEARCH_PATH
 
 xenBootloader :: String
 xenBootloader = "XEN_BOOTLOADER"
@@ -92,7 +98,7 @@ sharedFileStorageDir :: String
 sharedFileStorageDir = "SHARED_FILE_STORAGE_DIR"
 
 iallocatorSearchPath :: [String]
-iallocatorSearchPath = IALLOCATOR_SEARCH_PATH[]
+iallocatorSearchPath = split IALLOCATOR_SEARCH_PATH
 
 kvmPath :: String
 kvmPath = "KVM_PATH"
