diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rwxr-xr-x | baserock-bootstrap | 28 | ||||
-rwxr-xr-x | run-bootstrap-in-chroot | 102 |
3 files changed, 105 insertions, 26 deletions
@@ -5,3 +5,4 @@ *.stdout-diff *.stderr-actual *.stderr-diff +do-squeeze-chroot diff --git a/baserock-bootstrap b/baserock-bootstrap index d5f2151f..eb5f3d3a 100755 --- a/baserock-bootstrap +++ b/baserock-bootstrap @@ -10,7 +10,13 @@ LFS="$(pwd)/tree" allsources="$LFS/../../lfs-tarballs" sources="$LFS/sources" tools="$LFS/tools" -SNAPSHOT="${1:-'no'}" +case "$1" in +y|ye|yes|t|tr|tru|true) + PASS1ONLY=true + ;; +n|no|f|fa|fal|fals|false|*) + PASS1ONLY=false +esac CPUS=$(grep -c '^processor' /proc/cpuinfo) JOBS=$(expr 2 '*' $CPUS) @@ -780,24 +786,28 @@ pass2_build_with_morph_in_chroot() set -e set -x -/tools/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache +#/tools/bin/ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache cd /baserock/gits/morph mkdir -p /baserock/cache +export PATH="/usr/bin:/bin:$tools/bin:$tools/sbin" python ./morph --verbose build \ - file:///baserock/gits/morphs/ master linux-stratum.morph \ - file:///baserock/gits/morphs/ master foundation.morph \ + file:///baserock/gits/morphs/ baserock/bootstrap foundation.morph \ file:///baserock/gits/morphs/ master devel.morph \ + file:///baserock/gits/morphs/ master linux-stratum.morph \ --bootstrap \ --cachedir=/baserock/cache \ --log=/baserock/morph.log \ --dump-memory-profile=none \ - --max-jobs=1 \ + --keep-path \ --git-base-url=file:///baserock/gits/ EOF $HOST_CHMOD +x "$LFS/baserock/build.sh" local do_chroot="$BASEDIR/do-chroot" if [ ! -e "$do_chroot" ]; then $HOST_CAT >"$do_chroot" <<EOF +trap "umount $LFS/proc $LFS/sys" EXIT +set -e +set -x if ! mount | grep "$LFS/proc" >/dev/null then $HOST_SUDO mount -t proc proc "$LFS/proc" @@ -835,6 +845,7 @@ pass2_build_devel_system_outside_chroot() $HOST_SUDO mkfs -t ext4 "$part" mp="$(mktemp -d)" $HOST_SUDO mount "$part" "$mp" + trap "$HOST_SUDO umount $part; $HOST_SUDO kpartx -dv $img" EXIT for stratum in "$LFS"/baserock/cache/*.stratum.{foundation,linux-stratum,devel} do @@ -911,11 +922,9 @@ pass1_git #pass1_strip_tools #pass1_fix_perms -if [ "$SNAPSHOT" = yes ] +if "$PASS1ONLY" then - cd "$LFS/.." - tar -caf tree-snapshot.tar tree - echo "See snapshot in tree-snapshot.tar" + echo "Only doing pass1" exit fi @@ -923,3 +932,4 @@ pass2_get_sources pass2_prepare_for_chroot pass2_build_with_morph_in_chroot pass2_build_devel_system_outside_chroot + diff --git a/run-bootstrap-in-chroot b/run-bootstrap-in-chroot index cdcf0612..f172165e 100755 --- a/run-bootstrap-in-chroot +++ b/run-bootstrap-in-chroot @@ -2,35 +2,103 @@ set -e +unmount_virtual() +{ + umount "$1/proc" || true + umount "$1/sys" || true +} + export LC_ALL=C -dir="squeeze-chroot" -mirror="http://192.168.1.185/debian" +if [ "x$1" = x ] +then + dir="squeeze-chroot" + snapshot=false +else + mkdir -p "$1" + dir="$1/squeeze-chroot" + snapshot=true + snapshotdir="$1" +fi + +if [ ! -x ./do-squeeze-chroot ]; then + cat >"./do-squeeze-chroot" <<EOF +#!/bin/sh +if mount -t proc proc "$dir/proc"; then + if mount -t sysfs sysfs "$dir/sys"; then + chroot "$dir" "\$@" + umount "$dir/sys" + fi + umount "$dir/proc" +fi +EOF + chmod +x "./do-squeeze-chroot" +fi + +if ([ "x$DEBIAN_MIRROR" = x ] && echo DEBIAN_MIRROR is unspecified >&2) || + ([ "x$LFS_MIRROR" = x ] && echo LFS_MIRROR is unspecified >&2) +then + echo It is recommended that mirrors are used + if test -t 0 -o -p /dev/stdin; then #check for interactive stdin + read -p "continue anyway? " || exit 1 + fi +fi +#DEBIAN_MIRROR="http://192.168.1.185/debian" +#LFS_MIRROR=http://192.168.1.185/lfs/ +unmount_virtual "$dir" +rm -rf "$dir" mkdir "$dir" -debootstrap \ ---include=build-essential,\ +if "$snapshot" && [ -e "$snapshotdir/squeeze.tar" ] +then + tar -C "$dir" -xf "$snapshotdir/squeeze.tar" +else + debootstrap \ + --include=build-essential,\ gawk,bison,python,autoconf,autopoint,automake,gettext,libtool,\ -help2man,texinfo,sudo \ -squeeze "$dir" "$mirror" +help2man,texinfo,sudo,qemu-utils,parted,kpartx,mbr,extlinux \ +squeeze "$dir" "$DEBIAN_MIRROR" + + if "$snapshot" + then + tar -caf "$snapshotdir/squeeze.tar" -C "$dir" . + fi +fi hostname > "$dir/etc/hostname" cat <<EOF > "$dir/etc/hosts" 127.0.0.1 localhost -127.0.1.1 $(hostname) +127.0.1.1 `hostname` EOF -cp baserock-bootstrap "$dir/." -sed 's,^.*/,http://192.168.1.185/lfs/,' wget-list > "$dir/wget-list" -mount -t proc proc "$dir/proc" -mount -t sysfs sysfs "$dir/sys" -if chroot "$dir" bash -x baserock-bootstrap yes +if [ "x$LFS_MIRROR" = x ]; then + cp wget-list "$dir/wget-list" +else + perl -M'Env' -lpe 's|^.*/|$LFS_MIRROR|' wget-list >"$dir/wget-list" + #gawk -v m="$LFS_MIRROR" '{gsub(/^.*\//, m)}; 1' wget-list >"$dir/wget-list" + #sed "s,^.*/,$LFS_MIRROR," wget-list > "$dir/wget-list" +fi + +# Unpack existing snapshot, or run pass1 of bootstrap and then make snapshot. +if "$snapshot" && [ -e "$snapshotdir/pass1-snapshot.tar" ] then - exit=0 + tar -C "$dir" -xf "$snapshotdir/pass1-snapshot.tar" + cp baserock-bootstrap "$dir/." #update bootstrap script else - exit=$? + cp baserock-bootstrap "$dir/." + "./do-squeeze-chroot" bash -x baserock-bootstrap true || exit 1 + if "$snapshot" + then + tar -C "$dir" -caf "$snapshotdir/pass1-snapshot.tar" . + fi fi -umount "$dir/sys" -umount "$dir/proc" -exit $exit + +# Update the git repos. +mkdir -p "$dir/tree/baserock" +rm -rf "$dir/tree/baserock/gits" +cp -rl "$HOME/baserock/gits" "$dir/tree/baserock/gits" + +# Run pass2 of bootstrap. This actually runs pass1 too, but quickly, since +# it's already built. +"./do-squeeze-chroot" bash -x baserock-bootstrap false || exit 1 |