From 402a84fc44f892bd41910f0cded57e1d06d07815 Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Thu, 30 Jun 2005 06:16:08 +0000 Subject: [PATCH] remove generated vserver when build fails and '--keep' was not specified git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2109 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/scripts/vserver-build.functions | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/util-vserver/scripts/vserver-build.functions b/util-vserver/scripts/vserver-build.functions index c2e7f74..bd617ad 100644 --- a/util-vserver/scripts/vserver-build.functions +++ b/util-vserver/scripts/vserver-build.functions @@ -30,6 +30,9 @@ _EXEC_DIR= BUILD_INITPRE= BUILD_INITPOST= +__BASE_GENERATED_FILES=() +__BASE_SUCCESS= + function makeDevEntry { local dst=$1/$2 @@ -143,6 +146,11 @@ with the '-d' option" >&2 fi >&2 } +function base._addGeneratedFile +{ + __BASE_GENERATED_FILES=( "${__BASE_GENERATED_FILES[@]}" "$@" ) +} + ## Usage: initFilesystem [force] function base.initFilesystem { @@ -157,7 +165,10 @@ exist already; please try to use '--force', or remove them manually" mkdir -p -m755 "$VDIR" chattr -t "$VDIR" + base._addGeneratedFile "$VDIR" + mkdir -p -m755 "$SETUP_CONFDIR"/apps "$VDIR"/{dev/pts,etc} + base._addGeneratedFile "$SETUP_CONFDIR" ln -s "$VDIR" "$SETUP_CONFDIR/vdir" @@ -175,7 +186,7 @@ exist already; please try to use '--force', or remove them manually" done } -function base.initVariables +function base._initVariables { _setRootDir _setVserverDir @@ -186,3 +197,22 @@ function base.initVariables findFile BUILD_INITPRE "$__CONFDIR/.distributions/$DISTRIBUTION/initpre" "$__DISTRIBDIR/$DISTRIBUTION/initpre" "" findFile BUILD_INITPOST "$__CONFDIR/.distributions/$DISTRIBUTION/initpost" "$__DISTRIBDIR/$DISTRIBUTION/initpost" "" } + +function base.__cleanup +{ + test -z "$OPTION_KEEP" || return 0 + test -z "$__BASE_SUCCESS" || return 0 + + echo rm -rf "${__BASE_GENERATED_FILES[@]}" +} + +function base.init +{ + trap "base.__cleanup" EXIT + base._initVariables +} + +function base.setSuccess +{ + __BASE_SUCCESS=1 +} -- 1.8.1.5