changeset 1252:ba951c11fb48

Refactor the gentoo bootstrap build some more. Add "build" and "files" subdirectories, split each package build into a separate file, break out reusable shell functions into functions.sh. Flow control now init chrooting into run-build-stages.sh calling the individual package scripts.
author Rob Landley <rob@landley.net>
date Sat, 25 Sep 2010 13:40:04 -0500
parents 204238871b7c
children d4b251e78fc0
files sources/native-builds/gentoo-bootstrap/build/bash-build sources/native-builds/gentoo-bootstrap/build/file-build sources/native-builds/gentoo-bootstrap/build/functions.sh sources/native-builds/gentoo-bootstrap/build/init sources/native-builds/gentoo-bootstrap/build/ncurses-build sources/native-builds/gentoo-bootstrap/build/patch-build sources/native-builds/gentoo-bootstrap/build/portage-build sources/native-builds/gentoo-bootstrap/build/python-build sources/native-builds/gentoo-bootstrap/build/rsync-build sources/native-builds/gentoo-bootstrap/build/run-build-stages.sh sources/native-builds/gentoo-bootstrap/build/zlib-build sources/native-builds/gentoo-bootstrap/files/init sources/native-builds/gentoo-bootstrap/make-control-image.sh
diffstat 13 files changed, 203 insertions(+), 152 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/bash-build	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. /mnt/functions.sh
+
+# Portage uses bash ~= regex matches, which were introduced in bash 3.
+
+set_titlebar "Bash3" && cp -sfR /mnt/bash bash && cd bash &&
+
+./configure --enable-cond-regexp --disable-nls --prefix=/usr &&
+make -j $CPUS &&
+make install &&
+
+cd .. && rm -rf bash || exit 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/file-build	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. /mnt/functions.sh
+
+set_titlebar "file" && cp -sfR /mnt/file file && cd file &&
+
+./configure --prefix=/usr &&
+make -j $CPUS &&
+make install &&
+
+cd .. && rm -rf file || exit 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/functions.sh	Sat Sep 25 13:40:04 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
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/init	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# Start running, 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 [ $RC -eq 0 ]
+then
+  set_titlebar "upload tarball"
+  tar czvf gentoo-stage1.tar.gz gentoo-stage1 | dotprogress &&
+  upload_result gentoo-stage1.tar.gz
+fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/ncurses-build	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. /mnt/functions.sh
+
+set_titlebar "ncurses" && cp -sfR /mnt/ncurses ncurses && cd ncurses &&
+
+./configure --without-cxx-binding --with-shared &&
+make -j $CPUS &&
+make install &&
+
+cd .. && rm -rf ncurses || exit 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/patch-build	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+. /mnt/functions.sh
+
+# Need a patch with --dry-run to make portage happy
+
+set_titlebar "patch" && cp -sfR /mnt/patch patch && cd patch &&
+
+./configure --prefix=/usr &&
+make -j $CPUS &&
+make install &&
+
+cd .. && rm -rf patch || exit 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/portage-build	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+. /mnt/functions.sh
+
+# Portage isn't really designed to be portable, so this script contains
+# the "make install" stage that portage really should have within itself.
+
+set_titlebar "portage" && cd /mnt/portage &&
+
+# Install portage user/group, and libraries.
+
+echo portage:x:250:250:portage:/var/tmp/portage:/bin/false >> /etc/passwd &&
+echo portage::250:portage >> /etc/group &&
+mkdir -p /usr/lib/portage &&
+cp -a bin pym /usr/lib/portage/ &&
+
+# Add portage python modules to the python search path.
+
+echo /usr/lib/portage/pym > /usr/lib/python2.6/site-packages/gentoo.pth ||
+  exit 1
+
+# Install portage binaries into bin and sbin
+
+for i in archive-conf dispatch-conf emaint emerge-webrsync env-update \
+         etc-update fixpackages quickpkg regenworld
+do
+  ln /usr/lib/portage/bin/$i /usr/sbin/$i || exit 1
+done
+
+for i in  ebuild egencache emerge portageq repoman
+do
+  ln /usr/lib/portage/bin/$i /usr/bin/$i || exit 1
+done
+
+# Install portage man pages
+
+cp cnf/make.globals /etc/ &&
+cp man/*.1 /usr/man/man1 &&
+cp man/*.5 /usr/man/man5 &&
+
+mkdir -p /var/log /etc/portage/profile || exit 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/python-build	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+. /mnt/functions.sh
+
+set_titlebar "Python" && cp -sfR /mnt/Python python && cd python &&
+
+./configure --prefix=/usr &&
+make -j $CPUS &&
+make install &&
+
+cd .. && rm -rf python || exit 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/rsync-build	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+. /mnt/functions.sh
+
+set_titlebar "rsync" && cp -sfR /mnt/rsync rsync && cd rsync &&
+
+./configure --prefix=/usr &&
+# Break link and touch file, otherwise ./configure tries to recreate it
+# which requires perl.
+cat proto.h-tstamp > proto.h.new &&
+mv -f proto.h.new proto.h-tstamp &&
+make -j $CPUS &&
+make install &&
+
+cd .. && rm -rf rsync || exit 1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/run-build-stages.sh	Sat Sep 25 13:40:04 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sources/native-builds/gentoo-bootstrap/build/zlib-build	Sat Sep 25 13:40:04 2010 -0500
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+. /mnt/functions.sh
+
+set_titlebar "zlib" && cp -sfR /mnt/zlib zlib && cd zlib &&
+
+# 1.2.5 accidentally shipped the Makefile, then configure tries to
+# modify it in place.
+rm Makefile && 
+./configure --prefix=/usr &&
+make -j $CPUS &&
+make install &&
+
+cd .. && rm -rf zlib || exit 1
--- a/sources/native-builds/gentoo-bootstrap/files/init	Fri Sep 24 08:36:21 2010 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,147 +0,0 @@
-#!/bin/bash
-
-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
-}
-
-echo Started second stage init
-
-# If the root filesystem is read only (squashfs), copy it into a new chroot
-# directory under /home and restart in there.
-
-touch /.iswriteable 2>/dev/null
-rm /.iswriteable 2>/dev/null
-if [ $? -ne 0 ]
-then
-  set_titlebar "writeable chroot"
-  mkdir gentoo-stage1
-  find / -xdev | cpio -m -v -p /home/gentoo-stage1 | dotprogress
-
-  echo Restarting init script in chroot
-  for i in mnt proc sys dev; do mount --bind /$i gentoo-stage1/$i; done
-  chroot gentoo-stage1 /mnt/init
-  RC=$?
-  for i in mnt proc sys dev; do umount gentoo-stage1/$i; done
-
-
-  if [ $RC -eq 0 ]
-  then
-    set_titlebar "upload tarball"
-    tar czvf gentoo-stage1.tar.gz gentoo-stage1 | dotprogress &&
-    upload_result gentoo-stage1.tar.gz
-  fi
-
-  sync
-  exit
-fi
-
-set_titlebar "zlib" && cp -sfR /mnt/zlib zlib && cd zlib &&
-
-# 1.2.5 accidentally shipped the Makefile, then configure tries to
-# modify it in place.
-rm Makefile && 
-./configure --prefix=/usr &&
-make -j $CPUS &&
-make install &&
-
-cd .. && rm -rf zlib || exit 1
-
-set_titlebar "ncurses" && cp -sfR /mnt/ncurses ncurses && cd ncurses &&
-
-./configure --without-cxx-binding --with-shared &&
-make -j $CPUS &&
-make install &&
-
-cd .. && rm -rf ncurses || exit 1
-
-set_titlebar "Python" && cp -sfR /mnt/Python python && cd python &&
-
-./configure --prefix=/usr &&
-make -j $CPUS &&
-make install &&
-
-cd .. && rm -rf python || exit 1
-
-# Portage uses bash ~= regex matches, which were introduced in bash 3.
-
-set_titlebar "Bash3" && cp -sfR /mnt/bash bash && cd bash &&
-
-./configure --enable-cond-regexp --disable-nls --prefix=/usr &&
-make -j $CPUS &&
-make install &&
-
-cd .. && rm -rf bash || exit 1
-
-set_titlebar "rsync" && cp -sfR /mnt/rsync rsync && cd rsync &&
-
-./configure --prefix=/usr &&
-# Break link and touch file, otherwise ./configure tries to recreate it
-# which requires perl.
-cat proto.h-tstamp > proto.h.new &&
-mv -f proto.h.new proto.h-tstamp &&
-make -j $CPUS &&
-make install &&
-
-cd .. && rm -rf rsync || exit 1
-
-# Need a patch with --dry-run to make portage happy
-
-set_titlebar "patch" && cp -sfR /mnt/patch patch && cd patch &&
-
-./configure --prefix=/usr &&
-make -j $CPUS &&
-make install &&
-
-cd .. && rm -rf patch || exit 1
-
-set_titlebar "file" && cp -sfR /mnt/file file && cd file &&
-
-./configure --prefix=/usr &&
-make -j $CPUS &&
-make install &&
-
-cd .. && rm -rf file || exit 1
-
-set_titlebar "portage" && cd /mnt/portage &&
-
-echo portage:x:250:250:portage:/var/tmp/portage:/bin/false >> /etc/passwd &&
-echo portage::250:portage >> /etc/group &&
-mkdir -p /usr/lib/portage &&
-cp -a bin pym /usr/lib/portage/ &&
-echo /usr/lib/portage/pym > /usr/lib/python2.6/site-packages/gentoo.pth ||
-  exit 1
-
-for i in archive-conf dispatch-conf emaint emerge-webrsync env-update \
-         etc-update fixpackages quickpkg regenworld
-do
-  ln /usr/lib/portage/bin/$i /usr/sbin/$i || exit 1
-done
-
-for i in  ebuild egencache emerge portageq repoman
-do
-  ln /usr/lib/portage/bin/$i /usr/bin/$i || exit 1
-done
-
-cp cnf/make.globals /etc/ &&
-cp man/*.1 /usr/man/man1 &&
-cp man/*.5 /usr/man/man5 &&
-mv /usr/bin/emerge /usr/bin/emerge.real &&
-cp /mnt/emerge_wrapper.sh /usr/bin/emerge &&
-
-mkdir -p /var/log &&
-mkdir -p /etc/portage/profile &&
-cp /mnt/package.provided /etc/portage/profile &&
-
-cd /home || exit 1
--- a/sources/native-builds/gentoo-bootstrap/make-control-image.sh	Fri Sep 24 08:36:21 2010 -0500
+++ b/sources/native-builds/gentoo-bootstrap/make-control-image.sh	Sat Sep 25 13:40:04 2010 -0500
@@ -1,10 +1,12 @@
 #!/bin/bash
 
-# Script to extend minimal native build environment into a Gentoo stage 1.
+# Extend minimal native build environment into a seed for Gentoo Catalyst.
 
-# We take some liberties with this stage 1: use busybox instead of gnu tools,
-# uClibc-based instead of glibc-based, and using our existing toolchain
-# (with distcc acceleration).
+# This doesn't quite create an official Gentoo Stage 1.  We use busybox instead
+# of gnu tools, we're uClibc-based instead of glibc-based, and we use our
+# existing toolchain (with distcc acceleration) instead of asking portage
+# to build one.  That said, this should be enough to run Catalyst and produce
+# official Stage 1, Stage 2, and Stage 3 images.
 
 # GFS used:
 # setup-base-packages.sh
@@ -77,7 +79,8 @@
 
 cleanup_oldfiles
 
-cp -a "$MYDIR/files/." "$WORK" || exit 1
+cp -a "$MYDIR/build/." "$WORK" &&
+cp -a "$MYDIR/files" "$WORK" || exit 1
 
 if [ "$1" != "/dev/null" ]
 then