From: Enrico Scholz Date: Wed, 4 Feb 2004 02:44:41 +0000 (+0000) Subject: initial checkin X-Git-Tag: VERSION_0_10~768 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c53cd37f715c52fbb47cbd7f6d0d9200b20ce861;p=util-vserver.git initial checkin git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@777 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/scripts/vserver-build.debootstrap b/util-vserver/scripts/vserver-build.debootstrap new file mode 100644 index 0000000..4e36d25 --- /dev/null +++ b/util-vserver/scripts/vserver-build.debootstrap @@ -0,0 +1,113 @@ +# $Id$ --*- sh -*-- + +# Copyright (C) 2003 Enrico Scholz +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +function cleanUp +{ + test ! -d "$workdir" || rm -rf "$workdir" +} + +function init +{ + workdir= + mirror= + trap "cleanUp" EXIT +} + +function initVariables +{ + base.initVariables + + test "${mirror-unset}" || { + local aux + findFile aux "$CONFDIR"/.defaults/apps/debootstrap/mirror '' + test -z "$aux" || read mirror <"$aux" + } +} + +function initFilesystem +{ + base.initFilesystem "$1" + + mkdir -p "$SETUP_CONFDIR"/apps/pkgmgmt + touch "$SETUP_CONFDIR"/apps/pkgmgmt/internal +} + +function findDebootstrap +{ + pushd . &>/dev/null + DEBOOTSTRAP=$(which debootstrap 2>/dev/null) || { + dir=$(mktemp -d /var/tmp/debootstrap.XXXXXX) + workdir=$dir + dst=$dir/debootstrap.deb + + findFile DEBOOTSTRAP_URI "$CONFDIR"/.defaults/debootstrap.uri "$PKGLIBDEFAULTDIR"/debootstrap.uri + read tmp <$DEBOOTSTRAP_URI + case "$tmp" in + (/*) ln -s "$tmp" "$dst";; + (http://*|ftp://*) $_WGET -q -O "$dst" "$tmp";; + (*) echo $"Unsupported URI scheme '$tmp'" >&2 + exit 1;; + esac + cd $dir + ar x "$dst" + tar xzf data.tar.gz + export DEBOOTSTRAP_DIR=`pwd`/usr/lib/debootstrap + DEBOOTSTRAP=`pwd`/usr/sbin/debootstrap + } + popd &>/dev/null + + test -x "$DEBOOTSTRAP" || { echo $"Can not find debootstrap at '$DEBOOTSTRAP'" >&2; exit 1; } +} + + +### main starts here <--- + + +tmp=$(getopt -o '+d:m:' --long debug -n "$0" -- "$@") || exit 1 +eval set -- "$tmp" + +init + +while true; do + case "$1" in + -d) DISTRIBUTION=$2; shift;; + -m) mirror=$2; shift;; + --debug) set -x;; + --) shift; break ;; + *) echo "vserver-build.skeleton: internal error: unrecognized option '$1'" + exit 1 + ;; + esac + shift +done + +getDistribution + +initVariables +initFilesystem "$OPTION_FORCE" + +setup_writeOption "$VSERVER_NAME" +setup_writeInitialFstab + +findDebootstrap + +test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS" +mv "$VDIR"/dev "$VDIR"/dev.X +"$DEBOOTSTRAP" "$DISTRIBUTION" "$VDIR" "$mirror" +rm -rf "$VDIR"/dev +mv "$VDIR"/dev.X "$VDIR"/dev +test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"