From 55f352d5d5f1e5d291eabc038fcbf41af4985fc6 Mon Sep 17 00:00:00 2001 From: Ella Stanforth Date: Tue, 19 Apr 2022 09:32:14 +0000 Subject: [PATCH] begin switching to iglunix-bootstrap --- autobuild.sh | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++ chroot.sh | 19 +++++++++ 2 files changed, 130 insertions(+) create mode 100755 autobuild.sh create mode 100755 chroot.sh diff --git a/autobuild.sh b/autobuild.sh new file mode 100755 index 0000000..ab778be --- /dev/null +++ b/autobuild.sh @@ -0,0 +1,111 @@ +#!/bin/sh -e + +mkdir -p build + +cd build +# TODO: add option for using native toolchain for stage 0 +[ -d 'iglunix-bootstrap' ] || git clone --depth=1 https://github.com/iglunix/iglunix-bootstrap +[ -d 'iglunix' ] || git clone --depth=1 https://github.com/iglunix/iglunix +[ -d 'iglupkg' ] || git clone --depth=1 https://github.com/iglunix/iglupkg + +SYSROOT_S2=$(pwd)/sysroot +IP=$(pwd)/iglupkg/ + +LOGS=$(pwd)/logs + +mkdir -p $LOGS + +echo === STAGE 1 === Build cross toolchain + +cd iglunix-bootstrap +MAKE=gmake bad --gmake ./boot.sh +SYSROOT_S1=$(pwd)/sysroot + +cd .. + +echo === STAGE 1 === Done + +s2_build() { + PKGDIR=$1 + PKGNAME=$2 + cd $1/$2 + [ -f .s2 ] || ${IP}iglupkg.sh --with-cross=x86_64 --with-cross-dir=$SYSROOT_S1 --for-cross --for-cross-dir=/ fbp + touch .s2 + # 2>$LOGS/$2.1.err > $LOGS/$2.1.out + cd ../../ +} + +s2_extract() { + PKGDIR=$1 + PKGNAME=$2 + cd $1/$2/out + tar -xf $2-*.tar.zst -C $SYSROOT_S2 -I zstd + cd ../../../ +} + + +cd iglunix + +echo === STAGE 2 === Build cross libs + +s2_build linux musl +s2_build linux linux +s2_build base libunwind +s2_build base libcxx + +echo === STAGE 2 === Assemble sysroot + +[ -d "$SYSROOT_S2" ] || { + mkdir -p $SYSROOT_S2 + + s2_extract linux musl + s2_extract linux linux + s2_extract base libunwind + s2_extract base libcxx +} + +echo === STAGE 3 === Build target packages + +s3_build() { + PKGDIR=$1 + PKGNAME=$2 + cd $1/$2 + [ -f .s3 ] || ${IP}iglupkg.sh --with-cross=x86_64 --with-cross-dir=$SYSROOT_S2 fbp + touch .s3 + # 2>$LOGS/$2.2.err > $LOGS/$2.2.out + cd ../../ +} + +s3_build linux linux +s3_build linux musl +s3_build linux busybox +s3_build base mksh +s3_build base toybox +s3_build base libunwind +s3_build base libcxx +s3_build base llvm + +touch .autobuilt + +# order to build packages +# +# build stage 1 cross toolchain with stage 0: +# +# linux +# musl +# libunwind +# libcxx +# ... +# +# build stage 2 final packages +# +# linux +# musl +# libunwind +# libcxx +# llvm +# +# mksh +# toybox +# busybox +# clang diff --git a/chroot.sh b/chroot.sh new file mode 100755 index 0000000..51908d8 --- /dev/null +++ b/chroot.sh @@ -0,0 +1,19 @@ +#!/bin/sh -e +cd build +[ -f iglunix/.autobuilt ] || echo "ERROR: you need to run autobuild.sh first" +CHROOT=$(pwd)/chroot +mkdir -p $CHROOT + +cex() { + PKGDIR=$1 + PKGNAME=$2 + tar -xf iglunix/$PKGDIR/$PKGNAME/out/$PKGNAME.*.tar.zst -I zstd -C $CHROOT +} + +cex linux musl +cex linux busybox +cex base mksh +cex base toybox +cex base libunwind +cex base libcxx +cex base llvm