summaryrefslogtreecommitdiff
path: root/run-bootstrap-in-chroot
diff options
context:
space:
mode:
Diffstat (limited to 'run-bootstrap-in-chroot')
-rwxr-xr-xrun-bootstrap-in-chroot199
1 files changed, 0 insertions, 199 deletions
diff --git a/run-bootstrap-in-chroot b/run-bootstrap-in-chroot
deleted file mode 100755
index fbe1e9f5..00000000
--- a/run-bootstrap-in-chroot
+++ /dev/null
@@ -1,199 +0,0 @@
-#!/bin/bash
-
-set -e
-
-unmount_virtual()
-{
- umount "$1/proc" || true
- umount "$1/sys" || true
- umount "$1/tree/proc" || true
- umount "$1/tree/sys" || true
-}
-
-pass_snapshot()
-{
- echo -n "$snapshotdir/$1-snapshot.tar.gz"
-}
-
-has_pass()
-{
- if [ -e $(pass_snapshot "$1") ]
- then
- return 0
- else
- return 1
- fi
-}
-
-update_morph()
-{
- local dir="$1"
- cp baserock-bootstrap "$dir/." # update bootstrap script
- rm -rf "$dir/tree/baserock/gits/morph"
- mkdir -p "$dir/tree/baserock/gits/morph"
-
- # Copy everything except the target directory into the target directory.
- # The point is to be able to keep the working area for a bootstrap inside
- # the morph source directory. This is useful for Jenkins jobs.
- local base=$(basename $(basename "$dir"))
- find . -mindepth 1 -maxdepth 1 ! -name "$base" ! -name '*.tar.gz' \
- -exec cp -a '{}' "$dir/tree/baserock/gits/morph" ';'
-}
-
-run_pass()
-{
- local dir="$1"
- local passname="$2"
- local tarball=$(pass_snapshot "$passname")
-
- if "$snapshot" && has_pass "$passname"
- then
- tar -C "$dir" -xhf "$tarball"
- update_morph "$dir"
- else
- update_morph "$dir"
- "./do-squeeze-chroot" bash -x baserock-bootstrap "$passname" || exit 1
- if "$snapshot"
- then
- tar -C "$dir" -caf "$tarball" .
- fi
- fi
-}
-
-export LC_ALL=C
-
-if [ "x$1" = x ]
-then
- echo "Usage: $0 chroot-dir" 1>&2
- exit 1
-fi
-
-mkdir -p "$1"
-dir="$1/squeeze-chroot"
-: ${snapshot:=true}
-snapshotdir="$1"
-
-cat >"./do-squeeze-chroot" <<EOF
-#!/bin/sh
-
-# clear the temporary directory used outside the chroot
-export TMPDIR=
-
-if mount -t proc proc "$dir/proc"; then
- trap "umount \"$dir/proc\"" INT TERM EXIT
- if mount -t sysfs sysfs "$dir/sys"; then
- trap "umount \"$dir/proc\" \"$dir/sys\"" INT TERM EXIT
- if [ "x$CCACHE_HOST_DIR" != "x" ]; then
- if mount --bind "$CCACHE_HOST_DIR" "$dir/var/tmp/ccache"; then
- trap "umount \"$dir/proc\" \"$dir/sys\" \"$dir/var/tmp/ccache\"" \
- INT TERM EXIT
- chroot "$dir" "\$@"
- fi
- else
- chroot "$dir" "\$@"
- fi
- fi
-fi
-EOF
-chmod +x "./do-squeeze-chroot"
-
-if ([ "x$DEBIAN_MIRROR" = x ] && echo DEBIAN_MIRROR is unspecified >&2) ||
- ([ "x$GIT_TARBALLS" = x ] && echo GIT_TARBALLS is unspecified >&2)
-then
- echo You have to set DEBIAN_MIRROR and other environment variables 1>&2
- exit 1
-fi
-
-if ! which dpkg 2> /dev/null; then
- echo "Warning: dpkg not found -- should debootstrap fail to autodetect "
- echo "your architecture, set ARCH in the environment (probably to amd64)"
-fi
-
-# prepare the ccache directory in the chroot, if necessary
-if [ "x$CCACHE_HOST_DIR" = "x" ]; then
- # print a warning if the CCACHE_HOST_DIR is not set
- echo "CCACHE_HOST_DIR is unspecified, but that's ok" >&2
-fi
-
-unmount_virtual "$dir"
-rm -rf "$dir"
-mkdir "$dir"
-
-chrootsnapshot="$snapshotdir/squeeze.tar.gz"
-if ! "$snapshot" || ! has_pass pass1a; then
- if "$snapshot" && [ -e "$chrootsnapshot" ]
- then
- tar -C "$dir" -xhf "$chrootsnapshot"
- else
- EXTRAPACKAGES="build-essential,gawk,bison,flex,python,autoconf"
- EXTRAPACKAGES="$EXTRAPACKAGES,autopoint,automake,gettext,libtool"
- EXTRAPACKAGES="$EXTRAPACKAGES,help2man,texinfo,sudo,ccache,gperf"
- EXTRAPACKAGES="$EXTRAPACKAGES,python-pip,python-simplejson,python-yaml"
-
- EXTRAARGS=
- if [ -n $ARCH]; then
- EXTRAARGS=$ARCH
- fi
-
- debootstrap $EXTRAARGS --include="$EXTRAPACKAGES" squeeze \
- "$dir" "$DEBIAN_MIRROR"
-
- mkdir -p "$dir/etc"
- hostname > "$dir/etc/hostname"
- cat <<EOF > "$dir/etc/hosts"
-127.0.0.1 localhost
-127.0.1.1 `hostname`
-EOF
-
- # create the directory for cached ccache object files
- mkdir -p "$dir/var/tmp/ccache"
-
- # manually build and install cliapp
- "./do-squeeze-chroot" mkdir -p /src
- "./do-squeeze-chroot" \
- git clone git://roadtrain.codethink.co.uk/delta/cliapp /src/cliapp
- "./do-squeeze-chroot" \
- sh -c 'cd /src/cliapp && "$@"' -- python setup.py build
- "./do-squeeze-chroot" \
- sh -c 'cd /src/cliapp && "$@"' -- python setup.py install
-
- "./do-squeeze-chroot" pip install ordereddict
-
- if "$snapshot"
- then
- tar -caf "$chrootsnapshot" -C "$dir" .
- fi
- fi
-fi
-
-# Unpack existing snapshot, or run pass1 of bootstrap and then make snapshot.
-
-if ! "$snapshot" || ! has_pass pass1b
-then
- run_pass "$dir" pass1a
-fi
-
-if ! "$snapshot" || ! has_pass pass2a
-then
- run_pass "$dir" pass1b
-fi
-
-if ! "$snapshot" || ! has_pass pass2b
-then
- run_pass "$dir" pass2a
-fi
-
-if ! "$snapshot" || ! has_pass pass3a
-then
- run_pass "$dir" pass2b
-fi
-
-if ! "$snapshot" || ! has_pass pass3b
-then
- run_pass "$dir" pass3a
-fi
-
-snapshot=false run_pass "$dir" pass3b
-
-echo "Passes 1, 2, and 3 of bootstrap done (possibly cached)."
-