3 # Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 test ! -d "$workdir" || $_RM -rf "$workdir"
30 function initVariables
34 test "${mirror-unset}" || {
36 findFile aux "$CONFDIR"/.defaults/apps/debootstrap/mirror ''
37 test -z "$aux" || read mirror <"$aux"
41 function initFilesystem
43 base.initFilesystem "$1"
45 mkdir -p "$SETUP_CONFDIR"/apps/pkgmgmt
46 touch "$SETUP_CONFDIR"/apps/pkgmgmt/internal
49 function findDebootstrap
52 DEBOOTSTRAP=$(which debootstrap 2>/dev/null) || {
53 dir=$($_MKTEMPDIR /var/tmp/debootstrap.XXXXXX)
55 dst=$dir/debootstrap.deb
57 findFile DEBOOTSTRAP_URI "$CONFDIR"/.defaults/apps/debootstrap/uri "$PKGLIBDEFAULTDIR"/debootstrap.uri
58 read tmp <$DEBOOTSTRAP_URI
60 (/*) ln -s "$tmp" "$dst";;
62 $_WGET -nv -O "$dst" "$tmp" || {
64 ERROR: Could not download the debootstrap package from
68 Usually, this means that Debian released a new version which is unknown
69 to util-vserver and removed the known ones. To fix this, go to
71 http://ftp.debian.org/debian/pool/main/d/debootstrap/
73 (or a nearby mirror) and search the URL for the most recent *.deb
74 package matching your platform. Then, put this URL into
76 $CONFDIR/.defaults/apps/debootstrap/uri
78 and retry the vserver-build command again.
83 (*) echo $"Unsupported URI scheme '$tmp'" >&2
89 export DEBOOTSTRAP_DIR=`pwd`/usr/lib/debootstrap
90 DEBOOTSTRAP=`pwd`/usr/sbin/debootstrap
94 test -x "$DEBOOTSTRAP" || { echo $"Can not find debootstrap at '$DEBOOTSTRAP'" >&2; exit 1; }
100 $_MV "$1"/dev.X "$1"/dev
104 ### main starts here <---
107 tmp=$(getopt -o '+d:m:' --long debug -n "$0" -- "$@") || exit 1
114 -d) DISTRIBUTION=$2; shift;;
115 -m) mirror=$2; shift;;
118 *) echo "vserver-build.debootstrap: internal error: unrecognized option '$1'" >&2
128 initFilesystem "$OPTION_FORCE"
130 setup_writeOption "$VSERVER_NAME"
131 setup_writeInitialFstab
135 test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
136 mv "$VDIR"/dev "$VDIR"/dev.X
137 "$DEBOOTSTRAP" "$@" "$DISTRIBUTION" "$VDIR" "$mirror" || : ## HACK: ignore all errors...
139 test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"