Skip to content

Commit 03babd9

Browse files
aafeijoo-suseLaszloGombos
authored andcommitted
feat(systemd-portabled): introducing the systemd-portabled module
Introducing the systemd-portabled module. It's intended to work only with raw binary disk images contained in regular files, but not with directory trees.
1 parent 429f9de commit 03babd9

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
# This file is part of dracut.
3+
# SPDX-License-Identifier: GPL-2.0-or-later
4+
5+
# Prerequisite check(s) for module.
6+
check() {
7+
8+
# If the binary(s) requirements are not fulfilled the module can't be installed.
9+
require_binaries \
10+
portablectl \
11+
"$systemdutildir"/systemd-portabled \
12+
|| return 1
13+
14+
# Return 255 to only include the module, if another module requires it.
15+
return 255
16+
17+
}
18+
19+
# Module dependency requirements.
20+
depends() {
21+
22+
# This module has external dependency on other module(s).
23+
echo dbus
24+
# Return 0 to include the dependent module(s) in the initramfs.
25+
return 0
26+
27+
}
28+
29+
# Install kernel module(s).
30+
installkernel() {
31+
instmods loop squashfs
32+
}
33+
34+
# Install the required file(s) and directories for the module in the initramfs.
35+
install() {
36+
37+
# It's intended to work only with raw binary disk images contained in
38+
# regular files, but not with directory trees.
39+
local _nonraw
40+
_nonraw=$(portablectl --no-pager --no-legend list | grep -v " raw " | cut -d ' ' -f1 | tr '\n' ' ')
41+
if [ -n "$_nonraw" ]; then
42+
dwarn "systemd-portabled: this module only installs raw disk images in the initramfs; skipping: $_nonraw"
43+
fi
44+
45+
inst_multiple -o \
46+
"/var/lib/portables/*.raw" \
47+
"/usr/lib/portables/*.raw" \
48+
"$tmpfilesdir/portables.conf" \
49+
"$dbussystem"/org.freedesktop.portable1.conf \
50+
"$dbussystemservices"/org.freedesktop.portable1.service \
51+
"$systemdutildir"/systemd-portabled \
52+
"$systemdutildir/portable/profile/default/*.conf" \
53+
"$systemdutildir/portable/profile/nonetwork/*.conf" \
54+
"$systemdutildir/portable/profile/strict/*.conf" \
55+
"$systemdutildir/portable/profile/trusted/*.conf" \
56+
"$systemdsystemunitdir"/systemd-portabled.service \
57+
"$systemdsystemunitdir/systemd-portabled.service.d/*.conf" \
58+
"$systemdsystemunitdir"/dbus-org.freedesktop.portable1.service \
59+
portablectl
60+
61+
# The existence of this file is required
62+
touch "$initdir"/etc/resolv.conf
63+
64+
# Enable systemd type unit(s)
65+
$SYSTEMCTL -q --root "$initdir" add-wants initrd.target systemd-portabled.service
66+
$SYSTEMCTL -q --root "$initdir" enable systemd-portabled.service
67+
68+
# Install the hosts local user configurations if enabled.
69+
if [[ $hostonly ]]; then
70+
inst_multiple -H -o \
71+
"/etc/portables/*.raw" \
72+
"$systemdutilconfdir/system.attached/*" \
73+
"$systemdutilconfdir/system.attached/*/*" \
74+
"$systemdutilconfdir/portable/profile/default/*.conf" \
75+
"$systemdutilconfdir/portable/profile/nonetwork/*.conf" \
76+
"$systemdutilconfdir/portable/profile/strict/*.conf" \
77+
"$systemdutilconfdir/portable/profile/trusted/*.conf" \
78+
"$systemdsystemconfdir"/systemd-portabled.service \
79+
"$systemdsystemconfdir/systemd-portabled.service.d/*.conf"
80+
fi
81+
82+
}

modules.d/01systemd-tmpfiles/module-setup.sh

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ depends() {
2525
install() {
2626

2727
# Excluding "$tmpfilesdir/home.conf", sets up /home /srv
28-
# Excluding "$tmpfilesdir/portables.conf", belongs in seperated portables module
2928
# Excluding "$tmpfilesdir/journal-nocow.conf", requires spesific btrfs setup
3029
# Excluding "$tmpfilesdir/legacy.conf", belongs in seperated legacy module
3130
# Excluding "$tmpfilesdir/systemd-nologin.conf", belongs in seperated pam module

pkgbuild/dracut.spec

+1
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
330330
%{dracutlibdir}/modules.d/01systemd-journald
331331
%{dracutlibdir}/modules.d/01systemd-ldconfig
332332
%{dracutlibdir}/modules.d/01systemd-modules-load
333+
%{dracutlibdir}/modules.d/01systemd-portabled
333334
%{dracutlibdir}/modules.d/01systemd-pstore
334335
%{dracutlibdir}/modules.d/01systemd-repart
335336
%{dracutlibdir}/modules.d/01systemd-resolved

0 commit comments

Comments
 (0)