Compare commits
No commits in common. "main" and "lib/main" have entirely different histories.
|
@ -0,0 +1,7 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*.sh]
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
|
@ -0,0 +1,2 @@
|
||||||
|
stage3-*.tar.*
|
||||||
|
latest-*.txt
|
99
README.md
99
README.md
|
@ -1,55 +1,62 @@
|
||||||
# Aimee OS Build Container Images
|
# Aimee OS Build Container Images
|
||||||
|
|
||||||
This repository contains the build scripts for the container images that
|
Prerequisites:
|
||||||
provide the build environment for Aimee OS projects. Most projects will use
|
|
||||||
the _build/build-{target}_ image, which contains a cross-compiler toolchain for
|
* `buildah`
|
||||||
the _{target}_ system (e.g. _aarch64-unknown-linux-gnu_) with Rust support, as
|
|
||||||
well as several other tools for compiling software and creating bootable OS
|
|
||||||
images.
|
|
||||||
|
|
||||||
|
|
||||||
## Container Images
|
## Gentoo Stage 3 Image
|
||||||
|
|
||||||
There are several images in the collection:
|
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
|
||||||
gentoo/stage3 †
|
produce the container image. If none is specified, the latest
|
||||||
build/base
|
`stage3-amd64-nomultilib-openrc` tarball is downloaded and used.
|
||||||
└── build/cross-aarch64-unknown-linux-gnu
|
|
||||||
└── build/build-aarch64-unknown-linux-gnu ‡
|
|
||||||
```
|
|
||||||
|
|
||||||
† The _gentoo/stage3_ image contains an unmodified Gentoo stage3 system. It is
|
|
||||||
used to bootstrap the _build/base_ image.
|
|
||||||
|
|
||||||
‡ Although the _build/build-{target}_ image is initially populated from the
|
|
||||||
corresponding _build/cross-{target}_ image, the final image is "squashed" into
|
|
||||||
a single layer to minimize download size.
|
|
||||||
|
|
||||||
|
|
||||||
## Git Branches
|
|
||||||
|
|
||||||
To enable building images in Jenkins without building all of the preceding
|
|
||||||
images, each image has its own Jenkins job. Since Jenkins does not support
|
|
||||||
(auto discovering) multiple jobs in a single Git repository branch, the build
|
|
||||||
scripts for the images are tracked in separate branches. Each branch is named
|
|
||||||
like _{image}/{sub-branch}_, where _{image}_ is the short name of the image
|
|
||||||
(e.g. `base`, `cross`, etc) and _{sub-branch}_ is an arbitrary name (e.g.
|
|
||||||
_main_).
|
|
||||||
|
|
||||||
* _base/main_: This branch is responsible for building _gentoo/stage3_ and
|
|
||||||
_build/base_.
|
|
||||||
* _cross/main_: This branch contains the build script for
|
|
||||||
_build/cross-{target}_.
|
|
||||||
* _build/main_: This branch builds _build/build-{target}_.
|
|
||||||
|
|
||||||
In addition to the per-image branches, there is also _lib/{sub-branch}_.
|
|
||||||
Code shared by multiple image build scripts is tracked here. Build scripts
|
|
||||||
expect the shared code to be available in the `lib` directory, which is
|
|
||||||
generally populated using a Git worktree, e.g.:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git worktree add lib lib/main
|
sh image-build/gentoo-stage3.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
The _main_ branch itself is empty except for this README.
|
|
||||||
|
## 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.
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/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 "$@"
|
||||||
|
}
|
Reference in New Issue