3
unset TMP TEMP TMPDIR || true
5
if [ "$DEBOOTSTRAP_DIR" = "" ]; then
6
DEBOOTSTRAP_DIR=/usr/lib/debootstrap
9
if [ -x "/usr/bin/gettext" ]; then
10
USE_GETTEXT_INTERACTION=yes
13
DEVICES_TARGZ=$DEBOOTSTRAP_DIR/devices.tar.gz
15
. $DEBOOTSTRAP_DIR/functions
21
DEBCONF_ADMIN_EMAIL=""
23
export LANG USE_COMPONENTS DEBCONF_ADMIN_EMAIL
28
info USAGE1 "usage: [OPTION]... <suite> <target> [<mirror> [<script>]]"
29
info USAGE2 "Try \`${0##*/} --help' for more information."
35
echo "Usage: ${0##*/} [OPTION]... <suite> <target> [<mirror> [<script>]]"
36
echo "Bootstrap Debian base system."
39
--arch set the target architecture (use if no dpkg)
41
--download-only download packages, but don't perform installation
42
--print-debs print the packages to be installed, and exit
43
--unpack-tarball acquire .debs from a tarball instead of http
44
--boot-floppies used for internal purposes by boot-floppies
45
--debian-installer used for internal purposes by debian-installer
46
--help display this help and exit
47
--include=A,B,C adds specified names to the list of base packages
48
--exclude=A,B,C removes specified packages from the list
49
--verbose don't turn off the output of wget
50
--components=A,B,C use packages from the listed components of the
52
--variant=X use variant X of the bootstrap scripts
53
(currently supported variants: buildd)
65
if [ -n "$USE_DEBIANINSTALLER_INTERACTION" ] ; then
66
error 1 ARG_BFDI "Can only use one of --boot-floppies and --debian-installer"
68
if ! (echo -n "" >&3) 2>/dev/null; then
69
error 1 ARG_BFBYHAND "If running debootstrap by hand, don't use --boot-floppies"
71
USE_BOOTFLOPPIES_INTERACTION=yes
75
if [ -n "$USE_BOOTFLOPPIES_INTERACTION" ] ; then
76
error 1 ARG_BFDI "Can only use one of --boot-floppies and --debian-installer"
78
if ! (echo -n "" >&3) 2>/dev/null; then
79
error 1 ARG_DIBYHAND "If running debootstrap by hand, don't use --debian-installer"
81
USE_DEBIANINSTALLER_INTERACTION=yes
97
error 1 NEEDARG "option requires an argument %s" "$1"
101
if [ -n "$2" ] ; then
102
if [ ! -f "$2" ] ; then
103
error 1 NOTARBALL "%s: No such file or directory" "$2"
108
error 1 NEEDARG "option requires an argument %s" "$1"
112
additional="$(echo $1 | cut -f2 -d"="|tr , " ")"
116
exclude="$(echo $1 | cut -f2 -d"="|tr , " ")"
125
USE_COMPONENTS="$(echo "$1" | cut -f2 -d"="|tr , "|")"
126
export USE_COMPONENTS
130
VARIANT="$(echo "$1" | cut -f2 -d"=")"
139
usage_err 1 NEEDSUITETARGET "You must specify a suite and a target."
142
if [ "$1" = "" -o \( "$2" = "" -a "$JUST_PRINT_DEBS" = "" \) ]; then
143
usage_err 1 NEEDSUITETARGET "You must specify a suite and a target."
148
if [ "${TARGET#/}" = "${TARGET}" ]; then
149
if [ "${TARGET%/*}" = "$TARGET" ] ; then
150
TARGET="$(echo `pwd`/$TARGET)"
152
TARGET="$(cd ${TARGET%/*}; echo `pwd`/${TARGET##*/})"
156
MIRRORS="http://ftp.debian.org/debian"
157
SCRIPT="$DEBOOTSTRAP_DIR/scripts/$1"
158
if [ -n "$VARIANT" ]; then
159
SCRIPT="${SCRIPT}.${VARIANT}"
161
if [ "$3" != "" ]; then
163
if [ "$4" != "" ]; then
168
# Remove trailing /'s
170
MIRRORS="${MIRRORS%/}"
172
if [ "$ARCH" != "" ]; then
174
elif [ -x /usr/bin/dpkg ] && /usr/bin/dpkg --print-installation-architecture >/dev/null 2>&1
176
ARCH=`/usr/bin/dpkg --print-installation-architecture`
177
elif [ -e $DEBOOTSTRAP_DIR/arch ]; then
178
ARCH=`cat $DEBOOTSTRAP_DIR/arch`
180
error 1 WHATARCH "Couldn't work out current architecture"
183
export MIRRORS ARCH SUITE TARGET
185
if [ "$JUST_PRINT_DEBS" = "" -a "$DOWNLOAD_ONLY" = "" -a -x /usr/bin/id ] && [ `id -u` -ne 0 ]; then
186
error 1 NEEDROOT "debootstrap can only run as root"
189
if [ ! -e "$SCRIPT" ]; then
190
error 1 NOSCRIPT "No such script: %s" "$SCRIPT"
195
PKGDETAILS=$DEBOOTSTRAP_DIR/pkgdetails
197
if [ "$UNPACK_TARBALL" ]; then
198
if [ "${UNPACK_TARBALL#/}" = "$UNPACK_TARBALL" ]; then
199
error 1 TARPATH "Tarball must be given a complete path"
201
if [ "${UNPACK_TARBALL%.tar}" != "$UNPACK_TARBALL" ]; then
202
(cd "$TARGET" && tar -xf "$UNPACK_TARBALL")
203
elif [ "${UNPACK_TARBALL%.tgz}" != "$UNPACK_TARBALL" ]; then
204
(cd "$TARGET" && zcat "$UNPACK_TARBALL" | tar -xf -)
206
error 1 NOTTAR "Unknown tarball: must be either .tar or .tgz"
214
if [ "$JUST_PRINT_DEBS" ]; then
221
if [ "$DOWNLOAD_ONLY" ]; then
227
if [ -e "$TARGET/etc/apt/sources.list" ]; then
228
rm -f "$TARGET/etc/apt/sources.list"
233
if [ -n "$USE_BOOTFLOPPIES_INTERACTION" ] ; then
234
echo "I: debootstrap: Successfully completed" # goes to /dev/tty4
235
sleep 1 || true # give the user a second to see the success notice.