From 954f9ff5531b6f1c195dd0695c98e20d2b8cfc06 Mon Sep 17 00:00:00 2001 From: Jason DeTiberus <915544+detiber@users.noreply.github.com> Date: Thu, 19 Dec 2024 22:09:13 -0500 Subject: [PATCH] update to forked bib iamge to build iso --- Justfile | 79 ++++++++++++++++++----------------- image-builder-iso.config.toml | 18 +++++++- 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/Justfile b/Justfile index bef935f..bd7c29f 100644 --- a/Justfile +++ b/Justfile @@ -3,6 +3,16 @@ export image_name := env("IMAGE_NAME", "main") export centos_version := env("CENTOS_VERSION", "stream10") export default_tag := env("DEFAULT_TAG", "latest") +# work around issue with upstream image builder, +# should converge back on upstream (quay.io/centos-bootc/bootc-image-builder:latest) +# asap + +export bib_image := env("BIB_IMAGE", "ghcr.io/centos-workstation/bootc-image-builder:latest") + +alias build-vm := build-qcow2 +alias rebuild-vm := rebuild-qcow2 +alias run-vm := run-vm-qcow2 + [private] default: @just --list @@ -123,6 +133,8 @@ _build-bib $target_image $tag $type $config: (_rootful_load_image target_image t #!/usr/bin/env bash set -euo pipefail + mkdir -p "output" + echo "Cleaning up previous build" sudo rm -rf "output/${type}" || true sudo rm "output/manifest-${type}.json" || true @@ -142,7 +154,7 @@ _build-bib $target_image $tag $type $config: (_rootful_load_image target_image t -v $(pwd)/${config} \ -v $(pwd)/output:/output \ -v /var/lib/containers/storage:/var/lib/containers/storage \ - quay.io/centos-bootc/bootc-image-builder:latest \ + "${bib_image}" \ ${args} \ "${target_image}" @@ -153,52 +165,34 @@ _build-bib $target_image $tag $type $config: (_rootful_load_image target_image t sudo qemu-img resize "output/qcow2/disk.qcow2" 80G fi -build-vm $target_image=("localhost/" + image_name) $tag=default_tag: && (_build-bib target_image tag "qcow2" "image-builder.config.toml") +_rebuild-bib $target_image $tag $type $config: (build target_image tag) && (_build-bib target_image tag type config) -build-iso $target_image=("localhost/" + image_name) $tag=default_tag: && (_build-bib target_image tag "iso" "image-builder-iso.config.toml") +[group('Build Virtal Machine Image')] +build-qcow2 $target_image=("localhost/" + image_name) $tag=default_tag: && (_build-bib target_image tag "qcow2" "image-builder.config.toml") -run-vm $target_image=("localhost/" + image_name) $tag=default_tag: - #!/usr/bin/bash - set -eoux pipefail +[group('Build Virtal Machine Image')] +build-raw $target_image=("localhost/" + image_name) $tag=default_tag: && (_build-bib target_image tag "raw" "image-builder.config.toml") - qcow2_file="output/qcow2/disk.qcow2" +[group('Build Virtal Machine Image')] +build-iso $target_image=("localhost/" + image_name) $tag=default_tag: && (_build-bib target_image tag "iso" "image-builder-iso.config.toml") - if [[ ! -f "${qcow2_file}" ]]; then - just build-vm "$target_image" "$tag" - fi +[group('Build Virtal Machine Image')] +rebuild-qcow2 $target_image=("localhost/" + image_name) $tag=default_tag: && (_rebuild-bib target_image tag "qcow2" "image-builder.config.toml") - # Determine which port to use - port=8006; - while grep -q :${port} <<< $(ss -tunalp); do - port=$(( port + 1 )) - done - echo "Using Port: ${port}" - echo "Connect to http://localhost:${port}" - run_args=() - run_args+=(--rm --privileged) - run_args+=(--pull=newer) - run_args+=(--publish "127.0.0.1:${port}:8006") - run_args+=(--env "CPU_CORES=4") - run_args+=(--env "RAM_SIZE=8G") - run_args+=(--env "DISK_SIZE=64G") - # run_args+=(--env "BOOT_MODE=windows_secure") - run_args+=(--env "TPM=Y") - run_args+=(--env "GPU=Y") - run_args+=(--device=/dev/kvm) - run_args+=(--volume "${PWD}/${qcow2_file}":"/boot.qcow2") - run_args+=(docker.io/qemux/qemu-docker) - podman run "${run_args[@]}" & - xdg-open http://localhost:${port} - fg "%podman" +[group('Build Virtal Machine Image')] +rebuild-raw $target_image=("localhost/" + image_name) $tag=default_tag: && (_rebuild-bib target_image tag "raw" "image-builder.config.toml") -run-iso $target_image=("localhost/" + image_name) $tag=default_tag: +[group('Build Virtal Machine Image')] +rebuild-iso $target_image=("localhost/" + image_name) $tag=default_tag: && (_rebuild-bib target_image tag "iso" "image-builder-iso.config.toml") + +_run-vm $target_image $tag $type $config: #!/usr/bin/bash set -eoux pipefail - iso_file="output/iso/myiso.iso" + image_file="output/${type}/disk.${type}" - if [[ ! -f "${iso_file}" ]]; then - just build-iso "$target_image" "$tag" + if [[ ! -f "${image_file}" ]]; then + just "build-${type}" "$target_image" "$tag" fi # Determine which port to use @@ -219,8 +213,17 @@ run-iso $target_image=("localhost/" + image_name) $tag=default_tag: run_args+=(--env "TPM=Y") run_args+=(--env "GPU=Y") run_args+=(--device=/dev/kvm) - run_args+=(--volume "${PWD}/${iso_file}":"/boot.iso") + run_args+=(--volume "${PWD}/${image_file}":"/boot.${type}") run_args+=(docker.io/qemux/qemu-docker) podman run "${run_args[@]}" & xdg-open http://localhost:${port} fg "%podman" + +[group('Run Virtal Machine')] +run-vm-qcow2 $target_image=("localhost/" + image_name) $tag=default_tag: && (_run-vm target_image tag "qcow2" "image-builder.config.toml") + +[group('Run Virtal Machine')] +run-vm-raw $target_image=("localhost/" + image_name) $tag=default_tag: && (_run-vm target_image tag "raw" "image-builder.config.toml") + +[group('Run Virtal Machine')] +run-vm-iso $target_image=("localhost/" + image_name) $tag=default_tag: && (_run-vm target_image tag "iso" "image-builder-iso.config.toml") diff --git a/image-builder-iso.config.toml b/image-builder-iso.config.toml index 823930b..30a7b32 100644 --- a/image-builder-iso.config.toml +++ b/image-builder-iso.config.toml @@ -4,15 +4,29 @@ graphical --non-interactive lang en_US.UTF-8 zerombr clearpart --all --initlabel --disklabel=gpt -autopart --noswap --type btrfs +autopart --noswap --type xfs network --bootproto=dhcp --device=link --activate --onboot=on timezone --utc America/New_York firstboot --enable reboot + +%post --nochroot +flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo +flatpak install flathub com.github.tchx84.Flatseal -y +flatpak install flathub org.keepassxc.KeePassXC -y +%end """ [customizations.installer.modules] enable = [ "org.fedoraproject.Anaconda.Modules.Localization", - "org.fedoraproject.Anaconda.Modules.Timezone" + "org.fedoraproject.Anaconda.Modules.Network", + "org.fedoraproject.Anaconda.Modules.Payloads", + "org.fedoraproject.Anaconda.Modules.Runtime", + "org.fedoraproject.Anaconda.Modules.Security", + "org.fedoraproject.Anaconda.Modules.Services", + "org.fedoraproject.Anaconda.Modules.Storage", + "org.fedoraproject.Anaconda.Modules.Subscription", + "org.fedoraproject.Anaconda.Modules.Timezone", + "org.fedoraproject.Anaconda.Modules.Users" ]