From 4a60328aa8a395945dd10a3f60cb39af4a0f78ba Mon Sep 17 00:00:00 2001 From: Flatcar Buildbot Date: Mon, 2 Oct 2023 07:12:30 +0000 Subject: [PATCH] eclass/systemd: Sync with Gentoo It's from Gentoo commit 866faf07e36ba85b4c1cce2ac642eb5b7b041f57. --- .../portage-stable/eclass/systemd.eclass | 44 ++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/sdk_container/src/third_party/portage-stable/eclass/systemd.eclass b/sdk_container/src/third_party/portage-stable/eclass/systemd.eclass index fbed387e0c..03d6a82fd3 100644 --- a/sdk_container/src/third_party/portage-stable/eclass/systemd.eclass +++ b/sdk_container/src/third_party/portage-stable/eclass/systemd.eclass @@ -1,4 +1,4 @@ -# Copyright 2011-2022 Gentoo Authors +# Copyright 2011-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 # @ECLASS: systemd.eclass @@ -227,6 +227,48 @@ systemd_install_serviced() { ) } +# @FUNCTION: systemd_install_dropin +# @USAGE: [--user] +# @DESCRIPTION: +# Install as the dropin file .d/00gentoo.conf, +# overriding the settings of . +# Defaults to system unit dropins, unless --user is provided, +# which causes the dropin to be installed for user units. +# The required argument may be '-', in which case the +# file is read from stdin and must also be specified. +# @EXAMPLE: +# systemd_install_dropin foo.service "${FILESDIR}/foo.service.conf" +# systemd_install_dropin foo.service - <<-EOF +# [Service] +# RestartSec=120 +# EOF +systemd_install_dropin() { + debug-print-function ${FUNCNAME} "${@}" + + local basedir + if [[ $# -ge 1 ]] && [[ $1 == "--user" ]]; then + basedir=$(_systemd_unprefix systemd_get_userunitdir) + shift 1 + else + basedir=$(_systemd_unprefix systemd_get_systemunitdir) + fi + + local unit=${1} + local src=${2} + + [[ ${unit} ]] || die "No unit specified" + [[ ${src} ]] || die "No conf file specified" + + # avoid potentially common mistake + [[ ${unit} == *.d ]] && die "Unit ${unit} must not have .d suffix" + + ( + insopts -m 0644 + insinto "${basedir}/${unit}".d + newins "${src}" 00gentoo.conf + ) +} + # @FUNCTION: systemd_enable_service # @USAGE: # @DESCRIPTION: