Skip to content

Commit e70ca32

Browse files
Yury-MonZonalchark
authored andcommitted
debian-rk3576-img.yaml: per-root cmdline + token build fan-out
Drop rootflags=subvol= and console=ttyS0 from the cmdline (the generator adds them per entry). Bake @minimal's token before the kernel install, then fan the kernel(s) out to every profile (reflinked /boot/<token>/ + one entry each) via flipper-bls.sh; each profile's band number derives from flipper-profiles.
1 parent bd6acf9 commit e70ca32

1 file changed

Lines changed: 78 additions & 13 deletions

File tree

debian-rk3576-img.yaml

Lines changed: 78 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{{ $sectorsize := or .sectorsize 512 }}
22
{{ $imagesize := or .imagesize "4GiB" }}
33
{{ $kerneldir := or .kerneldir "prebuilt/linux" }}
4-
{{ $cmdline := or .cmdline "audit=0 console=tty1 console=ttyS0,1500000n8" }}
4+
# cmdline: shared facts + policy only. The BLS generator adds the per-entry rootflags=subvol=
5+
# and the serial consoles (console=ttyS0/ttyS4/fbcon or ttyFIQ0, per kernel config).
6+
{{ $cmdline := or .cmdline "audit=0 console=tty1" }}
57
{{ $fslabel := or .fslabel "flipperos" }}
6-
{{- /* fs-wide btrfs mount options. ssd is FORCED (loopback/eMMC isn't reliably
7-
detected as non-rotational). */ -}}
8+
# btrfsopts: fs-wide mount options. ssd is FORCED (loopback/eMMC isn't reliably
9+
# detected as non-rotational).
810
{{ $btrfsopts := or .btrfsopts "compress=zstd,noatime,ssd,discard=async" }}
911
{{ $rootdev := "findmnt -fn --nofsroot -o SOURCE --target $IMAGEMNTDIR" }}
1012

@@ -72,17 +74,17 @@ actions:
7274
mount -t btrfs -o "{{ $btrfsopts }},subvol=@var-log" "$ROOTPART" "$IMAGEMNTDIR/var/log"
7375
mount -t btrfs -o "{{ $btrfsopts }},subvol=@var-cache" "$ROOTPART" "$IMAGEMNTDIR/var/cache"
7476
75-
# debos writes the standard root line into /etc/fstab and root=UUID into the cmdline;
76-
# the root subvolume is selected by the appended rootflags. @Desktop is the default root
77-
# (the desktop); the other profiles' BLS entries append rootflags=subvol=@<profile>
78-
# and the last rootflags= on the line wins. (Deploy still happens into @Minimal.)
77+
# debos writes the standard root line into /etc/fstab and root=UUID into the cmdline.
78+
# The root subvolume is NOT baked here: /etc/kernel/cmdline carries only shared facts +
79+
# policy (root=UUID, audit, console=tty1). The BLS generator supplies rootflags=subvol=
80+
# per entry (from flipper-profiles at build, from findmnt at runtime). Deploy into @Minimal.
7981
- action: filesystem-deploy
80-
append-kernel-cmdline: rootflags=subvol=@Desktop {{ $cmdline }}
82+
append-kernel-cmdline: {{ $cmdline }}
8183

8284
# Add fstab entries for the non-root subvolumes (debos only generated the root
8385
# line). The FSUUID is read back at build time. These (/boot, /home, /var/log,
84-
# /var/cache) are shared by every profile root. @snapshots is intentionally omitted
85-
# -- it holds runtime snapshots, managed on demand, never auto-mounted.
86+
# /var/cache) are shared by every profile root. @snapshots is intentionally omitted:
87+
# it holds runtime snapshots, managed on demand, never auto-mounted.
8688
- action: run
8789
description: Append subvolume entries to /etc/fstab
8890
chroot: false
@@ -114,11 +116,51 @@ actions:
114116
origin: artifacts
115117
destination: /var/cache/linux-kernel
116118

119+
# Bake @Minimal's entry-token before the kernel install, so the kernel-install plugin stages the
120+
# kernel into /boot/<token>/ instead of the 'debian' fallback. @Minimal is the build root, so its
121+
# token is the one the plugin reads. NN is derived from @Minimal's position in flipper-profiles.
122+
- action: run
123+
description: Pin @Minimal's kernel entry-token before the kernel install
124+
chroot: true
125+
command: |
126+
set -eu
127+
. /usr/lib/flipper-bls.sh
128+
mkdir -p /etc/kernel
129+
make_token "$(profile_base_nn @Minimal)" @Minimal > /etc/kernel/entry-token
130+
117131
- action: run
118132
description: Install Linux kernel packages inside the target
119133
chroot: true
120134
command: find /var/cache/linux-kernel -name linux-image-\*.deb -a ! -name \*-dbg_\* -print0 | xargs -0 apt install -y
121135

136+
# The kernel-install plugin only wrote @Minimal's entry (the build root). Fan the installed
137+
# kernel(s) out to every profile: one entry + a reflinked /boot/<token>/ per profile per version
138+
# (token = <NN>-flipperos-<subvol>, NN from the flipper-profiles order). The shared logic lives in
139+
# /usr/lib/flipper-bls.sh; this build step is the only fan-out (the plugin handles one root).
140+
- action: run
141+
description: Generate the per-profile BLS entries for the installed kernel(s)
142+
chroot: true
143+
command: |
144+
set -eu
145+
. /usr/lib/flipper-bls.sh
146+
CONF_ROOT=/etc/kernel; PROFILES=/etc/kernel/flipper-profiles; ENTRIES=/boot/loader/entries
147+
MACHINE_ID=""; DEVICETREE=""; DEVICETREE_ENTRY=""; BOOT_MNT="/"
148+
mkdir -p "$ENTRIES"; SORT_KEY="$(os_sort_key)"
149+
for _k in /boot/vmlinuz-*; do
150+
[ -e "$_k" ] || continue
151+
KERNEL_VERSION="${_k#/boot/vmlinuz-}"; KCONFIG="/boot/config-$KERNEL_VERSION"
152+
set_dtb_dirs; discover_devicetreedir; compute_base_opts
153+
_i=0
154+
while IFS='|' read -r tok suf extra gate dtbos legend; do
155+
tok="$(echo "$tok" | tr -d '[:space:]')"; case "$tok" in ''|\#*) continue ;; esac
156+
extra="$(trim "$extra")"; _sv="$(subvol_of "$extra")"
157+
ENTRY_TOKEN="$(make_token "$(printf '%03d' "$((900 - _i * 100))")" "$_sv")"
158+
remove_entries "$_sv" "$KERNEL_VERSION"; stage_kernel_reflink
159+
emit_entry "$(trim "$suf")" "$extra" "$(trim "$gate")" "$(trim "$dtbos")"
160+
_i=$((_i + 1))
161+
done <"$PROFILES"
162+
done
163+
122164
# Default session for every profile: the no-DE multi-user target, where the cog-seat1
123165
# kiosk runs (and @TV's kodi, enabled under multi-user). Only @Desktop overrides this to
124166
# graphical.target (for sddm); @Minimal/@Router/@TV all stay on multi-user.
@@ -139,7 +181,7 @@ actions:
139181
# @home and @var-* are separate top-level subvols shared by all profiles.
140182
#
141183
# KDE and TV-Media-Box install their packages (apt) + config (overlay); only @Desktop changes
142-
# its default target (to graphical, for sddm) -- TV/Router/Minimal stay on multi-user.
184+
# its default target (to graphical, for sddm); TV/Router/Minimal stay on multi-user.
143185
# Router applies only its config overlay (NM AP/WAN + ip-forwarding); no packages needed.
144186
# ===========================================================================
145187

@@ -148,6 +190,8 @@ actions:
148190
chroot: false
149191
command: |
150192
set -eu
193+
# @Minimal's entry-token was baked before the kernel install, so @Minimal_stock (snapshotted
194+
# here) and the re-created @Minimal both inherit it; no need to rewrite it.
151195
sync
152196
ROOTPART="$({{ $rootdev }})" # @Minimal is still mounted at $IMAGEMNTDIR
153197
# Mount the btrfs top level at a fixed path and KEEP it mounted for the whole profile
@@ -163,8 +207,8 @@ actions:
163207
| awk '{ print length, $0 }' | sort -rn | cut -d" " -f2- \
164208
| while read -r mp; do umount "$mp"; done
165209
# Re-create @Minimal as a writable child of the golden base (parent = @Minimal_stock)
166-
# so it matches the other profiles -- which are snapshots of their _stock -- instead
167-
# of being the build origin with no parent.
210+
# so it matches the other profiles (each a snapshot of its _stock) instead of being
211+
# the build origin with no parent.
168212
btrfs subvolume delete "$TOP/@Minimal"
169213
btrfs subvolume snapshot "$TOP/@Minimal_stock" "$TOP/@Minimal"
170214
@@ -207,6 +251,13 @@ actions:
207251
description: Make the KDE desktop the default session on @Desktop
208252
chroot: true
209253
command: systemctl set-default graphical.target
254+
- action: run
255+
description: Pin @Desktop's kernel entry-token (NN from flipper-profiles)
256+
chroot: true
257+
command: |
258+
set -eu
259+
. /usr/lib/flipper-bls.sh
260+
make_token "$(profile_base_nn @Desktop)" @Desktop > /etc/kernel/entry-token
210261
- action: run
211262
description: Lock @Desktop_stock RO and spawn writable @Desktop
212263
chroot: false
@@ -238,6 +289,13 @@ actions:
238289
description: TV media box profile config (kodi, enabled under multi-user)
239290
source: overlays/profile-tv-media-box
240291
destination: /
292+
- action: run
293+
description: Pin @TV-Media-Box's kernel entry-token (NN from flipper-profiles)
294+
chroot: true
295+
command: |
296+
set -eu
297+
. /usr/lib/flipper-bls.sh
298+
make_token "$(profile_base_nn @TV-Media-Box)" @TV-Media-Box > /etc/kernel/entry-token
241299
- action: run
242300
description: Lock @TV-Media-Box_stock RO and spawn writable @TV-Media-Box
243301
chroot: false
@@ -269,6 +327,13 @@ actions:
269327
description: Fix NetworkManager connection permissions on @Router
270328
chroot: true
271329
command: chmod 600 /etc/NetworkManager/system-connections/*.nmconnection
330+
- action: run
331+
description: Pin @Router's kernel entry-token (NN from flipper-profiles)
332+
chroot: true
333+
command: |
334+
set -eu
335+
. /usr/lib/flipper-bls.sh
336+
make_token "$(profile_base_nn @Router)" @Router > /etc/kernel/entry-token
272337
- action: run
273338
description: Lock @Router_stock RO and spawn writable @Router
274339
chroot: false

0 commit comments

Comments
 (0)