-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.images
121 lines (107 loc) · 4.83 KB
/
Makefile.images
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
.PHONY: clean
clean:
ifneq ($(wildcard $(WORK_DIR)/$(ARCH)),)
$(WORK_DIR)/$(ARCH)/destroy --remove
endif
rm -rf $(WORK_DIR)
k0s-worker: build-user
HL_OVERLAY_DIR=$(abspath $(WORK_DIR))/shared/overlays \
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
$(abspath $(WORK_DIR))/shared/aports/scripts/mkimage.sh \
--arch $(ARCH) \
--profile k0s_worker \
--outdir $(abspath $(WORK_DIR))/shared \
--repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/main \
--extra-repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/community
$(WORK_DIR)/$(ARCH)/destroy --remove
rpi-basic: build-user # chroot-initramfs-hack
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
$(abspath $(WORK_DIR))/shared/aports/scripts/mkimage.sh \
--arch $(ARCH) \
--profile rpi_basic \
--outdir $(abspath $(WORK_DIR))/shared \
--repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/main \
--extra-repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/community
$(WORK_DIR)/$(ARCH)/destroy --remove
rpi-firewall: build-user # chroot-initramfs-hack
HL_OVERLAY_DIR=$(abspath $(WORK_DIR))/shared/overlays \
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
$(abspath $(WORK_DIR))/shared/aports/scripts/mkimage.sh \
--arch $(ARCH) \
--profile rpi_firewall \
--outdir $(abspath $(WORK_DIR))/shared \
--repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/main \
--extra-repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/community
$(WORK_DIR)/$(ARCH)/destroy --remove
rpi-k0s-controller: build-user
HL_OVERLAY_DIR=$(abspath $(WORK_DIR))/shared/overlays \
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
$(abspath $(WORK_DIR))/shared/aports/scripts/mkimage.sh \
--arch $(ARCH) \
--profile rpi_k0s_controller \
--outdir $(abspath $(WORK_DIR))/shared \
--repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/main \
--extra-repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/community
$(WORK_DIR)/$(ARCH)/destroy --remove
rpi-ruuvi: build-user # chroot-initramfs-hack
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
$(abspath $(WORK_DIR))/shared/aports/scripts/mkimage.sh \
--arch $(ARCH) \
--profile rpi_ruuvi \
--outdir $(abspath $(WORK_DIR))/shared \
--repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/main \
--extra-repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/community
$(WORK_DIR)/$(ARCH)/destroy --remove
rpi-snapcast-client: build-user # chroot-initramfs-hack
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
$(abspath $(WORK_DIR))/shared/aports/scripts/mkimage.sh \
--arch $(ARCH) \
--profile rpi_snapcast_client \
--outdir $(abspath $(WORK_DIR))/shared \
--repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/main \
--extra-repository https://dl-cdn.alpinelinux.org/alpine/v$(ALPINE_VERSION)/community
$(WORK_DIR)/$(ARCH)/destroy --remove
chroot: clone-aci populate-shared
sudo SUDO_USER=$(BUILD_USER) \
$(WORK_DIR)/aci/alpine-chroot-install \
-a $(ARCH) \
-d $(abspath $(WORK_DIR))/$(ARCH) \
-i $(abspath $(WORK_DIR))/shared \
-k "ARCH CI QEMU_EMULATOR HL_.*" \
-p "abuild apk-tools alpine-conf busybox curl fakeroot sudo squashfs-tools mkinitfs grub-efi mtools xorriso"
build-user: chroot
# add non-root user to build images
$(WORK_DIR)/$(ARCH)/enter-chroot adduser $(BUILD_USER) abuild
$(WORK_DIR)/$(ARCH)/enter-chroot adduser $(BUILD_USER) wheel # for sudo
ifeq ($(wildcard $(WORK_DIR)/shared/keys/*rsa),)
rm -rf $(WORK_DIR)/shared/keys
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
abuild-keygen -a -i -n
$(WORK_DIR)/$(ARCH)/enter-chroot \
chgrp abuild $(abspath $(WORK_DIR))/shared
$(WORK_DIR)/$(ARCH)/enter-chroot \
chmod g+rwx $(abspath $(WORK_DIR))/shared
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
cp -ar /home/$(BUILD_USER)/.abuild $(abspath $(WORK_DIR))/shared/keys
else
$(WORK_DIR)/$(ARCH)/enter-chroot -u $(BUILD_USER) \
cp -ar $(abspath $(WORK_DIR))/shared/keys /home/$(BUILD_USER)/.abuild
endif
populate-shared: clone-aports
cp -pu scripts/* $(WORK_DIR)/shared/aports/scripts
clone-aci:
ifeq ($(wildcard $(WORK_DIR)/aci/.git),)
git -c advice.detachedHead=false clone -b $(ACI_TAG) $(ACI_REPO) $(WORK_DIR)/aci
endif
clone-aports:
ifeq ($(wildcard $(WORK_DIR)/shared/aports/.git),)
git clone --shallow-since=2022-07-01 $(APORTS_REPO) $(WORK_DIR)/shared/aports
endif
# Insert `--allow-untrusted` into the init script used to boostrap the live system
# from the initramfs. Useful for debugging errors...like why `/etc/inittab` is missing.
# (See previous commits.)
chroot-initramfs-hack:
$(WORK_DIR)/$(ARCH)/enter-chroot \
sed -i 's/^apkflags="\(.*\)"/apkflages="--allow-untrusted \1"/' /usr/share/mkinitfs/initramfs-init
$(WORK_DIR)/$(ARCH)/enter-chroot \
grep '^apk' /usr/share/mkinitfs/initramfs-init