From 4363e00728a9da9164e7f487b445b157d56cddb9 Mon Sep 17 00:00:00 2001 From: Tulip Blossom Date: Fri, 22 Nov 2024 22:45:33 -0300 Subject: [PATCH] feat(just): add bootc-image-builder step + use buildah for build --- image-builder.config.toml | 8 ++++ justfile | 79 +++++++++++++++------------------------ 2 files changed, 39 insertions(+), 48 deletions(-) create mode 100644 image-builder.config.toml diff --git a/image-builder.config.toml b/image-builder.config.toml new file mode 100644 index 0000000..32425de --- /dev/null +++ b/image-builder.config.toml @@ -0,0 +1,8 @@ +[[customizations.user]] +name = "ultramarine" +password = "ultramarine" +groups = ["wheel"] + +[[customizations.filesystem]] +mountpoint = "/" +minsize = "20 GiB" diff --git a/justfile b/justfile index 191c0c4..bb41412 100644 --- a/justfile +++ b/justfile @@ -1,49 +1,32 @@ -# registry_auth := "auth.json" -# ostree_cache := "/cache" -# ostree_repo := "ostree-repo" -# initialize := "--initialize" -# images_dir := "/images" - -# prep: -# [ -d {{ostree_cache}} ] || mkdir -p {{ostree_cache}} -# [ -d {{ostree_repo}} ] || ostree init --repo={{ostree_repo}} -# [ -d {{images_dir}} ] || mkdir -p {{images_dir}} - -# clean-cache: -# sudo rm -rf {{ ostree_cache }} - -# clean-variant variant: -# rm -rf ./out/{{variant}} - -# clean-out: -# rm -rf ./out - -# clean-repo: -# rm -rf ./{{ostree_repo}} - -# clean-images: -# rm -rf ./{{images_dir}} - -# clean: clean-cache clean-out clean-repo clean-images - -# compile variant: (clean-variant variant) -# melody compile ultramarine/{{variant}}.yaml out/{{variant}} - -# compose-tree variant: -# sudo rpm-ostree compose tree --cachedir={{ostree_cache}} --repo={{ostree_repo}} --unified-core out/{{variant}}/0.yaml - -# compose-image variant: -# sudo rpm-ostree compose image --cachedir={{ostree_cache}} {{initialize}} out/{{variant}}/0.yaml {{images_dir}}/$(echo "{{variant}}" | tr / -)-{{arch()}}.tar - -# build-tree variant: prep (compile variant) (compose-tree variant) -# build-image variant: prep (compile variant) (compose-image variant) - -image_name := "ghcr.io/ultramarine/base-standalone-bootc" - -build-base-standalone: - sudo buildah build --security-opt=label=disable --cap-add=all --device /dev/fuse -t {{image_name}} base-standalone - - +registry_prefix := "ghcr.io/ultramarine-linux" +build variant: + buildah bud -t {{ registry_prefix }}/{{ variant }}-bootc {{ variant }} + +build-vm image type="qcow2": + #!/usr/bin/env bash + set -euo pipefail + TARGET_IMAGE={{ image }} + + if ! sudo podman image exists $TARGET_IMAGE ; then + echo "Ensuring image is on root storage" + sudo podman image scp $USER@localhost::$TARGET_IMAGE root@localhost:: + fi - - + echo "Cleaning up previous build" + sudo rm -rf output || true + mkdir -p output + sudo podman run \ + --rm \ + -it \ + --privileged \ + --pull=newer \ + --security-opt label=type:unconfined_t \ + -v $(pwd)/image-builder.config.toml:/config.toml:ro \ + -v $(pwd)/output:/output \ + -v /var/lib/containers/storage:/var/lib/containers/storage \ + quay.io/centos-bootc/bootc-image-builder:latest \ + --type {{ type }} \ + --rootfs btrfs \ + --local \ + $TARGET_IMAGE + sudo chown -R $USER:$USER output