]> git.proxmox.com Git - mirror_lxc.git/commitdiff
Expand the configure directory
authordlezcano <dlezcano>
Mon, 1 Dec 2008 11:50:43 +0000 (11:50 +0000)
committerdlezcano <dlezcano>
Mon, 1 Dec 2008 11:50:43 +0000 (11:50 +0000)
From: Daniel Lezcano <dlezcano@fr.ibm.com>

Expand the configure variable specifying the directories in order to use
them directly in the scripts.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
config/acinclude.m4 [new file with mode: 0644]
configure.in
scripts/lxc-debian.in
scripts/lxc-sshd.in
src/lxc/lxc-ls.in
src/lxc/lxc-netstat.in
src/lxc/lxc-ps.in

diff --git a/config/acinclude.m4 b/config/acinclude.m4
new file mode 100644 (file)
index 0000000..02629ce
--- /dev/null
@@ -0,0 +1,44 @@
+dnl as-ac-expand.m4 0.2.0
+dnl autostars m4 macro for expanding directories using configure's prefix
+dnl thomas@apestaart.org
+dnl
+dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
+dnl example
+dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
+dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
+AC_DEFUN([AS_AC_EXPAND],
+[
+    EXP_VAR=[$1]
+    FROM_VAR=[$2]
+    dnl first expand prefix and exec_prefix if necessary
+    prefix_save=$prefix
+    exec_prefix_save=$exec_prefix
+    dnl if no prefix given, then use /usr/local, the default prefix
+    if test "x$prefix" = "xNONE"; then
+        prefix="$ac_default_prefix"
+    fi
+    dnl if no exec_prefix given, then use prefix
+    if test "x$exec_prefix" = "xNONE"; then
+        exec_prefix=$prefix
+    fi
+    full_var="$FROM_VAR"
+    dnl loop until it doesn't change anymore
+    while true; do
+        new_full_var="`eval echo $full_var`"
+        if test "x$new_full_var" = "x$full_var"; then break; fi
+        full_var=$new_full_var
+    done
+    dnl clean up
+    full_var=$new_full_var
+    AC_SUBST([$1], "$full_var")
+    dnl restore prefix and exec_prefix
+    prefix=$prefix_save
+    exec_prefix=$exec_prefix_save
+])
\ No newline at end of file
index 0b65e3482970cbda64eae6fd07a78fe29d287fe2..45981e23c2fe9d0ccf7f073355fdae9de68c4181 100644 (file)
@@ -15,7 +15,9 @@ AC_PROG_LIBTOOL
 AC_CHECK_PROG(SETCAP, setcap, yes, no)
 AC_CHECK_PROG(DOCBOOK, docbook2man, yes, no)
 AM_CONDITIONAL(ENABLE_DOCBOOK, test x$DOCBOOK = xyes)
-PKG_PROG_PKG_CONFIG
+AS_AC_EXPAND(BINDIR, $bindir)
+AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
+AS_AC_EXPAND(LOCALSTATEDIR, $localstatedir)
 
 AC_CHECK_HEADERS([linux/netlink.h linux/genetlink.h], [], AC_MSG_ERROR([netlink headers not found]),
 [#include <linux/types.h>
index 355b03d872c8850c18921cd0b8c1e8698f801c6e..a71d802b23165d12043ccd7d9b1261b44a05bc0e 100755 (executable)
@@ -11,7 +11,7 @@ INTERFACES="/etc/network/interfaces"
 INITTAB="/etc/inittab"
 HOSTNAME="/etc/hostname"
 FSTAB="/etc/fstab"
-CACHE="/var/cache/lxc/debian"
+CACHE="@LOCALSTATEDIR@/cache/lxc/debian"
 
 create() {
 
@@ -172,7 +172,7 @@ EOF
 
 # create the container object
 
-lxc-create -n $NAME -f $CONFFILE
+@BINDIR@/lxc-create -n $NAME -f $CONFFILE
 
 # remove the configuration files
 
@@ -192,7 +192,7 @@ destroy() {
        NAME=$_NAME_
     fi
 
-    lxc-destroy -n $NAME
+    @BINDIR@/lxc-destroy -n $NAME
     RETVAL=$?
     if [ ! $RETVAL -eq 0 ]; then
        echo "Failed to destroyed '$NAME'"
@@ -257,10 +257,7 @@ purge() {
        fi
 
        echo -n "Purging the download cache..."
-       # I don't use here the variable, just to be sure
-       # nobody touching the CACHE variable will lead to
-       # remove the real rootfs '/'.
-       rm -rf /var/cache/lxc/debian/* && echo "Done." || exit 1
+       rm --preserve-root --one-file-system -rf $CACHE && echo "Done." || exit 1
        exit 0
 
     ) 200>/var/lock/subsys/lxc
index 118c409781d3678098fb319850d2658115ab04f1..4a65230614c59f205763a10e2e6ba2db058a4219 100755 (executable)
@@ -407,7 +407,7 @@ cat <<EOF >> $MNTFILE
 EOF
 fi
 
-    lxc-create -n $NAME -f $CONFFILE
+    @BINDIR@/lxc-create -n $NAME -f $CONFFILE
 
     rm -f $MNTFILE
     rm -f $CONFFILE
@@ -434,7 +434,7 @@ destroy() {
        rm -rf $ROOTFS
     fi
 
-    lxc-destroy -n $NAME
+    @BINDIR@/lxc-destroy -n $NAME
 }
 
 help() {
index b00116b45af08191da7b50563186643a0c71f505..49722d16bbad7e37226a44ff8b3b8d63d28d9095 100644 (file)
@@ -1,7 +1,6 @@
 #!/bin/bash
 
-prefix=@prefix@
-lxcpath=@localstatedir@/lxc
+lxcpath=@LOCALSTATEDIR@/lxc
 
 if [ ! -r $lxcpath ]; then
     exit 0
index 0ccc1521a0900554d2de3c873c0ac1a7d2859764..072b4f4f44c05c27915de0df0fe4817443a93da2 100644 (file)
@@ -1,8 +1,7 @@
 #!/bin/bash
 # set -ex
 
-prefix=@prefix@
-lxcpath=@localstatedir@/lxc
+lxcpath=@LOCALSTATEDIR@/lxc
 exec=""
 
 if [ ! -r $lxcpath ]; then
@@ -24,7 +23,7 @@ for i in $*; do
 done
 
 if [ -z "$exec" ]; then
-    exec @bindir@/lxc-unshare -m -- @bindir@/lxc-netstat -n $name --exec $*
+    exec @BINDIR@/lxc-unshare -m -- @BINDIR@/lxc-netstat -n $name --exec $*
 fi
 
 if [ -z "$name" ]; then
index 165726ae554339e0e3b37780bbb64f0951e45a20..efbafb234459c11d7153587e664b4ab899f76740 100755 (executable)
@@ -1,8 +1,7 @@
 #!/bin/bash
 # set -ex
 
-prefix=@prefix@
-lxcpath=@localstatedir@/lxc
+lxcpath=@LOCALSTATEDIR@/lxc
 
 if [ ! -r $lxcpath ]; then
     exit 0