Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional systemd-nspawn support #8823

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions distributions/LibreELEC/options
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@
DEBUG_GROUPS="kodi+=kodi+,kodi-platform+,p8-platform+,!mesa"
DEBUG_GROUP_YES="kodi+"

# include systemd-nspawn support (yes / no)
NSPAWN_SUPPORT="no"

# build and install iSCSI support - iscsistart (yes / no)
ISCSI_SUPPORT="no"

Expand Down
23 changes: 20 additions & 3 deletions packages/sysutils/systemd/package.mk
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ PKG_MESON_OPTS_TARGET="--libdir=/usr/lib \
-Dlogind=true \
-Dhostnamed=true \
-Dlocaled=false \
-Dmachined=false \
-Dportabled=false \
-Duserdb=false \
-Dhomed=disabled \
Expand Down Expand Up @@ -108,6 +107,12 @@ else
PKG_MESON_OPTS_TARGET+=" -Defi=false"
fi

if [ "${NSPAWN_SUPPORT}" = "yes" ]; then
PKG_MESON_OPTS_TARGET+=" -Dmachined=true"
else
PKG_MESON_OPTS_TARGET+=" -Dmachined=false"
fi

pre_configure_target() {
export TARGET_CFLAGS="${TARGET_CFLAGS} -fno-schedule-insns -fno-schedule-insns2 -Wno-format-truncation"
export LC_ALL=en_US.UTF-8
Expand Down Expand Up @@ -156,8 +161,14 @@ post_makeinstall_target() {
sed '/^ConditionNeedsUpdate=.*$/d' -i ${INSTALL}/usr/lib/systemd/system/systemd-hwdb-update.service

# remove nspawn
safe_remove ${INSTALL}/usr/bin/systemd-nspawn
safe_remove ${INSTALL}/usr/lib/systemd/system/[email protected]
if [ ${NSPAWN_SUPPORT} != "yes" ]; then
safe_remove ${INSTALL}/usr/bin/systemd-nspawn
safe_remove ${INSTALL}/usr/lib/systemd/system/[email protected]
safe_remove ${INSTALL}/usr/lib/tmpfiles.d/z_02_systemd-nspawn.conf
safe_remove ${INSTALL}/usr/lib/systemd/system/nspawn-symlink.service
else
find_file_path scripts/nspawn-symlink && cp -PRv ${FOUND_PATH} ${INSTALL}/usr/bin
fi

# remove timedatectl
safe_remove ${INSTALL}/usr/bin/timedatectl
Expand Down Expand Up @@ -254,6 +265,9 @@ post_makeinstall_target() {
ln -sf /storage/.config/logind.conf.d ${INSTALL}/etc/systemd/logind.conf.d
ln -sf /storage/.config/sleep.conf.d ${INSTALL}/etc/systemd/sleep.conf.d
ln -sf /storage/.config/timesyncd.conf.d ${INSTALL}/etc/systemd/timesyncd.conf.d
if [ "${NSPAWN_SUPPORT}" = "yes" ]; then
ln -sf /storage/.config/nspawn ${INSTALL}/etc/systemd/nspawn
fi
safe_remove ${INSTALL}/etc/sysctl.d
ln -sf /storage/.config/sysctl.d ${INSTALL}/etc/sysctl.d
safe_remove ${INSTALL}/etc/tmpfiles.d
Expand Down Expand Up @@ -306,4 +320,7 @@ post_install() {
enable_service network-base.service
enable_service systemd-timesyncd.service
enable_service systemd-timesyncd-setup.service
if [ "${NSPAWN_SUPPORT}" = "yes" ]; then
enable_service nspawn-symlink.service
fi
}
5 changes: 5 additions & 0 deletions packages/sysutils/systemd/scripts/nspawn-symlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

for entry in $(find /storage/containers -mindepth 1 -maxdepth 1); do
ln -s "${entry}" /var/lib/machines/
done
12 changes: 12 additions & 0 deletions packages/sysutils/systemd/system.d/nspawn-symlink.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Make symlinks from /storage/containers to /var/lib/machines
After=systemd-tmpfiles-setup.service
Requires=systemd-tmpfiles-setup.service

[Service]
Type=oneshot
ExecStart=/usr/bin/nspawn-symlink
RemainAfterExit=yes

[Install]
WantedBy=basic.target
4 changes: 4 additions & 0 deletions packages/sysutils/systemd/tmpfiles.d/z_02_systemd-nspawn.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
# Copyright (C) 2024-present Team LibreELEC (https://libreleec.tv)

d /storage/containers 0755 root root - -