# HG changeset patch # User Rob Landley # Date 1286331516 18000 # Node ID df70740df1a579ad20193661effbdf8e1572c0b4 # Parent 82d34e55552f274251ea6683a8fcfa5245eb3ff9 Add generic native-build infastructure. diff -r 82d34e55552f -r df70740df1a5 sources/native-builds/bootstrap-skeleton/build/build-one-package.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/native-builds/bootstrap-skeleton/build/build-one-package.sh Tue Oct 05 21:18:36 2010 -0500 @@ -0,0 +1,48 @@ +#!/bin/sh + +source /mnt/functions.sh || exit 1 + +# build $1 using manifest file $2 + +# Is it already installed? + +if [ ! -z "$2" ] && [ -z "$FORCE" ] && grep -q "$1" "$2" +then + echo "$1 already installed" + exit 0 +fi + +set_titlebar "$1" + +# Snapshot source + +cd /home && +rm -rf "/home/$1" && +cp -sfR "/mnt/packages/$1" "$1" && +cd "$1" || exit 1 + +# Lobotomize config.guess so it won't complain about unknown target types. + +for guess in $(find . -name config.guess) +do + rm "$guess" && + echo -e "#!/bin/sh\ngcc -dumpmachine" > "$guess" || exit 1 +done + +# Call package build script + +time "/mnt/build/${1}-build" || exit 1 + +# Add file to manifest, removing previous version (if any). + +if [ ! -z "$2" ] +then + sed -i -e "/$1/d" "$2" && + echo "$1" >> "$2" || exit 1 +fi + +# Delete copy of source if build succeeded + +cd /home && +rm -rf "$1" && +sync diff -r 82d34e55552f -r df70740df1a5 sources/native-builds/bootstrap-skeleton/build/functions.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/native-builds/bootstrap-skeleton/build/functions.sh Tue Oct 05 21:18:36 2010 -0500 @@ -0,0 +1,40 @@ +#!/bin/echo This file is sourced not run + +upload_result() +{ + ftpput $FTP_SERVER -P $FTP_PORT "$1-$HOST" "$1" +} + +set_titlebar() +{ + echo -en "\033]2;($HOST) $1\007" + echo === "$1" +} + +dotprogress() +{ + while read i; do echo -n .; done; echo +} + +do_in_chroot() +{ + # Copy root filesystem into a new chroot directory and restart in there. + + CHROOT="$1" + shift + + set_titlebar "Setup chroot" + mkdir "$CHROOT" + cp -a /mnt/files/. "$CHROOT" + find / -xdev | cpio -m -v -p "$CHROOT" | dotprogress + for i in mnt proc sys dev; do mount --bind /$i "$CHROOT"/$i; done + + echo Chroot + chroot "$CHROOT" "$@" + RC=$? + + echo Chroot cleanup + for i in mnt proc sys dev; do umount "$CHROOT"/$i; done + + return $RC +} diff -r 82d34e55552f -r df70740df1a5 sources/native-builds/bootstrap-skeleton/build/init --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/native-builds/bootstrap-skeleton/build/init Tue Oct 05 21:18:36 2010 -0500 @@ -0,0 +1,18 @@ +#!/bin/bash + +# Start running here, and hand off to run-build-stages.sh in chroot. + +. /mnt/functions.sh + +# Always chroot, because even if root filesystem is writeable it's hard to +# tell tar to skip /proc and /sys and such without unmounting bits of the +# host environment. + +do_in_chroot /home/chroot /mnt/run-build-stages.sh + +if [ $? -eq 0 ] +then + set_titlebar "upload tarball" + tar czvf gentoo-stage1.tar.gz gentoo-stage1 | dotprogress && + upload_result gentoo-stage1.tar.gz +fi diff -r 82d34e55552f -r df70740df1a5 sources/native-builds/bootstrap-skeleton/build/run-build-stages.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/native-builds/bootstrap-skeleton/build/run-build-stages.sh Tue Oct 05 21:18:36 2010 -0500 @@ -0,0 +1,8 @@ +#!/bin/sh + +# Run each of the individual package build files, in order. + +for i in zlib ncurses python bash rsync patch file portage +do + cd /home && /mnt/${i}-build || exit 1 +done diff -r 82d34e55552f -r df70740df1a5 sources/native-builds/bootstrap-skeleton/control-image-wrapper.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sources/native-builds/bootstrap-skeleton/control-image-wrapper.sh Tue Oct 05 21:18:36 2010 -0500 @@ -0,0 +1,52 @@ +#!/bin/bash + +# Control image generator infrastructure. + +source sources/include.sh || exit 1 + +# Did caller specify the name of a control image to generate? Explicit +# /dev/null means none. + +[ $# -ne 1 ] && echo "usage: $0 FILENAME" >&2 && exit 1 +[ "$1" != "/dev/null" ] && [ -e "$1" ] && echo "$1" exists && exit 0 + +# Find path to our working directory. + +MYDIR="$(dirname "$(readlink -f "$(which "$0")")")" +IMAGENAME="${MYDIR/*\//}" + +# Use our own directories for downloaded source tarballs and patches. +# (We may have the same packages as the aboriginal build, but use different +# versions, and we don't want our cleanup_oldfiles to overlap.) + +PATCHDIR="$MYDIR/patches" +SRCDIR="$SRCDIR/$IMAGENAME" && mkdir -p "$SRCDIR" || dienow + +# Include package cache in the control image, so the target system image can +# build from this source. + +WORK="$WORK/$IMAGENAME" && +blank_tempdir "$WORK" && +SRCTREE="$WORK" && +cp "$MYDIR"/../bootstrap-skeleton/files/* "$WORK" || exit 1 + +echo "=== $IMAGENAME: Download/extract source code" + +EXTRACT_ALL=1 + +"$MYDIR"/download.sh || exit 1 + +cleanup_oldfiles + +if [ -e "$MYDIR/mnt" ] +then + cp -a "$MYDIR/mnt/." "$WORK" || exit 1 +fi + +# Create sqaushfs image + +if [ "$1" != "/dev/null" ] +then + cd "$TOP" && + mksquashfs "$WORK" "$1" -noappend -all-root || dienow +fi