summaryrefslogtreecommitdiffstats
path: root/mkosi.functions
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2024-07-10 10:07:05 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2024-07-10 10:55:33 +0200
commit612a98a0652387d857198cb92dea03ddf1bbbe43 (patch)
tree9636a10ebfad15c72560e5733797863ce185e2a6 /mkosi.functions
parentmkosi: Install erofs-utils (diff)
downloadsystemd-612a98a0652387d857198cb92dea03ddf1bbbe43.tar.xz
systemd-612a98a0652387d857198cb92dea03ddf1bbbe43.zip
mkosi: Build a sysext if SYSEXT=1 is specified
Diffstat (limited to 'mkosi.functions')
-rw-r--r--mkosi.functions49
1 files changed, 49 insertions, 0 deletions
diff --git a/mkosi.functions b/mkosi.functions
new file mode 100644
index 0000000000..c19c1aa643
--- /dev/null
+++ b/mkosi.functions
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+make_sysext_unsigned() {
+ if ! ((SYSEXT)); then
+ return
+ fi
+
+ mkdir -p /usr/lib/systemd/repart/definitions/sysext-unsigned.repart.d
+ cat >/usr/lib/systemd/repart/definitions/sysext-unsigned.repart.d/10-root.conf <<EOF
+[Partition]
+Type=root
+Format=erofs
+CopyFiles=/usr/
+Minimize=best
+EOF
+
+ . /usr/lib/os-release
+
+ mkdir -p "$1"/usr/lib/extension-release.d
+ cat >"$1"/usr/lib/extension-release.d/extension-release.systemd <<EOF
+ID=$ID
+SYSEXT_ID=systemd
+SYSEXT_SCOPE=system
+ARCHITECTURE=$ARCHITECTURE
+EOF
+
+ if [[ -n "$VERSION_ID" ]]; then
+ cat >>"$1"/usr/lib/extension-release.d/extension-release.systemd <<EOF
+VERSION_ID=$VERSION_ID
+EOF
+ fi
+
+ if [[ -n "$SYSEXT_LEVEL" ]]; then
+ cat >>"$1"/usr/lib/extension-release.d/extension-release.systemd <<EOF
+SYSEXT_LEVEL=$SYSEXT_LEVEL
+EOF
+ fi
+
+ rm -f "$BUILDDIR"/systemd.raw
+
+ env --unset=SYSTEMD_REPART_OVERRIDE_FSTYPE_ROOT \
+ "$BUILDDIR"/systemd-repart \
+ --make-ddi=sysext-unsigned \
+ --copy-source="$1" \
+ --pretty=no \
+ "$BUILDDIR"/systemd.raw
+
+ cp "$BUILDDIR"/systemd.raw "$OUTPUTDIR"
+}