From: dlezcano Date: Mon, 1 Dec 2008 11:50:43 +0000 (+0000) Subject: Expand the configure directory X-Git-Tag: lxc_0_5_0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ad641d5bf0aeda5c3415eece2013bae128f1ad5;p=thirdparty%2Flxc.git Expand the configure directory From: Daniel Lezcano Expand the configure variable specifying the directories in order to use them directly in the scripts. Signed-off-by: Daniel Lezcano --- diff --git a/config/acinclude.m4 b/config/acinclude.m4 new file mode 100644 index 000000000..02629ce85 --- /dev/null +++ b/config/acinclude.m4 @@ -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 diff --git a/configure.in b/configure.in index 0b65e3482..45981e23c 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/scripts/lxc-debian.in b/scripts/lxc-debian.in index 355b03d87..a71d802b2 100755 --- a/scripts/lxc-debian.in +++ b/scripts/lxc-debian.in @@ -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 diff --git a/scripts/lxc-sshd.in b/scripts/lxc-sshd.in index 118c40978..4a6523061 100755 --- a/scripts/lxc-sshd.in +++ b/scripts/lxc-sshd.in @@ -407,7 +407,7 @@ cat <> $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() { diff --git a/src/lxc/lxc-ls.in b/src/lxc/lxc-ls.in index b00116b45..49722d16b 100644 --- a/src/lxc/lxc-ls.in +++ b/src/lxc/lxc-ls.in @@ -1,7 +1,6 @@ #!/bin/bash -prefix=@prefix@ -lxcpath=@localstatedir@/lxc +lxcpath=@LOCALSTATEDIR@/lxc if [ ! -r $lxcpath ]; then exit 0 diff --git a/src/lxc/lxc-netstat.in b/src/lxc/lxc-netstat.in index 0ccc1521a..072b4f4f4 100644 --- a/src/lxc/lxc-netstat.in +++ b/src/lxc/lxc-netstat.in @@ -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 diff --git a/src/lxc/lxc-ps.in b/src/lxc/lxc-ps.in index 165726ae5..efbafb234 100755 --- a/src/lxc/lxc-ps.in +++ b/src/lxc/lxc-ps.in @@ -1,8 +1,7 @@ #!/bin/bash # set -ex -prefix=@prefix@ -lxcpath=@localstatedir@/lxc +lxcpath=@LOCALSTATEDIR@/lxc if [ ! -r $lxcpath ]; then exit 0