From 86330dc292cbb5642cbc5b6ba645d67946ad3a68 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Mon, 2 Dec 2024 18:51:13 -0600 Subject: [PATCH] Initial commit --- .editorconfig | 7 ++++++ .gitignore | 2 ++ README.md | 38 ++++++++++++++++++++++++++++ build-image.sh | 63 +++++++++++++++++++++++++++++++++++++++++++++++ common.sh | 15 +++++++++++ crossdev-image.sh | 36 +++++++++++++++++++++++++++ crossdev.sh | 20 +++++++++++++++ stage3-image.sh | 37 ++++++++++++++++++++++++++++ sync.sh | 10 ++++++++ update.sh | 5 ++++ 10 files changed, 233 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 README.md create mode 100644 build-image.sh create mode 100644 common.sh create mode 100644 crossdev-image.sh create mode 100644 crossdev.sh create mode 100644 stage3-image.sh create mode 100644 sync.sh create mode 100644 update.sh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..f6b035f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,7 @@ +root = true + +[*.sh] +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7ed0647 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +stage3-*.tar.* +latest-*.txt diff --git a/README.md b/README.md new file mode 100644 index 0000000..4df386c --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# Aimee OS Build Container Images + +Prerequisites: + +* `buildah` + + +## Gentoo Stage 3 Image + +This image forms the base layer for Aimee OS build images. + +Use the default stage3 tarball (`stage3-amd64-nomultilib-openrc`): + +```sh +sh stage3-image.sh +``` + +Use a specific stage3 tarball: + +```sh +sh stage3-image.sh amd64-systemd +``` + + +## Crossdev Image + +This image includes a cross-compilation toolchain, generated by _crossdev_. + +```sh +sh crossdev-image.sh +``` + +Use the `--base` and `--target` command-line arguments to specify a base Stage +3 image (see above) and crossdev target, respectively, e.g.: + +```sh +sh crossdev-image.sh --target armv7a-unknown-linux-gnueabihf +``` diff --git a/build-image.sh b/build-image.sh new file mode 100644 index 0000000..bec0f26 --- /dev/null +++ b/build-image.sh @@ -0,0 +1,63 @@ +#!/bin/sh + +target=aarch64-unknown-linux-gnu + +MIRROR=http://mirror.leaseweb.com/gentoo +URLPATH=releases/amd64/autobuilds +GENTOO_KEY=13EBBDBEDE7A12775DFDB1BABB572E0E2D182910 +GENTOO_KEYSERVER=hkps://keys.gentoo.org + +target=aarch64-unknown-linux-gnu +stage3=amd64-nomultilib-openrc +while [ $# -gt 0 ]; do + case "$1" in + -t|--target) + shift + target="$1" + ;; + -b|--base) + shift + stage3="$1" + ;; + *) + printf 'Unknown argument: %s\n' "$1" >&2 + exit 2 + ;; + esac +done + +set -e + +gpg --keyserver ${GENTOO_KEYSERVER} --recv-keys ${GENTOO_KEY} +curl -fLO "${MIRROR}/${URLPATH}/latest-stage3-${stage3}.txt" +gpg --verify "latest-stage3-${stage3}.txt" + +tarball=$(gpg --decrypt "latest-stage3-${stage3}.txt" | awk '$1!="#"{print $1}') +if [ ! -f "${tarball##*/}" ]; then + curl -fLO "${MIRROR}/${URLPATH}/${tarball}" +fi +if [ ! -f "${tarball##*/}.asc" ]; then + curl -fLO "${MIRROR}/${URLPATH}/${tarball}.asc" +fi +gpg --verify "${tarball##*/}.asc" + +cid=$(buildah from scratch) +buildah add ${cid} "${tarball##*/}" +buildah run \ + --mount type=cache,target=/var/db/repos/gentoo \ + --mount type=cache,target=/var/cache\ + -- ${cid} \ + sh -s - "${target}" \ + < build.sh \ +|| { + rc=$? + buildah rm ${cid} + exit $rc +} + +buildah config \ + --add-history \ + --cmd /bin/bash \ + --label target=${target} \ + ${cid} +buildah commit --rm --squash ${cid} aimee-os.org/build/cross-${target} diff --git a/common.sh b/common.sh new file mode 100644 index 0000000..0626b7a --- /dev/null +++ b/common.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +buildah_run_script() { + local cid script + cid=$1 + shift + script=$1 + shift + buildah run \ + --mount type=cache,target=/var/db/repos/gentoo \ + --mount type=cache,target=/var/cache \ + -- "${cid}" \ + sh -s - "$@" \ + < "${script}" +} diff --git a/crossdev-image.sh b/crossdev-image.sh new file mode 100644 index 0000000..ca17886 --- /dev/null +++ b/crossdev-image.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +SELF=$(readlink -f "$0") +SRCDIR=${SELF%/*} +. "${SRCDIR}"/common.sh + +target=aarch64-unknown-linux-gnu +stage3=amd64-nomultilib-openrc +while [ $# -gt 0 ]; do + case "$1" in + -t|--target) + shift + target="$1" + ;; + -b|--base) + shift + stage3="$1" + ;; + *) + printf 'Unknown argument: %s\n' "$1" >&2 + exit 2 + ;; + esac +done + +set -e + +cid=$(buildah from "aimee-os.org/gentoo/stage3-${stage3}") +buildah_run_script ${cid} sync.sh +buildah_run_script ${cid} crossdev.sh "${target}" +buildah config \ + --add-history \ + --cmd /bin/bash \ + --label target=${target} \ + ${cid} +buildah commit --rm ${cid} aimee-os.org/build/cross-${target} diff --git a/crossdev.sh b/crossdev.sh new file mode 100644 index 0000000..3b6dced --- /dev/null +++ b/crossdev.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +export FEATURES='-ipc-sandbox -network-sandbox -pid-sandbox' + +mkdir -p /var/db/repos/crossdev/profiles /var/db/repos/crossdev/metadata +echo crossdev > /var/db/repos/crossdev/profiles/repo_name +echo 'masters = gentoo' > /var/db/repos/crossdev/metadata/layout.conf +chown -R portage:portage /var/db/repos/crossdev +mkdir -p /etc/portage/repos.conf +cat > /etc/portage/repos.conf/crossdev.conf <