From d50a0801c17e698a005df65a5db44665698a8948 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Fri, 20 Jul 2018 02:28:18 -0500 Subject: scripts: add our modified bootstrap.sh to Git Told you it'd happen some day. --- scripts/bootstrap.sh | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 scripts/bootstrap.sh (limited to 'scripts/bootstrap.sh') diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh new file mode 100755 index 000000000..5d870f436 --- /dev/null +++ b/scripts/bootstrap.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +set -e + +TARGET_ARCH="$1" +SUDO_APK=abuild-apk + +# optional cross build packages +KERNEL_PKG="linux-firmware linux-vanilla" + +# get abuild configurables +[ -e /usr/share/abuild/functions.sh ] || (echo "abuild not found" ; exit 1) +CBUILDROOT="$(CTARGET=$TARGET_ARCH . /usr/share/abuild/functions.sh ; echo $CBUILDROOT)" +. /usr/share/abuild/functions.sh +[ -z "$CBUILD_ARCH" ] && die "abuild is too old (use 2.29.0 or later)" +[ -z "$CBUILDROOT" ] && die "CBUILDROOT not set for $TARGET_ARCH" + +# deduce aports directory +[ -z "$APORTS" ] && APORTS=$(realpath $(dirname $0)/../) +[ -e "$APORTS/system/build-tools" ] || die "Unable to deduce aports base checkout" + +apkbuildname() { + local repo="${1%%/*}" + local pkg="${1##*/}" + [ "$repo" = "$1" ] && repo="system" + echo $APORTS/$repo/$pkg/APKBUILD +} + +msg() { + [ -n "$quiet" ] && return 0 + local prompt="$GREEN>>>${NORMAL}" + local name="${BLUE}bootstrap-${TARGET_ARCH}${NORMAL}" + printf "${prompt} ${name}: %s\n" "$1" >&2 +} + +if [ -z "$TARGET_ARCH" ]; then + program=$(basename $0) + cat </dev/null; then + # C-library headers for target + CHOST=$TARGET_ARCH BOOTSTRAP=nocc APKBUILD=$(apkbuildname musl) abuild -r + + # Minimal cross GCC + EXTRADEPENDS_HOST="musl-dev" \ + CTARGET=$TARGET_ARCH BOOTSTRAP=nolibc APKBUILD=$(apkbuildname gcc) abuild -r + + # Cross build bootstrap C-library for the target + EXTRADEPENDS_BUILD="gcc-pass2-$TARGET_ARCH" \ + CHOST=$TARGET_ARCH BOOTSTRAP=nolibc APKBUILD=$(apkbuildname musl) abuild -r +fi + +# Full cross GCC +EXTRADEPENDS_TARGET="musl musl-dev" \ +CTARGET=$TARGET_ARCH BOOTSTRAP=nobase APKBUILD=$(apkbuildname gcc) abuild -r + +# Cross build-base +CTARGET=$TARGET_ARCH BOOTSTRAP=nobase APKBUILD=$(apkbuildname build-base) abuild -r + +msg "Cross building base system" +msg "Change your abuild.conf NOW to avoid build errors!!" +read + +# add implicit target prerequisite packages +apk info --quiet --installed --root "$CBUILDROOT" libgcc libstdc++ musl-dev || \ + ${SUDO_APK} --root "$CBUILDROOT" add --repository "$REPODEST/system" libgcc libstdc++ musl-dev + +# ordered cross-build +for PKG in fortify-headers linux-headers musl libc-dev pkgconf zlib \ + gettext-tiny ncurses readline bash binutils make bison flex m4 \ + openssl libfetch apk-tools linux-pam shadow \ + gmp mpfr3 mpc1 isl cloog gcc ca-certificates \ + openrc libcap-ng coreutils sed gzip bzip2 diffutils \ + attr libcap patch sudo acl fakeroot libarchive mawk \ + pax-utils abuild grep findutils patch lzip unzip autoconf automake libtool \ + ncurses util-linux lvm2 popt xz lddtree libssh2 curl build-tools pcre \ + debianutils file shimmy procps zsh sharutils net-tools check kbd sysklogd vim db groff libpipeline man-db psmisc less \ + adelie-base \ + ; do + + CHOST=$TARGET_ARCH BOOTSTRAP=bootimage APKBUILD=$(apkbuildname $PKG) abuild -r + + case "$PKG" in + fortify-headers | libc-dev | build-base) + # headers packages which are implicit but mandatory dependency + apk info --quiet --installed --root "$CBUILDROOT" $PKG || \ + ${SUDO_APK} --update --root "$CBUILDROOT" --repository "$REPODEST/main" add $PKG + ;; + musl | gcc) + # target libraries rebuilt, force upgrade + [ "$(apk upgrade --root "$CBUILDROOT" --repository "$REPODEST/main" --available --simulate | wc -l)" -gt 1 ] && + ${SUDO_APK} upgrade --root "$CBUILDROOT" --repository "$REPODEST/main" --available + ;; + esac +done -- cgit v1.2.3-70-g09d2