Skip to content
This repository has been archived by the owner on Aug 6, 2024. It is now read-only.

Commit

Permalink
Allow configuration of build variant/platform (#3)
Browse files Browse the repository at this point in the history
- Improve Artifact naming (more consistent pattern)
- Add gl metal build
- Make `BUILD_VARIANT` configurable in ostreeRepo and ostreeImage feature
  • Loading branch information
fwilhe authored Oct 19, 2023
1 parent c7b9558 commit 2e2cc04
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 33 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ jobs:
- name: Build the image
run: ./build ostreeImage-${{ matrix.arch }}
working-directory: ./debian
- name: Upload ${{ matrix.arch }} image
- name: Rename build artifact
run: mv *ostreeImage-${{ matrix.arch }}-trixie-*.ostree.raw ostree-debian-image-${{ matrix.arch }}.raw
working-directory: ./debian/.build
- name: Upload debian ${{ matrix.arch }} image
uses: actions/upload-artifact@v3
with:
name: ostree-${{ matrix.arch }}-trixie-image
path: debian/.build/*ostreeImage-${{ matrix.arch }}-trixie-*.ostree.raw
name: ostree-debian-image-${{ matrix.arch }}
path: debian/.build/ostree-debian-image-${{ matrix.arch }}.raw
retention-days: 2

gardenlinux-image:
Expand All @@ -30,17 +33,23 @@ jobs:
fail-fast: false
matrix:
arch: [ amd64, arm64 ]
platform: [ kvm ]
platform: [ kvm, metal ]
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Configure Build Variant
run: echo ${{ matrix.platform }} > features/ostreeImage/BUILD_VARIANT
working-directory: ./gardenlinux
- name: Build the image
run: ./build ostreeImage-${{ matrix.arch }}
working-directory: ./gardenlinux
- name: Upload ${{ matrix.arch }} image
- name: Rename build artifact
run: mv *ostreeImage-${{ matrix.arch }}-today-*.ostree.raw ostree-gardenlinux-image-${{ matrix.platform }}-${{ matrix.arch }}.raw
working-directory: ./gardenlinux/.build
- name: Upload gardenlinux ${{ matrix.platform }} ${{ matrix.arch }} image
uses: actions/upload-artifact@v3
with:
name: ostreeImage-${{ matrix.arch }}
path: gardenlinux/.build/*ostreeImage-${{ matrix.arch }}-today-*.ostree.raw
name: ostree-gardenlinux-image-${{ matrix.platform }}-${{ matrix.arch }}
path: gardenlinux/.build/ostree-gardenlinux-image-${{ matrix.platform }}-${{ matrix.arch }}.raw
retention-days: 2
21 changes: 15 additions & 6 deletions .github/workflows/repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ jobs:
- name: Build the repo
run: ./build ostreeRepo-${{ matrix.arch }}
working-directory: ./debian
- name: Upload ${{ matrix.arch }} repo
- name: Rename build artifact
run: mv ostreeRepo-${{ matrix.arch }}-trixie*.ostreeRepo.tar.gz ostree-debian-repo-${{ matrix.arch }}.tar.gz
working-directory: ./debian/.build
- name: Upload debian ${{ matrix.arch }} repo
uses: actions/upload-artifact@v3
with:
name: ostree-${{ matrix.arch }}-trixie-repo
path: debian/.build/ostreeRepo-${{ matrix.arch }}-trixie*.ostreeRepo.tar.gz
name: ostree-debian-repo-${{ matrix.arch }}
path: debian/.build/ostree-debian-repo-${{ matrix.arch }}.tar.gz
retention-days: 2

gardenlinux-repo:
Expand All @@ -39,12 +42,18 @@ jobs:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Configure Build Variant
run: echo ${{ matrix.platform }} > features/ostreeRepo/BUILD_VARIANT
working-directory: ./gardenlinux
- name: Build the repo
run: ./build ${{ matrix.platform }}_dev_curl-ostreeRepo-${{ matrix.arch }}
working-directory: ./gardenlinux
- name: Upload ${{ matrix.arch }} repo
- name: Rename build artifact
run: mv ${{ matrix.platform }}*${{ matrix.arch }}*.ostreeRepo.tar.gz ostree-gardenlinux-repo-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz
working-directory: ./gardenlinux/.build
- name: Upload gardenlinux ${{ matrix.platform }} ${{ matrix.arch }} repo
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.platform }}_dev_curl-ostreeRepo-${{ matrix.arch }}
path: gardenlinux/.build/${{ matrix.platform }}*${{ matrix.arch }}*.ostreeRepo.tar.gz
name: ostree-gardenlinux-repo-${{ matrix.platform }}-${{ matrix.arch }}
path: gardenlinux/.build/ostree-gardenlinux-repo-${{ matrix.platform }}-${{ matrix.arch }}.tar.gz
retention-days: 2
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,24 @@ This directory contains a lot of code taken from the [gardenlinux/gardenlinux](h
To build it yourself, run inside the `gardenlinux` directory:

```bash
# Required: Set the platform. Must match between what is set in the BUILD_VARIANT file and in the repo argument.
# Allowd values for PLATFORM: kvm, metal
$ PLATFORM=kvm
$ echo $PLATFORM > features/ostreeRepo/BUILD_VARIANT
$ echo $PLATFORM > features/ostreeImage/BUILD_VARIANT
# Optional: To build the OSTree Repo
$ ./build kvm_dev_curl-ostreeRepo
$ ./build "$PLATFORM"_dev_curl-ostreeRepo
# To build the bootable image
$ ./build ostreeImage
```

Alternativly, use the `./ostree-build.sh` script:

```bash
./ostree-build.sh kvm
./ostree-build.sh metal
```

## Running

To boot any of the images, use the `start-vm` script from the root of this repository:
Expand Down
6 changes: 1 addition & 5 deletions debian/features/ostreeImage/image.ostree.raw
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,8 @@ OSTREE_SYSROOT="$MYROOT/sysroot"
OSTREE_REPO=$OSTREE_SYSROOT/ostree/repo
OSTREE_REF="debian/testing/$BUILDER_ARCH"

# REPO_CNAME=$(echo $BUILDER_CNAME | sed 's/Image/Repo/g')
# FIXME proper name building
REPO_CNAME=ostreeRepo-${BUILDER_ARCH}-trixie
REMOTE_NAME="$REPO_CNAME".ostreeRepo
REMOTE_ARCHIVE_NAME="$REMOTE_NAME.tar.gz"
REMOTE_URL="http://ostree.gardenlinux.io"
REMOTE_ARCHIVE_NAME=ostree-debian-repo-${BUILDER_ARCH}.tar.gz

rootfs="$1"
output="$2"
Expand Down
8 changes: 5 additions & 3 deletions debian/features/ostreeRepo/image.ostreeRepo.tar.gz
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ OSTREE_SYSROOT="$MYROOT/sysroot"
OSTREE_REPO=$OSTREE_SYSROOT/ostree/repo
OSTREE_REF="debian/testing/$BUILDER_ARCH"

REMOTE_NAME="$BUILDER_CNAME".ostreeRepo
REMOTE_ARCHIVE_NAME="$REMOTE_NAME.tar.gz"
REMOTE_URL="http://ostree.gardenlinux.io"
REMOTE_ARCHIVE_NAME=ostree-debian-repo-${BUILDER_ARCH}.tar.gz
REMOTE_NAME=debian-repo-${BUILDER_ARCH}

rootfs="$1"
output="$2"
Expand All @@ -43,9 +43,11 @@ if curl --head --silent --fail $REMOTE_URL/$REMOTE_ARCHIVE_NAME 2> /dev/null;
ostree admin init-fs --modern $OSTREE_SYSROOT
ostree admin os-init --sysroot=$OSTREE_SYSROOT debian
ostree config --repo=$OSTREE_REPO set sysroot.bootloader none
ostree remote --repo=$OSTREE_REPO add --no-gpg-verify --no-sign-verify origin $REMOTE_URL/$REMOTE_NAME $OSTREE_REF
fi

ostree remote --repo=$OSTREE_REPO delete --if-exists origin
ostree remote --repo=$OSTREE_REPO add --no-gpg-verify --no-sign-verify origin $REMOTE_URL/$REMOTE_NAME $OSTREE_REF

ostree commit --repo=$OSTREE_REPO --branch $OSTREE_REF --skip-if-unchanged -s "Debian $REMOTE_NAME $(date --utc +%Y-%m-%dT%H:%M%Z)" "$rootfs_work"

ostree log --repo=$OSTREE_REPO $OSTREE_REF
Expand Down
1 change: 1 addition & 0 deletions gardenlinux/features/ostreeImage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BUILD_VARIANT
15 changes: 8 additions & 7 deletions gardenlinux/features/ostreeImage/image.ostree.raw
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@ OSTREE_SYSROOT="$MYROOT/sysroot"
OSTREE_REPO=$OSTREE_SYSROOT/ostree/repo
OSTREE_REF="gardenlinux/today/$BUILDER_ARCH"

# REPO_CNAME=$(echo $BUILDER_CNAME | sed 's/Image/Repo/g')
# FIXME proper name building

REPO_CNAME=kvm-ostreeRepo_curl_dev-${BUILDER_ARCH}-today
REMOTE_NAME="$REPO_CNAME".ostreeRepo
REMOTE_ARCHIVE_NAME="$REMOTE_NAME.tar.gz"
# BUILD_VARIANT determains which repo we need to download (like metal, kvm, gcp, aws, azure, ..)
BUILD_VARIANT=$([ -f /builder/features/ostreeImage/BUILD_VARIANT ] && cat /builder/features/ostreeImage/BUILD_VARIANT || echo '')
# Use kvm as default variant when nothing is configured
BUILD_VARIANT="${BUILD_VARIANT:-kvm}"
REMOTE_URL="http://ostree.gardenlinux.io"
REMOTE_ARCHIVE_NAME=ostree-gardenlinux-repo-${BUILD_VARIANT}-${BUILDER_ARCH}.tar.gz
REMOTE_NAME=gardenlinux-repo-${BUILD_VARIANT}-${BUILDER_ARCH}

rootfs="$1"
output="$2"

tar xf "$rootfs" -C "$rootfs_work"
echo Building variant $BUILD_VARIANT

tar xf "$rootfs" -C "$rootfs_work"

mkdir -p $OSTREE_REPO
mkdir -p $OSTREE_SYSROOT
Expand Down
1 change: 1 addition & 0 deletions gardenlinux/features/ostreeRepo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BUILD_VARIANT
16 changes: 12 additions & 4 deletions gardenlinux/features/ostreeRepo/image.ostreeRepo.tar.gz
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ OSTREE_SYSROOT="$MYROOT/sysroot"
OSTREE_REPO=$OSTREE_SYSROOT/ostree/repo
OSTREE_REF="gardenlinux/today/$BUILDER_ARCH"

REMOTE_NAME="$BUILDER_CNAME".ostreeRepo
REMOTE_ARCHIVE_NAME="$REMOTE_NAME.tar.gz"
# BUILD_VARIANT determains which repo we need to download (like metal, kvm, gcp, aws, azure, ..)
BUILD_VARIANT=$([ -f /builder/features/ostreeRepo/BUILD_VARIANT ] && cat /builder/features/ostreeRepo/BUILD_VARIANT || echo '')
# Use kvm as default variant when nothing is configured
BUILD_VARIANT="${BUILD_VARIANT:-kvm}"
REMOTE_URL="http://ostree.gardenlinux.io"
REMOTE_ARCHIVE_NAME=ostree-gardenlinux-repo-${BUILD_VARIANT}-${BUILDER_ARCH}.tar.gz
REMOTE_NAME=gardenlinux-repo-${BUILD_VARIANT}-${BUILDER_ARCH}

rootfs="$1"
output="$2"

echo Building variant $BUILD_VARIANT

tar xf "$rootfs" -C "$rootfs_work"

mv "$rootfs_work"/etc "$rootfs_work"/usr/etc
Expand All @@ -43,10 +49,12 @@ if curl --head --silent --fail $REMOTE_URL/$REMOTE_ARCHIVE_NAME 2> /dev/null;
ostree admin init-fs --modern $OSTREE_SYSROOT
ostree admin os-init --sysroot=$OSTREE_SYSROOT gardenlinux
ostree config --repo=$OSTREE_REPO set sysroot.bootloader none
ostree remote --repo=$OSTREE_REPO add --no-gpg-verify --no-sign-verify origin $REMOTE_URL/$REMOTE_NAME $OSTREE_REF
fi

ostree commit --repo=$OSTREE_REPO --branch $OSTREE_REF --skip-if-unchanged -s "Garden Linux $REMOTE_NAME $(date --utc +%Y-%m-%dT%H:%M%Z)" "$rootfs_work"
ostree remote --repo=$OSTREE_REPO delete --if-exists origin
ostree remote --repo=$OSTREE_REPO add --no-gpg-verify --no-sign-verify origin $REMOTE_URL/$REMOTE_NAME $OSTREE_REF

ostree commit --repo=$OSTREE_REPO --branch $OSTREE_REF --skip-if-unchanged -s "Garden Linux $BUILD_VARIANT $(date --utc +%Y-%m-%dT%H:%M%Z)" "$rootfs_work"

ostree log --repo=$OSTREE_REPO $OSTREE_REF

Expand Down
15 changes: 15 additions & 0 deletions gardenlinux/ostree-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -o nounset
set -o errexit

if [[ "$#" -ne 1 ]]; then
echo "Usage: $(basename "$0") kvm|metal"
exit 1
fi

PLATFORM=$1

echo $PLATFORM > features/ostreeRepo/BUILD_VARIANT
echo $PLATFORM > features/ostreeImage/BUILD_VARIANT
./build "$PLATFORM"_dev_curl-ostreeRepo
./build ostreeImage

0 comments on commit 2e2cc04

Please sign in to comment.