summaryrefslogtreecommitdiffstats
path: root/stage2.sh
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2013-03-22 16:47:17 -0700
committer Eric Hameleers <alien@slackware.com>2013-03-22 16:47:17 -0700
commit69dd99f961988fa15da8d7f0d63b62f3385419c3 (patch)
treed57eb3e85e1d08e7815787de26946ee42c398b66 /stage2.sh
downloadalienarm-69dd99f961988fa15da8d7f0d63b62f3385419c3.tar.gz
alienarm-69dd99f961988fa15da8d7f0d63b62f3385419c3.tar.xz
Initial commit of a Slackware cross-arch bootstrap framework.
Diffstat (limited to 'stage2.sh')
-rwxr-xr-xstage2.sh210
1 files changed, 210 insertions, 0 deletions
diff --git a/stage2.sh b/stage2.sh
new file mode 100755
index 0000000..57d47e6
--- /dev/null
+++ b/stage2.sh
@@ -0,0 +1,210 @@
+#!/bin/bash
+#
+# This script is the second stage in bootstrapping a Slackware build
+# to a new platform or architecture. Running stage1.sh with no arguments
+# builds a cross-development environment, then cross-builds a minimal
+# rootfs. Once you have this minimal rootfs booted (or chroot'd), run
+# stage2.sh (this script) in that rootfs to build the rest of the
+# bootstrap packages.
+#
+# This script assumes that all the needed sources are installed in
+# $SLACKSOURCE (below) by stage1.sh. Each build installs into /usr.
+#
+# You may pass a single package name on the command line to rebuild
+# just that one package.
+#
+# The master upstream for this script is:
+# git://fedorapeople.org/~djdelorie/bootstrap.git
+#
+# ------------------------------------------------------------
+#
+# --- NOTES FOR PACKAGE PORTING ---
+#
+# This script is stage TWO of a bootstrap process. EVERYTHING that
+# this script uses MUST be provided by the stage ONE script -
+# filesystem, utilities, sources, etc. Please keep this in mind when
+# editing this script - anything you do manually to "prepare" for your
+# build, will NOT be reproducible.
+#
+# Please make sure your package is not in either stage1 or stage2, and
+# that nobody else is already working on your package, before
+# starting. Grep is your friend. See the wiki page for details.
+#
+# There are FOUR places you must edit when adding packages to the
+# bootstrap build:
+#
+# 1. Add a clause at the end of this script to actually build your
+# package.
+#
+# 2. Add your package to the "" case at the beginning of the package
+# list, about a page down from these comments. Put in the order in
+# which it needs to build based on its dependencies.
+#
+# 3. Add your package source to the list at the end of the stage1 script
+# so that your sources are available in the bootstrap rootfs.
+#
+# 4. Update the Fedora/ARM bootstrap wiki page.
+#
+# If you attempt to add a package and discover some unsatisfied build
+# dependency, add a clause for it here that documents the dependency
+# and exits with a non-zero code. In that case, do not add your
+# package to the "" case.
+#
+# ------------------------------------------------------------
+
+#set -vx
+
+# What are we cross-compiling for?
+DISTRO=slackware
+ARCH=armv7hl
+HWSPEC=tegra
+KVER=3.1.6
+KARCH=arm
+CHOST="$ARCH-$DISTRO-linux-gnueabi"
+SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16"
+SLKLDFLAGS=""
+LIBDIRSUFFIX=""
+
+# Everything required for building stage2 is found here:
+TOP=/stage2
+
+# Where do we look for the scripts?
+SRCDIR=$(cd $(dirname $0); pwd)
+
+# Script to run in the rootfs, on the target:
+STAGE2=$SRCDIR/stage2.sh
+
+# Where we extracted our original Slackware sources:
+SLACKSOURCE=$TOP/sources
+
+# Each build installs into /usr.
+PREFIX=/usr
+
+NUMJOBS=${NUMJOBS:--j7}
+
+BUILDDIR=$TOP/builds
+
+# The cross-compiler target
+export TARGET=$CHOST
+
+# Needed during build:
+export CFLAGS="$SLKCFLAGS"
+export LDFLAGS="$SLKLDFLAGS"
+
+if [ -f $SRCDIR/local.conf ]
+then
+ . $SRCDIR/local.conf
+fi
+
+if [ ! -c /dev/null -a -w / ]
+then
+ echo Creating /dev devices...
+ mkdir /dev
+ mknod /dev/null c 1 3
+ mknod /dev/zero c 1 5
+ mknod /dev/tty c 5 0
+ mknod /dev/console c 5 1
+ mknod /dev/sda b 8 0
+ mknod /dev/sda1 b 8 1
+ mknod /dev/sda2 b 8 2
+ mknod /dev/sda3 b 8 3
+ mknod /dev/sda4 b 8 4
+ mknod /dev/mmcblk0 b 179 0
+ mknod /dev/mmcblk0p1 b 179 1
+ mknod /dev/mmcblk0p2 b 179 2
+ mknod /dev/mmcblk0p3 b 179 3
+ mknod /dev/mmcblk0p4 b 179 4
+ mknod /dev/ttyO0 c 253 0
+ mknod /dev/ttyO1 c 253 1
+ mknod /dev/ttyO2 c 253 2
+ mknod /dev/ttyO3 c 253 3
+ chmod a+rw /dev/null /dev/zero
+fi
+
+if [ ! -d /tmp ]
+then
+ echo Creating /tmp...
+ mkdir /tmp
+ chmod 1777 /tmp
+fi
+
+# ------------------------------------------------------------
+
+mkdirp()
+{
+ test -d $1 || mkdir -p $1
+}
+
+mkdirp $PREFIX
+mkdirp $BUILDDIR
+
+export PATH=$PREFIX/bin:$PATH
+
+go()
+{
+ "$0" "$@"
+}
+
+mcd()
+{
+ test -d $1 || mkdir -p $1
+ cd $1
+}
+
+notparallel()
+{
+ echo .NOTPARALLEL: >> Makefile
+}
+
+fix_la()
+{
+ for la in /usr/lib/*$1*.la
+ do
+ rm $la
+ done
+}
+
+case "$1" in
+ "" )
+ go clean
+
+ # build recipes are now in /stage2/recipe.d/
+ # enabled recipes start with [0-9]{4}-
+ # disabled recipes start with XXXX-
+
+ for PKG in /stage2/recipe.d/[0-9][0-9][0-9][0-9]-*
+ do
+ PKG="$(basename $PKG|sed -r 's/^[0-9]{4}-//')"
+ go "$PKG"
+ done
+ ;;
+
+ "clean" )
+ ;;
+
+ # Packages built by stage1
+
+ binutils | gcc | glibc | kernel | x-loader | u-boot \
+ | gmp | mpfr | libmpc | zlib \
+ | bash | make | sed | coreutils | util-linux | tar | gzip \
+ | bzip2 | diffutils | findutils | gawk | patch | unzip | which | gz | grep )
+
+ echo "$1 is built in stage1" >&2
+ exit 1
+ ;;
+
+#--------------------------------------------------
+
+ * )
+ if [ -f "/stage2/recipe.d/"[0-9][0-9][0-9][0-9]"-$1" ]
+ then
+ . /stage2/recipe.d/[0-9][0-9][0-9][0-9]-$1
+ else
+ echo "No build recipe found for $1" >&2
+ exit 2
+ fi
+
+esac
+
+exit 0
+