-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
91 lines (77 loc) · 2.69 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
MNT = mnt
DEST = dest
ASSETS = assets
BASE_IMG = RockyRpi_9.2.img
BASE_IMG_URL = https://dl.rockylinux.org/pub/sig/9/altarch/aarch64/images/$(BASE_IMG).xz
SRCS = $(wildcard src/*)
RPI_BUILDER_VERSION ?= $(shell git describe --abbrev=0 2>/dev/null || true)
RPI_BUILDER_SHA ?= $(shell git rev-parse --short HEAD)
default: $(DEST)/rpi-rocky9-rootfs-$(RPI_BUILDER_VERSION).sq $(DEST)/rpi-rocky9-boot-$(RPI_BUILDER_VERSION).tar.gz
sudo chown -R oruud:wheel $(DEST)
.PHONY: default
# The boot configuration that should be available across TFTP
$(DEST)/rpi-rocky9-boot-%.tar.gz: .$(MNT).chroot-final
tar -czf $@ --directory="$(MNT)/boot" .
# The squashed root filesystem that should be available across HTTP
$(DEST)/rpi-rocky9-rootfs-%.sq: .$(MNT).chroot-final
# NB! File permissions should not be modified by mksquashfs,
# or else it breaks when booting.
# NB! SELinux is disabled for now, see
# (https://superuser.com/questions/1570463/how-can-an-selinux-filesystem-be-relabeled-in-an-unpacked-squashfs-filesystem)
sudo mksquashfs $(MNT) $@ \
-noappend \
-progress \
-e proc sys dev etc/resolv.conf usr/bin/qemu-aarch64-static
# Divided into multiple buildsteps to provide some caching when developing
# to prevent having to rebuild from start on every change.
.$(MNT).setup: $(DEST)/$(BASE_IMG)
sudo \
--preserve-env=RPI_SIZE \
--preserve-env=RPI_IMAGE_NAME \
./setup-image.sh $< $(MNT) $(DEST)
touch $@
.$(MNT).chroot-base: .$(MNT).setup chroot-base.sh
RPI_BUILDER_VERSION=$(RPI_BUILDER_VERSION) \
RPI_BUILDER_SHA=$(RPI_BUILDER_SHA) \
sudo \
--preserve-env=RPI_BUILDER_VERSION \
--preserve-env=RPI_BUILDER_SHA \
--preserve-env=RPI_HTML_TEMPLATE_NAME \
--preserve-env=RPI_USER_PASSWORD \
./configure-image.sh $(MNT) chroot-base.sh
touch $@
.$(MNT).chroot-final: .$(MNT).chroot-base chroot-final.sh $(SRCS)
RPI_BUILDER_VERSION=$(RPI_BUILDER_VERSION) \
RPI_BUILDER_SHA=$(RPI_BUILDER_SHA) \
sudo \
--preserve-env=RPI_BUILDER_VERSION \
--preserve-env=RPI_BUILDER_SHA \
--preserve-env=RPI_HTML_TEMPLATE_NAME \
--preserve-env=RPI_USER_PASSWORD \
./configure-image.sh $(MNT) chroot-final.sh
touch $@
$(DEST)/$(BASE_IMG): $(ASSETS)/$(BASE_IMG).xz
@mkdir -p $(@D)
xz --decompress --stdout $< > $@
$(ASSETS)/$(BASE_IMG).xz:
@mkdir -p $(@D)
curl \
--retry 5 \
--retry-max-time 120 \
--skip-existing \
--output $@ \
$(BASE_IMG_URL)
curl \
--retry 5 \
--retry-max-time 120 \
--output $@ \
$(BASE_IMG_URL).sha256sum
@cd $(ASSETS); sha256sum --check $(BASE_IMG).xz.sha256sum
clean:
-sudo umount -R mnt
-sudo losetup -D $(DEST)/rpi-full.img
-sudo losetup -D $(ASSETS)/$(BASE_IMG)
-rm -f $(DEST)/rpi-full.img .$(MNT).*
-rmdir mnt
#-rm -rf --one-file-system $(DEST)
.PHONY: clean