diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index ba1c9e1..914bcd8 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -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: @@ -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 diff --git a/.github/workflows/repo.yml b/.github/workflows/repo.yml index 46f053e..c99557b 100644 --- a/.github/workflows/repo.yml +++ b/.github/workflows/repo.yml @@ -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: @@ -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 diff --git a/README.md b/README.md index 5ee777e..56c4905 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/debian/features/ostreeImage/image.ostree.raw b/debian/features/ostreeImage/image.ostree.raw index afe1d5b..1ae5040 100755 --- a/debian/features/ostreeImage/image.ostree.raw +++ b/debian/features/ostreeImage/image.ostree.raw @@ -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" diff --git a/debian/features/ostreeRepo/image.ostreeRepo.tar.gz b/debian/features/ostreeRepo/image.ostreeRepo.tar.gz index 5d0a696..e5a4dfa 100755 --- a/debian/features/ostreeRepo/image.ostreeRepo.tar.gz +++ b/debian/features/ostreeRepo/image.ostreeRepo.tar.gz @@ -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" @@ -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 diff --git a/gardenlinux/features/ostreeImage/.gitignore b/gardenlinux/features/ostreeImage/.gitignore new file mode 100644 index 0000000..c6fa83e --- /dev/null +++ b/gardenlinux/features/ostreeImage/.gitignore @@ -0,0 +1 @@ +BUILD_VARIANT diff --git a/gardenlinux/features/ostreeImage/image.ostree.raw b/gardenlinux/features/ostreeImage/image.ostree.raw index 3dc93b4..2c37f09 100755 --- a/gardenlinux/features/ostreeImage/image.ostree.raw +++ b/gardenlinux/features/ostreeImage/image.ostree.raw @@ -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 diff --git a/gardenlinux/features/ostreeRepo/.gitignore b/gardenlinux/features/ostreeRepo/.gitignore new file mode 100644 index 0000000..c6fa83e --- /dev/null +++ b/gardenlinux/features/ostreeRepo/.gitignore @@ -0,0 +1 @@ +BUILD_VARIANT diff --git a/gardenlinux/features/ostreeRepo/image.ostreeRepo.tar.gz b/gardenlinux/features/ostreeRepo/image.ostreeRepo.tar.gz index 7853d1f..d19d42a 100755 --- a/gardenlinux/features/ostreeRepo/image.ostreeRepo.tar.gz +++ b/gardenlinux/features/ostreeRepo/image.ostreeRepo.tar.gz @@ -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 @@ -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 diff --git a/gardenlinux/ostree-build.sh b/gardenlinux/ostree-build.sh new file mode 100755 index 0000000..e2f3b39 --- /dev/null +++ b/gardenlinux/ostree-build.sh @@ -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