|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Use qemu if necessary
|
|
|
|
#qemu=qemu-i386
|
|
|
|
qemu=
|
|
|
|
|
|
|
|
NPROC="${NPROC:-$(nproc)}"
|
|
|
|
|
|
|
|
rm -rf system
|
|
|
|
mkdir -p builds
|
|
|
|
|
|
|
|
# Stage 1: Build matching mes and busybox binaries
|
|
|
|
NPROC="$NPROC" ./build_binaries.sh
|
|
|
|
mv system/binaries.tar.gz builds/
|
|
|
|
|
|
|
|
# Stage 2: Bootstrap system from these
|
|
|
|
mkdir -p system/sources/
|
|
|
|
cp -av sources/* system/sources/
|
|
|
|
cp build_bootstrap.sh system/sources/
|
|
|
|
mkdir system/dev system/tmp
|
|
|
|
mknod system/dev/null c 1 3
|
|
|
|
mknod system/dev/tty c 5 0
|
|
|
|
$qemu system/bin/busybox chroot system /bin/busybox env -i NPROC="$NPROC" /bin/busybox sh /sources/build_bootstrap.sh
|
|
|
|
mv system/bootstrap.tar.gz builds/
|
|
|
|
|
|
|
|
# Stage 2.5 (optional): Rebuild bootstrap binaries to have a "clean" archive
|
|
|
|
if [ "$1" = double_bootstrap ]; then
|
|
|
|
cp build_binaries.sh binaries.sha1 busybox-config system/
|
|
|
|
$qemu system/bootstrap/bin/chroot system /bootstrap/bin/env -i NPROC="$NPROC" PATH=/bootstrap/bin /bootstrap/bin/sh /build_binaries.sh
|
|
|
|
mv system/system/binaries.tar.gz builds/
|
|
|
|
rm system/build_binaries.sh system/binaries.sha1 system/busybox-config
|
|
|
|
rm -rf system/system/
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Stage 3: Cross-compile system for x86_64
|
|
|
|
cp build_cross.sh system/sources
|
|
|
|
$qemu system/bootstrap/bin/chroot system /bootstrap/bin/env -i NPROC="$NPROC" /bootstrap/bin/sh /sources/build_cross.sh
|
|
|
|
mv system/system/cross.tar.gz builds/
|