Skip to content

Commit 90065d0

Browse files
committed
Generalize build process for iso/img and gpt/mbr
1 parent b378b79 commit 90065d0

7 files changed

Lines changed: 307 additions & 205 deletions

File tree

.env

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
export VERSION=2.0.0
2-
export MISO_DISTRO_NAME=weeedebian
1+
# Image
2+
#
3+
export MISO_DISTRO_NAME=golden_image
4+
# amd64 or i386
35
export MISO_ARCH=amd64
4-
export MISO_HOSTNAME=weeedebian
6+
# img or iso
7+
export MISO_OUTPUT_EXT=img
8+
# mbr or gpt, ignored if MISO_OUTPUT_EXT=iso
9+
export MISO_PART_TABLE=gpt
10+
11+
# Distro
12+
#
13+
export MISO_HOSTNAME=weee
514
export MISO_ROOTPASSWD=asd
615
export MISO_USERNAME=weee
716
export MISO_USERPASSWD=asd
17+
18+
# Miso
19+
#
20+
export MISO_BUILD_DIR=build
21+
export MISO_CHROOT_SCRIPTS_DIR="chroot_scripts"
22+
export VERSION=2.1.0

.github/workflows/build_iso.yml

Lines changed: 33 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,41 @@
11
on: push
2-
name: build iso
2+
name: build output file
33
defaults:
44
run:
55
shell: bash
66
working-directory: .
77
jobs:
8-
build_iso:
9-
name: Build weeedebian ISO
8+
build_output:
9+
name: Build
1010
runs-on: ubuntu-22.04
1111
steps:
12-
- uses: actions/checkout@v4
13-
- name: Install dependencies
14-
run: sudo apt-get update && sudo apt-get install -y mmdebstrap squashfs-tools dosfstools xorriso isolinux syslinux-efi grub-pc-bin grub-efi-amd64-bin mtools debian-archive-keyring isolinux syslinux
15-
- name: Set T.A.R.A.L.L.O. Token
16-
uses: "DamianReeves/write-file-action@master"
17-
with:
18-
path: ./.env
19-
write-mode: append
20-
contents: |
21-
export TARALLO_URL="${{ secrets.TARALLO_URL }}"
22-
export TARALLO_TOKEN="${{ secrets.TARALLO_TOKEN }}"
23-
export PERACOTTA_REPORT_URL="${{ secrets.PERACOTTA_REPORT_URL }}"
24-
export PERACOTTA_AUTOMATIC_REPORT_ERRORS="true"
25-
- name: Dotenv Action
26-
uses: falti/dotenv-action@v1.1
27-
id: dotenv
28-
with:
29-
export-variables: true
30-
- name: build amd64
31-
env:
32-
MISO_ARCH: amd64
33-
run: sudo ./miso.sh
34-
shell: bash
35-
# i386 CI is disabled because I couldn't get QT (either 5 or 6)to work on a modern 32bit release of debian
36-
#- name: build i386
37-
# env:
38-
# MISO_ARCH: i386
39-
# run: ./miso.sh
40-
# shell: bash
41-
- uses: ncipollo/release-action@v1
42-
with:
43-
artifacts: "./build/*/*.iso"
44-
allowUpdates: true
45-
prerelease: true
46-
draft: true
47-
tag: v${{ steps.dotenv.outputs.version }}
48-
body: |
49-
> [!CAUTION]
50-
> Do NOT publish this draft.
51-
> It is only to be used internally as the T.A.R.A.L.L.O. secret token is visible in the built iso.
12+
- uses: actions/checkout@v4
13+
- name: Install dependencies
14+
run: sudo apt-get update && sudo apt-get install -y mmdebstrap squashfs-tools dosfstools xorriso isolinux parted udev syslinux-efi grub-pc-bin grub-efi-amd64-bin mtools debian-archive-keyring isolinux syslinux
15+
- name: Dotenv Action
16+
uses: falti/dotenv-action@v1.1
17+
id: dotenv
18+
with:
19+
export-variables: true
20+
- name: build amd64
21+
env:
22+
MISO_ARCH: amd64
23+
run: sudo ./miso.sh
24+
shell: bash
25+
# i386 CI is disabled because I couldn't get QT (either 5 or 6)to work on a modern 32bit release of debian
26+
#- name: build i386
27+
# env:
28+
# MISO_ARCH: i386
29+
# run: ./miso.sh
30+
# shell: bash
31+
- uses: ncipollo/release-action@v1
32+
with:
33+
artifacts: "./build/*/*.iso"
34+
allowUpdates: true
35+
prerelease: true
36+
draft: true
37+
tag: v${{ steps.dotenv.outputs.version }}
38+
# body: |
39+
# > [!CAUTION]
40+
# > Do NOT publish this draft.
41+
# > It is only to be used internally as the T.A.R.A.L.L.O. secret token is visible in the built iso.

Dockerfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ RUN apt-get update -y \
99
dosfstools \
1010
xorriso \
1111
isolinux \
12-
syslinux-efi \
12+
parted \
13+
syslinux-efi \
1314
syslinux \
15+
grub-efi-amd64 \
1416
grub-efi-amd64-bin \
15-
grub-pc-bin \
17+
binutils \
1618
mtools \
1719
debian-archive-keyring \
18-
fakeroot \
20+
udev \
21+
libguestfs-tools \
22+
libguestfs-dev \
23+
supermin \
24+
fakeroot \
1925
fakechroot \
2026
&& apt-get clean -y
2127
WORKDIR /miso

Makefile

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# variables
2+
-include .env
3+
export
4+
5+
# detection logic
6+
DOCKER_CMD := $(shell command -v podman 2> /dev/null || command -v docker 2> /dev/null)
7+
IS_DEBIAN := $(shell [ -f /etc/debian_version ] && echo "yes")
8+
9+
# build pathing
10+
# ensure these evaluate to the same string used by your scripts
11+
BUILD_DIR = $(MISO_BUILD_DIR)/$(MISO_DISTRO_NAME)-$(MISO_ARCH)-$(MISO_PART_TABLE)
12+
IMG_PATH = $(BUILD_DIR).$(MISO_OUTPUT_EXT)
13+
14+
OVMF_PATH ?= /usr/share/OVMF/OVMF_CODE.fd
15+
16+
.PHONY: build build-container build-debian test prune clean cleanall
17+
18+
# THE ONLY BUILD TARGET
19+
build:
20+
sudo rm -rf $(BUILD_DIR)/chroot
21+
ifneq ($(DOCKER_CMD),)
22+
@echo "--- [$(notdir $(DOCKER_CMD))] detected: building via container ---"
23+
$(MAKE) build-container
24+
else ifeq ($(IS_DEBIAN),yes)
25+
@echo "--- no container engine: falling back to local debian build ---"
26+
$(MAKE) build-debian
27+
else
28+
$(error ERROR: no podman/docker found and not on debian. cannot build.)
29+
endif
30+
31+
# sentinel for host deps
32+
.deps_installed: install_dep.sh
33+
@echo "--- checking/installing host dependencies ---"
34+
sudo ./install_dep.sh
35+
@touch .deps_installed
36+
37+
# collect sources for dependency tracking
38+
MISO_SRCS := miso.sh $(shell find chroot_scripts -type f 2>/dev/null) .env
39+
40+
# actual file target
41+
$(IMG_PATH): .deps_installed $(MISO_SRCS)
42+
@echo "--- cleaning previous build artifacts ---"
43+
# sudo rm -f $(IMG_PATH)
44+
@mkdir -p $(MISO_BUILD_DIR)
45+
@echo "--- host deps ok, starting miso.sh ---"
46+
./miso.sh
47+
48+
build-debian: $(IMG_PATH)
49+
50+
build-container:
51+
@echo "--- clearing chroot ---"
52+
sudo rm -rf $(MISO_BUILD_DIR)/chroot
53+
@mkdir -p $(MISO_BUILD_DIR)
54+
$(DOCKER_CMD) run -it --rm \
55+
--name miso \
56+
--hostname weee \
57+
--privileged \
58+
--device /dev/kvm:/dev/kvm \
59+
--device /dev/fuse:/dev/fuse \
60+
-v ./build:/miso/build:rw,Z \
61+
-v ./chroot_scripts:/miso/chroot_scripts:ro,Z \
62+
-e LIBGUESTFS_BACKEND=direct \
63+
$$($(DOCKER_CMD) build -q .)
64+
65+
test:
66+
@if [ ! -f $(IMG_PATH) ]; then \
67+
echo "ERROR: $(IMG_PATH) missing. run 'make build'."; \
68+
exit 1; \
69+
fi
70+
@case "$(MISO_PART_TABLE)" in \
71+
gpt) ARGS="-drive if=pflash,format=raw,readonly=on,file=$(OVMF_PATH)" ;; \
72+
*) ARGS="" ;; \
73+
esac; \
74+
case "$(MISO_OUTPUT_EXT)" in \
75+
iso) DISK="-cdrom $(IMG_PATH)" ;; \
76+
*) DISK="-drive file=$(IMG_PATH),format=raw" ;; \
77+
esac; \
78+
qemu-system-x86_64 -accel kvm -m 2G $$ARGS $$DISK
79+
80+
prune:
81+
ifneq ($(DOCKER_CMD),)
82+
@echo "--- pruning $(notdir $(DOCKER_CMD)) images and build cache ---"
83+
$(DOCKER_CMD) image prune -f
84+
$(DOCKER_CMD) builder prune -f
85+
$(DOCKER_CMD) container rm miso
86+
endif
87+
88+
clean:
89+
@echo "--- removing intermediate build files ---"
90+
@if [ -d "$(MISO_BUILD_DIR)" ]; then \
91+
sudo find $(MISO_BUILD_DIR) -mindepth 1 -maxdepth 1 \
92+
! -name "*.img" ! -name "*.iso" -exec rm -rf {} +; \
93+
fi
94+
rm -f .deps_installed
95+
96+
cleanall: prune
97+
sudo rm -rf $(MISO_BUILD_DIR)
98+
rm -f .deps_installed

docker-compose.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

install_dep.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ sudo apt install \
1010
grub-efi-amd64-bin \
1111
mtools \
1212
debian-archive-keyring \
13+
libguestfstools \

0 commit comments

Comments
 (0)