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/lib/bootstrap.sh b/bootstrap.sh similarity index 100% rename from lib/bootstrap.sh rename to bootstrap.sh diff --git a/image-build/base.sh b/build.sh similarity index 86% rename from image-build/base.sh rename to build.sh index dfa1191..f138f29 100644 --- a/image-build/base.sh +++ b/build.sh @@ -1,7 +1,7 @@ #!/bin/sh SELF=$(readlink -f "$0") -SRCDIR=${SELF%/*/*} +SRCDIR=${SELF%/*} . "${SRCDIR}"/lib/common.sh base=aimee-os.org/gentoo/stage3-amd64-nomultilib-openrc:latest @@ -26,11 +26,11 @@ 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 +buildah_run_script "${work}" "${SRCDIR}"/bootstrap.sh cid=$(buildah from scratch) buildah copy "${cid}" "${builddir}" / -buildah_run_script "${cid}" "${SRCDIR}"/lib/profile.sh +buildah_run_script "${cid}" "${SRCDIR}"/profile.sh buildah config --cmd /bin/bash "${cid}" buildah commit --rm --squash "${cid}" aimee-os.org/build/base diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile index 9881660..44d9a74 100644 --- a/ci/Jenkinsfile +++ b/ci/Jenkinsfile @@ -8,27 +8,25 @@ pipeline { } stages { + stage('Prepare') { + steps { + 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('Gentoo Stage 3') { steps { - sh 'sh -e image-build/gentoo-stage3.sh' + sh 'sh -e gentoo-stage3.sh' } } stage('Base') { steps { - sh 'sh -e image-build/base.sh' - } - } - - stage('Cross') { - steps { - sh 'sh -e image-build/cross.sh' - } - } - - stage('Build') { - steps { - sh 'sh -e image-build/build.sh' + sh 'sh -e build.sh' } } @@ -50,8 +48,6 @@ pipeline { """ } 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/tools/fetch-stage3.sh b/fetch-stage3.sh similarity index 100% rename from tools/fetch-stage3.sh rename to fetch-stage3.sh diff --git a/image-build/gentoo-stage3.sh b/gentoo-stage3.sh similarity index 85% rename from image-build/gentoo-stage3.sh rename to gentoo-stage3.sh index ef1573a..6807e29 100644 --- a/image-build/gentoo-stage3.sh +++ b/gentoo-stage3.sh @@ -1,14 +1,14 @@ #!/bin/sh SELF=$(readlink -f "$0") -SRCDIR=${SELF%/*/*} +SRCDIR=${SELF%/*} tarball=$1 set -e if [ -z "${tarball}" ]; then - tarball=$(sh "${SRCDIR}"/tools/fetch-stage3.sh "$@") + tarball=$(sh "${SRCDIR}"/fetch-stage3.sh "$@") fi stage3=${tarball%.tar.*} version=${stage3##*-} 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/cross.sh b/image-build/cross.sh deleted file mode 100644 index a32cac8..0000000 --- a/image-build/cross.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh - -SELF=$(readlink -f "$0") -SRCDIR=${SELF%/*/*} -. "${SRCDIR}"/lib/common.sh - -target=aarch64-unknown-linux-gnu -base=aimee-os.org/build/base -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 - shift -done - -set -e - -cid=$(buildah from "${base}") -buildah_run_script "${cid}" "${SRCDIR}"/lib/sync.sh -buildah_run_script "${cid}" "${SRCDIR}"/lib/crossdev.sh "${target}" -buildah commit --rm "${cid}" aimee-os.org/build/cross-"${target}" diff --git a/lib/common.sh b/lib/common.sh deleted file mode 100644 index 21f1463..0000000 --- a/lib/common.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -buildah_run_script() { - local cid script - cid=$1 - shift - script=$(readlink -f "$1") - shift - mkdir -p binpkgs log tmp - buildah run \ - --mount type=cache,target=/var/db/repos/gentoo \ - --mount type=cache,target=/var/cache \ - --mount type=bind,src="${PWD}"/log,target=/var/log,rw,z \ - --mount type=bind,src="${PWD}"/tmp,target=/var/tmp,rw,z \ - --mount type=bind,src="${PWD}"/binpkgs,target=/var/cache/binpkgs,rw,z \ - --mount type=bind,src="${script}",target=/run/script,ro,z \ - --tty=false \ - -e FEATURES='-ipc-sandbox -network-sandbox -pid-sandbox' \ - "${cid}" \ - /run/script "$@" -} diff --git a/lib/crossdev.sh b/lib/crossdev.sh deleted file mode 100755 index f7d94b0..0000000 --- a/lib/crossdev.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -set -e - -target=$1 - -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 < /etc/portage/package.accept-keywords/rust-cross -echo 'dev-lang/rust rust-src' \ - > /etc/portage/package.use/rust-src -case ${target%%-*} in -aarch64) - llvm_target=AArch64 - ;; -arm*) - llvm_target=ARM - ;; -*) - printf 'Unknown LLVM target: %s' "${target%%-*}" - exit 1 - ;; -esac -printf '( %s:%s:%s )\n' \ - "${llvm_target}" \ - "${target}" \ - "${target}" \ - >> /etc/portage/env/dev-lang/rust -emerge -vbknuUj cross-${target}/rust-std diff --git a/lib/sync.sh b/lib/sync.sh deleted file mode 100755 index ca5fc97..0000000 --- a/lib/sync.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -if [ ! -e /var/db/repos/gentoo/metadata ]; then - emerge-webrsync -fi -if [ "$(find /var/db/repos/gentoo/metadata -newermt '-24 hours' | wc -l)" -eq 0 ]; then - emaint sync -fi diff --git a/lib/tools.sh b/lib/tools.sh deleted file mode 100755 index ac4d8fa..0000000 --- a/lib/tools.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -xargs -r emerge -vnuUj --rebuilt-binaries=y <