Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: building AArch64 (Mac M1) #33

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 14 additions & 18 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ 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")
export bib_image := env("BIB_IMAGE", "localhost/bootc-image-builder:latest")

alias build-vm := build-qcow2
alias rebuild-vm := rebuild-qcow2
Expand All @@ -20,7 +16,7 @@ default:
# Check Just Syntax
[group('Just')]
check:
#!/usr/bin/bash
#!/usr/bin/env bash
find . -type f -name "*.just" | while read -r file; do
echo "Checking syntax: $file"
just --unstable --fmt --check -f $file
Expand All @@ -31,7 +27,7 @@ check:
# Fix Just Syntax
[group('Just')]
fix:
#!/usr/bin/bash
#!/usr/bin/env bash
find . -type f -name "*.just" | while read -r file; do
echo "Checking syntax: $file"
just --unstable --fmt -f $file
Expand All @@ -42,7 +38,7 @@ fix:
# Clean Repo
[group('Utility')]
clean:
#!/usr/bin/bash
#!/usr/bin/env bash
set -eoux pipefail
touch _build
find *_build* -exec rm -rf {} \;
Expand All @@ -60,7 +56,7 @@ sudo-clean:
[group('Utility')]
[private]
sudoif command *args:
#!/usr/bin/bash
#!/usr/bin/env bash
function sudoif(){
if [[ "${UID}" -eq 0 ]]; then
"$@"
Expand Down Expand Up @@ -96,15 +92,15 @@ build $target_image=image_name $tag=default_tag:
LABELS+=("--label" "io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4")
LABELS+=("--label" "org.opencontainers.image.description=CentOS based images")

podman build \
sudo podman build \
"${BUILD_ARGS[@]}" \
"${LABELS[@]}" \
--pull=newer \
--tag "${target_image}:${tag}" \
.

_rootful_load_image $target_image=image_name $tag=default_tag:
#!/usr/bin/bash
#!/usr/bin/env bash
set -eoux pipefail

if [[ -n "${SUDO_USER:-}" || "${UID}" -eq "0" ]]; then
Expand All @@ -113,7 +109,7 @@ _rootful_load_image $target_image=image_name $tag=default_tag:
fi

set +e
resolved_tag=$(podman inspect -t image "${target_image}:${tag}" | jq -r '.[].RepoTags.[0]')
resolved_tag=$(sudo podman inspect -t image "${target_image}:${tag}" | jq -r '.[].RepoTags.[0]')
return_code=$?
set -e

Expand Down Expand Up @@ -158,12 +154,13 @@ _build-bib $target_image $tag $type $config: (_rootful_load_image target_image t
-it \
--privileged \
--pull=newer \
--net=host \
--security-opt label=type:unconfined_t \
-v $(pwd)/${config}:/config.toml:ro \
-v $(pwd)/output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
"${bib_image}" \
${args} \
${args} --rootfs ext4 \
"${target_image}"

sudo chown -R $USER:$USER output
Expand All @@ -189,7 +186,7 @@ rebuild-raw $target_image=("localhost/" + image_name) $tag=default_tag: && (_reb
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
#!/usr/bin/env bash
set -eoux pipefail

image_file="output/${type}/disk.${type}"
Expand All @@ -214,17 +211,16 @@ _run-vm $target_image $tag $type $config:
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 "RAM_SIZE=4G")
run_args+=(--env "DISK_SIZE=30G")
# 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}/${image_file}":"/boot.${type}")
run_args+=(docker.io/qemux/qemu-docker)
podman run "${run_args[@]}" &
sudo 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")
Expand Down
27 changes: 7 additions & 20 deletions image-builder-iso.config.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
[customizations.installer.kickstart]
contents = """
graphical --non-interactive
lang en_US.UTF-8
zerombr
clearpart --all --initlabel --disklabel=gpt
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
%post
bootc switch --mutate-in-place --transport registry ghcr.io/centos-workstation/main:latest
%end
"""

[customizations.installer.modules]
enable = [
"org.fedoraproject.Anaconda.Modules.Localization",
"org.fedoraproject.Anaconda.Modules.Storage"
]
disable = [
"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.Users",
"org.fedoraproject.Anaconda.Modules.Subscription",
"org.fedoraproject.Anaconda.Modules.Timezone",
"org.fedoraproject.Anaconda.Modules.Users"
"org.fedoraproject.Anaconda.Modules.Timezone"
]
Loading