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.
25 function initVariables
29 test -n "${MIRROR}" || {
31 findFile aux "$__CONFDIR"/.distributions/"$DISTRIBUTION"/debootstrap.mirror \
32 "$__CONFDIR"/.defaults/apps/debootstrap/mirror \
33 "$__DISTRIBDIR"/"$DISTRIBUTION"/debootstrap.mirror \
34 "$__PKGLIBDEFAULTDIR"/debootstrap.mirror ''
35 test -z "$aux" || read MIRROR <"$aux"
38 findFile file "$__CONFDIR"/.distributions/"$DISTRIBUTION"/debootstrap.options \
39 "$__CONFDIR"/.defaults/apps/debootstrap/options ''
40 test -z "$file" || read options <"$file"
43 function initFilesystem
45 base.initFilesystem "$1"
47 mkdir -p "$SETUP_CONFDIR"/apps/pkgmgmt
48 touch "$SETUP_CONFDIR"/apps/pkgmgmt/internal
51 function findDebootstrap
53 test ! -x "$DEBOOTSTRAP" || return 0
56 DEBOOTSTRAP=$(which debootstrap 2>/dev/null) || {
57 dir=$($_MKTEMPDIR -p /var/tmp debootstrap.XXXXXX)
59 dst=$dir/debootstrap.deb
61 base._addGeneratedFile "$workdir"
63 findFile DEBOOTSTRAP_URI "$__CONFDIR"/.defaults/apps/debootstrap/uri "$__PKGLIBDEFAULTDIR"/debootstrap.uri
64 read tmp <$DEBOOTSTRAP_URI
66 (/*) ln -s "$tmp" "$dst";;
69 Could not find local version of 'debootstrap'; downloading it from
71 $_WGET -nv -O "$dst" "$tmp" || {
73 ERROR: Could not download the debootstrap package from
77 Usually, this means that Debian released a new version which is unknown
78 to util-vserver and removed the known ones. To fix this, go to
80 http://ftp.debian.org/debian/pool/main/d/debootstrap/
82 (or a nearby mirror) and search the URL for the most recent *.deb
83 package matching your platform. Then, put this URL into
85 $__CONFDIR/.defaults/apps/debootstrap/uri
87 and retry the vserver-build command again.
92 (*) echo $"Unsupported URI scheme '$tmp'" >&2
98 DEBOOTSTRAP_DIR=`pwd`/usr/lib/debootstrap
99 DEBOOTSTRAP=`pwd`/usr/sbin/debootstrap
100 test -d "$DEBOOTSTRAP_DIR" || DEBOOTSTRAP_DIR=`pwd`/usr/share/debootstrap
101 export DEBOOTSTRAP_DIR
104 arch=$(uname -i 2>/dev/null) || \
105 arch=$(arch 2>/dev/null) ||
108 ## Wash the calculated architecture
110 (i?86|athlon) arch=i386;;
113 test -z "$arch" || echo "$arch" >$DEBOOTSTRAP_DIR/arch
117 test -x "$DEBOOTSTRAP" || { echo $"Can not find debootstrap at '$DEBOOTSTRAP'" >&2; exit 1; }
123 $_MV "$1"/dev.X "$1"/dev
127 ### main starts here <---
130 tmp=$(getopt -o '+d:m:s:' --long debug -n "$0" -- "$@") || exit 1
137 (-d) DISTRIBUTION=$2; shift;;
138 (-m) MIRROR=$2; shift;;
139 (-s) script=$2; shift;;
142 (*) echo "vserver-build.debootstrap: internal error: unrecognized option '$1'" >&2
152 initFilesystem "$OPTION_FORCE"
154 setup_writeOption "$VSERVER_NAME"
155 setup_writeInitialFstab
159 if test -z "$script"; then
160 findFile script "$__CONFDIR/.distributions/$DISTRIBUTION/debootstrap.script" \
161 "$__DISTRIBDIR/$DISTRIBUTION/debootstrap.script" ''
165 test -z "$BUILD_INITPRE" || "$BUILD_INITPRE" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"
166 mv "$VDIR"/dev "$VDIR"/dev.X
167 "$_VNAMESPACE" --new -- \
168 "$DEBOOTSTRAP" $options "$@" "$DISTRIBUTION" "$VDIR" "$MIRROR" "$script" || : ## HACK: ignore all errors...
170 test -z "$BUILD_INITPOST" || "$BUILD_INITPOST" "$SETUP_CONFDIR" "$UTIL_VSERVER_VARS"