Expand the configure directory

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>
This commit is contained in:
dlezcano 2008-12-01 11:50:43 +00:00
parent b6d441f289
commit 7ad641d5bf
7 changed files with 57 additions and 17 deletions

44
config/acinclude.m4 Normal file
View File

@ -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
])

View 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>

View File

@ -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

View File

@ -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() {

View File

@ -1,7 +1,6 @@
#!/bin/bash
prefix=@prefix@
lxcpath=@localstatedir@/lxc
lxcpath=@LOCALSTATEDIR@/lxc
if [ ! -r $lxcpath ]; then
exit 0

View 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

View File

@ -1,8 +1,7 @@
#!/bin/bash
# set -ex
prefix=@prefix@
lxcpath=@localstatedir@/lxc
lxcpath=@LOCALSTATEDIR@/lxc
if [ ! -r $lxcpath ]; then
exit 0