From 359e5f3c3b38fba878e86501a1ea5e9be02dc818 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Wed, 18 Dec 2024 18:12:38 -0600 Subject: [PATCH] split-repo: Populate cross branch In order to create multiple Jenkins build pipelines for this repository, I'm splitting it up with branches. There will be a branch for each image: * base/main: The base image * cross/main: The image with a cross-compiler toolchain * build/main: The final build image Note _/main_ in each name. The intent here is to be able to have different "sub-branches" for each image, so e.g. there might be a _base/dev_. In addition to the branches for each image, there will be branches for the shared library code as well, named like _lib/main_. The image branches will checkout this branch using `git worktree`. --- README.md | 62 ------------------------ image-build/cross.sh => build.sh | 4 +- ci/Jenkinsfile | 24 +++------ lib/crossdev.sh => crossdev.sh | 0 image-build/base.sh | 39 --------------- image-build/build.sh | 35 ------------- image-build/gentoo-stage3.sh | 22 --------- lib/bootstrap.sh | 29 ----------- lib/common.sh | 21 -------- lib/profile.sh | 11 ----- lib/sync.sh | 8 --- lib/tools.sh | 20 -------- portage/env/nobuildpkg | 1 - portage/make.conf/15-keywords.conf | 1 - portage/make.conf/20-binpkgs.conf | 2 - portage/make.conf/60-nls.conf | 1 - portage/make.conf/80-quiet.conf | 2 - portage/package.accept_keywords/genimage | 1 - portage/package.accept_keywords/kernel | 1 - portage/package.env/kernel | 6 --- portage/package.use/btrfs-progs | 1 - portage/package.use/git | 1 - portage/package.use/grub | 1 - portage/package.use/kernel | 2 - portage/package.use/qemu | 5 -- portage/package.use/selinux | 2 - portage/package.use/squashfs-tools | 1 - portage/package.use/systemd | 6 --- tools/fetch-stage3.sh | 24 --------- 29 files changed, 9 insertions(+), 324 deletions(-) delete mode 100644 README.md rename image-build/cross.sh => build.sh (86%) rename lib/crossdev.sh => crossdev.sh (100%) delete mode 100644 image-build/base.sh delete mode 100644 image-build/build.sh delete mode 100644 image-build/gentoo-stage3.sh delete mode 100755 lib/bootstrap.sh delete mode 100644 lib/common.sh delete mode 100755 lib/profile.sh delete mode 100755 lib/sync.sh delete mode 100755 lib/tools.sh delete mode 100644 portage/env/nobuildpkg delete mode 100644 portage/make.conf/15-keywords.conf delete mode 100644 portage/make.conf/20-binpkgs.conf delete mode 100644 portage/make.conf/60-nls.conf delete mode 100644 portage/make.conf/80-quiet.conf delete mode 100644 portage/package.accept_keywords/genimage delete mode 100644 portage/package.accept_keywords/kernel delete mode 100644 portage/package.env/kernel delete mode 100644 portage/package.use/btrfs-progs delete mode 100644 portage/package.use/git delete mode 100644 portage/package.use/grub delete mode 100644 portage/package.use/kernel delete mode 100644 portage/package.use/qemu delete mode 100644 portage/package.use/selinux delete mode 100644 portage/package.use/squashfs-tools delete mode 100644 portage/package.use/systemd delete mode 100644 tools/fetch-stage3.sh diff --git a/README.md b/README.md deleted file mode 100644 index 6ccd589..0000000 --- a/README.md +++ /dev/null @@ -1,62 +0,0 @@ -# Aimee OS Build Container Images - -Prerequisites: - -* `buildah` - - -## Gentoo Stage 3 Image - -This image is used to bootstrap the base layer for Aimee OS build images. To -build it, use the `gentoo-stage3.sh` build script. This script takes a single -(optional) positional argument: the name of a Gentoo stage 3 tarball to use to -produce the container image. If none is specified, the latest -`stage3-amd64-nomultilib-openrc` tarball is downloaded and used. - -```sh -sh image-build/gentoo-stage3.sh -``` - - -## Base Image - -The Aimee OS base build image is a minimal environment based on Gentoo. It -includes Portage and a basic build toolchain. Building it requires a Stage 3 -image to bootstrap the environment. By default, -_aimee-os.org/gentoo/stage3-amd64-nomultilib-openrc:latest_ is used, but an -alternative image can be specified using the `-b`/`--base` argument to the -`base.sh` script. - -```sh -sh image-build/base.sh -``` - - -## Crossdev Image - -This image includes a cross-compilation toolchain, generated by _crossdev_. It -is built using the `cross.sh` script. This script takes a `-t`/`--target` -argument, which specifies the toolchain to generate. The default is -`aarch64-unknown-linux-gnu`. This image is layered on top of the base image, -which can be specified using the `-b`/`--base` argument. By default, -_aimee-os.org/build/base:latest_ is used. - -```sh -sh image-build/cross.sh -``` - -## Build Image - -The top-level image is based on the Crossdev image, and includes additional -tools for building an Aimee OS project. It is built using the `build.sh` script. -As with the Crossdev image build script, this script accepts `-t`/`--target` -and `-b`/`--build` arguments, which specify the cross-compilation toolchain and -base image later, respectively. - -```sh -sh image-build/build.sh -``` - -This image is "squashed," meaning it consists of only a single layer. The Base -and Crossdev image layers are merged into the final layer when the image is -built. This reduces the final size of the image. diff --git a/image-build/cross.sh b/build.sh similarity index 86% rename from image-build/cross.sh rename to build.sh index a32cac8..0d65517 100644 --- a/image-build/cross.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/sh SELF=$(readlink -f "$0") -SRCDIR=${SELF%/*/*} +SRCDIR=${SELF%/*} . "${SRCDIR}"/lib/common.sh target=aarch64-unknown-linux-gnu @@ -28,5 +28,5 @@ set -e cid=$(buildah from "${base}") buildah_run_script "${cid}" "${SRCDIR}"/lib/sync.sh -buildah_run_script "${cid}" "${SRCDIR}"/lib/crossdev.sh "${target}" +buildah_run_script "${cid}" "${SRCDIR}"/crossdev.sh "${target}" buildah commit --rm "${cid}" aimee-os.org/build/cross-"${target}" diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 9881660..b321707 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -8,27 +8,19 @@ pipeline { } stages { - stage('Gentoo Stage 3') { + stage('Prepare') { steps { - sh 'sh -e image-build/gentoo-stage3.sh' - } - } - - stage('Base') { - steps { - sh 'sh -e image-build/base.sh' - } - } - - stage('Cross') { - steps { - sh 'sh -e image-build/cross.sh' + container('jnlp') { + // TODO checkout lib/ branch based on $BRANCH_NAME + sh 'git fetch origin lib/main:lib/main' + sh 'git worktree add lib lib/main' + } } } stage('Build') { steps { - sh 'sh -e image-build/build.sh' + sh 'sh -e build.sh --base git.pyrocufflink.net/aimeeos/build/base' } } @@ -49,9 +41,7 @@ pipeline { git.pyrocufflink.net """ } - sh 'buildah push aimee-os.org/build/base git.pyrocufflink.net/aimeeos/build/base' sh 'buildah push aimee-os.org/build/cross-aarch64-unknown-linux-gnu git.pyrocufflink.net/aimeeos/build/cross-aarch64-unknown-linux-gnu' - sh 'buildah push aimee-os.org/build/build-aarch64-unknown-linux-gnu git.pyrocufflink.net/aimeeos/build/build-aarch64-unknown-linux-gnu' } } } diff --git a/lib/crossdev.sh b/crossdev.sh similarity index 100% rename from lib/crossdev.sh rename to crossdev.sh diff --git a/image-build/base.sh b/image-build/base.sh deleted file mode 100644 index dfa1191..0000000 --- a/image-build/base.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh - -SELF=$(readlink -f "$0") -SRCDIR=${SELF%/*/*} -. "${SRCDIR}"/lib/common.sh - -base=aimee-os.org/gentoo/stage3-amd64-nomultilib-openrc:latest -while [ $# -gt 0 ]; do - case "$1" in - -b|--base) - shift - base="$1" - ;; - *) - printf 'Unknown argument: %s\n' "$1" >&2 - exit 2 - ;; - esac -done - -set -e - -builddir=$(export TMPDIR=${TMPDIR:-${PWD}} && mktemp -d gentoo.XXXXXX) -builddir=$(readlink -f "${builddir}") - -work=$(buildah from -v "${builddir}":/mnt/gentoo:rw,Z "${base}") -buildah add "${work}" portage /etc/portage/ -buildah_run_script "${work}" "${SRCDIR}"/lib/sync.sh -buildah_run_script "${work}" "${SRCDIR}"/lib/bootstrap.sh - -cid=$(buildah from scratch) -buildah copy "${cid}" "${builddir}" / -buildah_run_script "${cid}" "${SRCDIR}"/lib/profile.sh -buildah config --cmd /bin/bash "${cid}" -buildah commit --rm --squash "${cid}" aimee-os.org/build/base - -buildah run "${work}" find /mnt/gentoo -mindepth 1 -delete -buildah rm "${work}" -rmdir "${builddir}" diff --git a/image-build/build.sh b/image-build/build.sh deleted file mode 100644 index b78396d..0000000 --- a/image-build/build.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -SELF=$(readlink -f "$0") -SRCDIR=${SELF%/*/*} -. "${SRCDIR}"/lib/common.sh - -target=aarch64-unknown-linux-gnu -while [ $# -gt 0 ]; do - case "$1" in - -t|--target) - shift - target="$1" - ;; - -b|--base) - shift - base="$1" - ;; - *) - printf 'Unknown argument: %s\n' "$1" >&2 - exit 2 - ;; - esac -done - -if [ -z "${base-}" ]; then - base=aimee-os.org/build/cross-"${target}" -fi - -set -e - -cid=$(buildah from "${base}") -buildah add "${cid}" portage /etc/portage -buildah_run_script "${cid}" "${SRCDIR}"/lib/sync.sh -buildah_run_script "${cid}" "${SRCDIR}"/lib/tools.sh -buildah commit --rm --squash "${cid}" "aimee-os.org/build/build-${target}" diff --git a/image-build/gentoo-stage3.sh b/image-build/gentoo-stage3.sh deleted file mode 100644 index ef1573a..0000000 --- a/image-build/gentoo-stage3.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -SELF=$(readlink -f "$0") -SRCDIR=${SELF%/*/*} - -tarball=$1 - -set -e - -if [ -z "${tarball}" ]; then - tarball=$(sh "${SRCDIR}"/tools/fetch-stage3.sh "$@") -fi -stage3=${tarball%.tar.*} -version=${stage3##*-} -stage3=${stage3%-*} - -cid=$(buildah from scratch) -buildah add "${cid}" "${tarball}" -buildah config --cmd /bin/bash "${cid}" -buildah commit --rm --squash "${cid}" "aimee-os.org/gentoo/${stage3}:${version}" -buildah tag "aimee-os.org/gentoo/${stage3}:${version}" \ - "aimee-os.org/gentoo/${stage3}:latest" diff --git a/lib/bootstrap.sh b/lib/bootstrap.sh deleted file mode 100755 index e2fe3cd..0000000 --- a/lib/bootstrap.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -set -e - -mkdir -p /mnt/gentoo - -USE=build \ -emerge -kvnuUDj --rebuilt-binaries=y --root=/mnt/gentoo sys-apps/baselayout - -# Portage itself only requires Python and Bash. Actually building -# packages requires a lot more. These dependencies are implicit because -# they are listed in @system. We do not want everything from @system, -# though, so we have to explicitly install several packages. -# -# At some point, we may end up with an Aimee OS profile for Portage. -# If/when that happens, we can override @system to remove the stuff we -# don't want, like virtual/service-manager and virtual/openssh. -xargs emerge -kvnuUDj --rebuilt-binaries=y --root=/mnt/gentoo < (09 Feb 2023) -# Do not build binary packages for kernel sources -sys-kernel/gentoo-sources nobuildpkg -sys-kernel/raspberrypi-sources nobuildpkg diff --git a/portage/package.use/btrfs-progs b/portage/package.use/btrfs-progs deleted file mode 100644 index eca7fed..0000000 --- a/portage/package.use/btrfs-progs +++ /dev/null @@ -1 +0,0 @@ -sys-fs/btrfs-progs -man diff --git a/portage/package.use/git b/portage/package.use/git deleted file mode 100644 index 46e62d2..0000000 --- a/portage/package.use/git +++ /dev/null @@ -1 +0,0 @@ -dev-vcs/git -perl diff --git a/portage/package.use/grub b/portage/package.use/grub deleted file mode 100644 index e032517..0000000 --- a/portage/package.use/grub +++ /dev/null @@ -1 +0,0 @@ -sys-boot/grub -* GRUB_PLATFORMS: -* diff --git a/portage/package.use/kernel b/portage/package.use/kernel deleted file mode 100644 index 5f091c9..0000000 --- a/portage/package.use/kernel +++ /dev/null @@ -1,2 +0,0 @@ -sys-kernel/gentoo-sources symlink -sys-kernel/raspberrypi-sources symlink diff --git a/portage/package.use/qemu b/portage/package.use/qemu deleted file mode 100644 index ab67f81..0000000 --- a/portage/package.use/qemu +++ /dev/null @@ -1,5 +0,0 @@ -# vim: set ft=gentoo-package-use : - -# Dustin C. Hatch (11 Dec 2024) -# Build a minimal QEMU for chrooting into the target environment -app-emulation/qemu -* QEMU_USER_TARGETS: aarch64 PYTHON_TARGETS: python3_12 diff --git a/portage/package.use/selinux b/portage/package.use/selinux deleted file mode 100644 index 14ea6e0..0000000 --- a/portage/package.use/selinux +++ /dev/null @@ -1,2 +0,0 @@ -sys-libs/libselinux python -sys-process/audit python diff --git a/portage/package.use/squashfs-tools b/portage/package.use/squashfs-tools deleted file mode 100644 index 27ddfb0..0000000 --- a/portage/package.use/squashfs-tools +++ /dev/null @@ -1 +0,0 @@ -sys-fs/squashfs-tools zstd diff --git a/portage/package.use/systemd b/portage/package.use/systemd deleted file mode 100644 index a0d6dce..0000000 --- a/portage/package.use/systemd +++ /dev/null @@ -1,6 +0,0 @@ -sys-apps/dbus systemd -sys-apps/systemd -* PYTHON_SINGLE_TARGET: python3_12 -sec-policy/selinux-base systemd -sec-policy/selinux-base-policy systemd -virtual/tmpfiles systemd -virtual/udev systemd diff --git a/tools/fetch-stage3.sh b/tools/fetch-stage3.sh deleted file mode 100644 index 011f1f5..0000000 --- a/tools/fetch-stage3.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -: "${GENTOO_MIRROR:=http://mirror.leaseweb.com/gentoo}" -URLPATH=releases/amd64/autobuilds -GENTOO_KEY=13EBBDBEDE7A12775DFDB1BABB572E0E2D182910 -GENTOO_KEYSERVER=hkps://keys.gentoo.org - -stage3="${1:-amd64-nomultilib-openrc}" - -set -e - -gpg --keyserver ${GENTOO_KEYSERVER} --recv-keys ${GENTOO_KEY} -curl -fLO "${GENTOO_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 "${GENTOO_MIRROR}/${URLPATH}/${tarball}" -fi -if [ ! -f "${tarball##*/}.asc" ]; then - curl -fLO "${GENTOO_MIRROR}/${URLPATH}/${tarball}.asc" -fi -gpg --verify "${tarball##*/}.asc" -echo "${tarball##*/}"