[lxc-devel] [PATCH] allow multiple types of init scripts to be configured

Dwight Engen dwight.engen at oracle.com
Mon Jan 6 19:05:12 UTC 2014


Signed-off-by: Dwight Engen <dwight.engen at oracle.com>
---
 configure.ac | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/configure.ac b/configure.ac
index fb61e26..a200460 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,21 +73,10 @@ AM_CONDITIONAL([DISTRO_UBUNTU], [test "x$with_distro" = "xubuntu"])
 # Check for init system type
 AC_MSG_CHECKING([for init system type])
 AC_ARG_WITH([init-script],
-	    [AC_HELP_STRING([--with-init-script@<:@=TYPE@:>@],
-			    [Type of init script to install: sysv, systemd, upstart,
-			     distro, none @<:@default=distro@:>@])],[],[with_init_script=distro])
+	    [AC_HELP_STRING([--with-init-script@<:@=TYPE@<:@,TYPE,...@:>@@:>@],
+			    [Type(s) of init script to install: sysv, systemd, upstart,
+			     distro @<:@default=distro@:>@])],[],[with_init_script=distro])
 case "$with_init_script" in
-	sysv)
-		init_script=sysv
-		;;
-	systemd)
-		init_script=systemd
-		;;
-	upstart)
-		init_script=upstart
-		;;
-	none)
-		;;
 	distro)
 		case $with_distro in
 			fedora)
@@ -97,7 +86,7 @@ case "$with_init_script" in
 				init_script=sysv
 				;;
 			ubuntu)
-				init_script=upstart
+				init_script=sysv,upstart
 				;;
 			*)
 				echo -n "Linux distribution init system unknown, defaulting to sysv"
@@ -106,12 +95,25 @@ case "$with_init_script" in
 		esac
 		;;
 	*)
-		AC_MSG_ERROR([Unknown init system type $with_init_script])
+		init_script=$with_init_script
 		;;
 esac
-AM_CONDITIONAL([INIT_SCRIPT_SYSV], test "$init_script" = "sysv")
-AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], test "$init_script" = "systemd")
-AM_CONDITIONAL([INIT_SCRIPT_UPSTART], test "$init_script" = "upstart")
+
+# Check valid init systems were given, run in subshell so we don't mess up IFS
+(IFS="," ; for init_sys in $init_script;
+do
+	case "$init_sys" in
+		none|sysv|systemd|upstart)
+			;;
+		*)
+			exit 1
+			;;
+	esac
+done) || AC_MSG_ERROR([Unknown init system type in $init_script])
+
+AM_CONDITIONAL([INIT_SCRIPT_SYSV], [echo "$init_script" |grep -q "sysv"])
+AM_CONDITIONAL([INIT_SCRIPT_SYSTEMD], [echo "$init_script" |grep -q "systemd"])
+AM_CONDITIONAL([INIT_SCRIPT_UPSTART], [echo "$init_script" |grep -q "upstart"])
 AC_MSG_RESULT($init_script)
 
 # Allow disabling rpath
@@ -659,7 +661,7 @@ cat << EOF
 Environment:
  - compiler: $CC
  - distribution: $with_distro
- - init script type: $init_script
+ - init script type(s): $init_script
  - rpath: $enable_rpath
  - GnuTLS: $enable_gnutls
 
-- 
1.8.3.1



More information about the lxc-devel mailing list