feat: add functional live ISO

This commit is contained in:
Tulip Blossom 2025-03-19 02:36:21 -03:00
parent afd4f19be6
commit 9ecd274e4e
No known key found for this signature in database
5 changed files with 147 additions and 2 deletions

5
.gitignore vendored Normal file
View file

@ -0,0 +1,5 @@
*.img
rootfs
*.raw
*.iso
work

95
Justfile Normal file
View file

@ -0,0 +1,95 @@
workdir := env("TITANOBOA_WORKDIR", "work")
isoroot := env("TITANOBOA_ISO_ROOT", "work/iso-root")
init-work:
mkdir -p {{ workdir }}
mkdir -p {{ isoroot }}
initramfs $IMAGE: init-work
#!/usr/bin/env bash
# THIS NEEDS dracut-live
set -xeuo pipefail
sudo podman run --privileged --rm -it -v .:/tmp/test:Z $IMAGE \
sh -c '
set -xeuo pipefail
sudo dnf install -y dracut dracut-live kernel
INSTALLED_KERNEL=$(rpm -q kernel-core --queryformat "%{evr}.%{arch}" | tail -n 1)
cat >/tmp/fake-uname <<EOF
#!/usr/bin/env bash
if [ "\$1" == "-r" ] ; then
echo ${INSTALLED_KERNEL}
exit 0
fi
exec /usr/bin/uname \$@
EOF
install -Dm0755 /tmp/fake-uname /tmp/bin/uname
PATH=/tmp/bin:$PATH dracut --zstd --reproducible --no-hostonly --add dmsquash-live --add dmsquash-live-autooverlay --force /tmp/test/{{ workdir }}/initramfs.img'
rootfs $IMAGE: init-work
#!/usr/bin/env bash
set -xeuo pipefail
ROOTFS="{{ workdir }}/rootfs"
mkdir -p $ROOTFS
sudo podman export "$(sudo podman create "${IMAGE}")" | tar -xf - -C "${ROOTFS}"
squash $IMAGE: init-work
#!/usr/bin/env bash
set -xeuo pipefail
ROOTFS="{{ workdir }}/rootfs"
# Needs to be squashfs.img due to dracut default name (can be configured on grub.cfg)
if [ -e "{{ workdir }}/squashfs.img" ] ; then
exit 0
fi
sudo podman run --privileged --rm -it -v .:/tmp/test:Z -v "./${ROOTFS}:/rootfs:Z" "${IMAGE}" sh -c "
set -xeuo pipefail
sudo dnf install -y squashfs-tools
mksquashfs /rootfs /tmp/test/{{ workdir }}/squashfs.img"
iso-organize: init-work
#!/usr/bin/env bash
set -xeuo pipefail
mkdir -p {{ isoroot }}/boot/grub {{ isoroot }}/LiveOS
cp src/grub.cfg {{ isoroot }}/boot/grub
cp {{ workdir }}/rootfs/lib/modules/*/vmlinuz {{ isoroot }}/boot
sudo cp {{ workdir }}/initramfs.img {{ isoroot }}/boot
sudo mv {{ workdir }}/squashfs.img {{ isoroot }}/LiveOS/squashfs.img
iso $IMAGE:
#!/usr/bin/env bash
# grub2 grub2-tools-extra xorriso
set -xeuo pipefail
sudo podman run --privileged --rm -it -v .:/tmp/test:Z registry.fedoraproject.org/fedora:41 \
sh -c "
set -xeuo pipefail
sudo dnf install -y grub2 grub2-tools-extra xorriso
grub2-mkrescue --xorriso=/tmp/test/src/xorriso_wrapper.sh -o /tmp/test/output.iso /tmp/test/{{ isoroot }}"
build $IMAGE:
#!/usr/bin/env bash
set -xeuo pipefail
just clean
just initramfs "${IMAGE}"
just rootfs "${IMAGE}"
just squash "${IMAGE}"
just iso-organize
just iso "${IMAGE}"
clean:
rm -rf {{ workdir }}
rm -rf output.iso
vm *ARGS:
#!/usr/bin/env bash
flatpak run "--command=qemu-system-$(arch)" org.virt_manager.virt-manager \
-enable-kvm \
-M q35 \
-cpu host \
-smp 1 \
-m 4G \
-net nic,model=virtio \
-net user,hostfwd=tcp::2222-:22 \
-display gtk \
-boot d \
-cdrom {{ ARGS }}

View file

@ -1,2 +1,23 @@
# titanoboa
Eats anacondas
# Titanoboa (Alpha)
A [bootc](https://github.com/bootc-dev/bootc) installer that eats anacondas.
This is an experiment to see how far we can get building our own ISOs
The objective is to:
- Make our own ISO from scratch
- Have it booting a live bootc ISO
- Install any image off of that
## Building a Live ISO
```bash
just build ghcr.io/ublue-os/bluefin:lts
just vm ./output.iso
```
## TODO
- [ ] Include flatpaks in the rootfs
- [ ] Include `/var/lib/containers` in the rootfs
- [ ] Have an installer for the Live ISO
- [ ] Different names for each image

21
src/grub.cfg Normal file
View file

@ -0,0 +1,21 @@
set default="1"
function load_video {
insmod all_video
}
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
# insmod ext2
# insmod chain
set timeout=60
search --no-floppy --set=root -l 'bluefin_boot'
menuentry 'Install Bluefin LTS' --class fedora --class gnu-linux --class gnu --class os {
linux ($root)/boot/vmlinuz quiet rhgb root=live:CDLABEL=bluefin_boot enforcing=0 rd.live.image
initrd ($root)/boot/initramfs.img
}

3
src/xorriso_wrapper.sh Normal file
View file

@ -0,0 +1,3 @@
#!/usr/bin/env bash
xorriso $@ -iso-level 4 -V "bluefin_boot"