diff options
author | Zach van Rijn <me@zv.io> | 2021-10-09 21:04:03 -0500 |
---|---|---|
committer | Zach van Rijn <me@zv.io> | 2024-08-10 06:09:07 +0000 |
commit | 6a3ea466b7af7d2e9896f5a70182c7771182540b (patch) | |
tree | 64f847389f7d5e8d8e3c04427003b0e06e532e79 /scripts/bootstrap.sh | |
parent | 6f94d419b70e2881ce6d9c37233b5a13dca61d08 (diff) | |
download | packages-6a3ea466b7af7d2e9896f5a70182c7771182540b.tar.gz packages-6a3ea466b7af7d2e9896f5a70182c7771182540b.tar.bz2 packages-6a3ea466b7af7d2e9896f5a70182c7771182540b.tar.xz packages-6a3ea466b7af7d2e9896f5a70182c7771182540b.zip |
Initial draft of new bootstrap tooling.
Diffstat (limited to 'scripts/bootstrap.sh')
-rwxr-xr-x | scripts/bootstrap.sh | 82 |
1 files changed, 71 insertions, 11 deletions
diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index 87d7b1d48..78f8ac7ff 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -1,14 +1,56 @@ -#!/bin/sh +#!/bin/sh -e -set -e +set -x +HERE="$(dirname $(readlink -f ${0}))"; + +## +# mcmtools provides almost everything needed to build 'abuild', +# and it is a hard dependency for our bootstrap process now. +# +# https://git.zv.io/toolchains/bootstrap +# +# It is possible to bootstrap from a non- Alpine/Adélie system. +# We will build 'abuild' and other utilities momentarily. +# +MCMTOOLS=${MCMTOOLS:-"$HOME/mcmtools"} +test ! -d "${MCMTOOLS}/sys/bin" && printf "Environment 'MCMTOOLS=%s' is not valid.\n" "${MCMTOOLS}" && exit 1; + + +## +# TARGET_ARCH (argv[1]) is used during cross-compilation. +# TARGET_ARCH="$1" +test ! -n "${TARGET_ARCH}" && printf "Invoking '%s TARGET_ARCH' where 'TARGET_ARCH=%s' is not valid.\n" "${0}" "${TARGET_ARCH}" && exit 1; + + +## +# Build 'abuild', its dependencies, and other utilities. +# Once finished, add them to PATH. +# +"${HERE}/setup-abuild" ${TARGET_ARCH}; +export PATH="${MCMTOOLS}/abuild/bin:${PATH}"; +#bash; +#exit; + +## +# Additional configuration. +# +export PACKAGER="Zach van Rijn <me@zv.io>"; +export CBUILD=${TARGET_ARCH}; +export CBUILDROOT="${MCMTOOLS}/abuild/${TARGET_ARCH}"; +export ABUILD_USERDIR="${CBUILDROOT}.conf"; +export SRCDEST="${MCMTOOLS}/abuild/src"; +export REPODEST="${MCMTOOLS}/abuild/apk"; +export ABUILD_APK_INDEX_OPTS="--allow-untrusted"; # FIXME +#export BUILD_ROOT="${CBUILDROOT}"; + SUDO_APK=abuild-apk # 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 +[ -e "${MCMTOOLS}/abuild/share/abuild/functions.sh" ] || (echo "abuild not found" ; exit 1) +CBUILDROOT="$(CTARGET=$TARGET_ARCH . ${MCMTOOLS}/abuild/share/abuild/functions.sh ; echo $CBUILDROOT)" +. "${MCMTOOLS}/abuild/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" @@ -53,19 +95,37 @@ EOF return 1 fi -if [ ! -d "$CBUILDROOT" ]; then + +## +# Package signing keys. Public and Private keys are stored in a +# different location; variables for which are installed to arch- +# specific 'abuild.conf' file. +# +if [ ! -d "$CBUILDROOT/etc/apk/keys" ] || [ -n "$(find $CBUILDROOT -type f -name '*.rsa')" ]; then msg "Creating sysroot in $CBUILDROOT" mkdir -p "$CBUILDROOT/etc/apk/keys" - cp -a /etc/apk/keys/* "$CBUILDROOT/etc/apk/keys" - ${SUDO_APK} add --quiet --initdb --arch $TARGET_ARCH --root $CBUILDROOT + abuild-keygen -an; + p=$(find "${ABUILD_USERDIR}" -type f -name "*.rsa.pub"); + mv "${p}" "$CBUILDROOT/etc/apk/keys"; + grep 1>/dev/null PACKAGER_PUBKEY= "${ABUILD_USERDIR}/abuild.conf" || printf >> "${ABUILD_USERDIR}/abuild.conf" "PACKAGER_PUBKEY=\"%s\"\n" "$CBUILDROOT/etc/apk/keys/${p##*/}"; +fi + + +## +# APK database. +# +if [ ! -f "${CBUILDROOT}/._database-${TARGET_ARCH}" ]; then + mkdir -p "${CBUILDROOT}/var/log"; # why not created by default? + ${SUDO_APK} add --quiet --initdb --arch $TARGET_ARCH --root $CBUILDROOT + touch "${CBUILDROOT}/._database-${TARGET_ARCH}"; fi msg "Building cross-compiler" # Build and install cross binutils (--with-sysroot) CTARGET=$TARGET_ARCH BOOTSTRAP=nobase APKBUILD=$(apkbuildname binutils) abuild -r - -#if ! CHOST=$TARGET_ARCH BOOTSTRAP=nolibc APKBUILD=$(apkbuildname musl) abuild up2date 2>/dev/null; then +exit +if ! CHOST=$TARGET_ARCH BOOTSTRAP=nolibc APKBUILD=$(apkbuildname musl) abuild up2date 2>/dev/null; then # C-library headers for target CHOST=$TARGET_ARCH BOOTSTRAP=nocc APKBUILD=$(apkbuildname musl) abuild -r @@ -76,7 +136,7 @@ CTARGET=$TARGET_ARCH BOOTSTRAP=nobase APKBUILD=$(apkbuildname binutils) abuild - # 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 +fi # Full cross GCC EXTRADEPENDS_TARGET="musl musl-dev" \ |