Merge pull request #277 from flatcar-linux/tormath1/systemd-eclass

eclass: sync systemd
This commit is contained in:
Mathieu Tortuyaux 2022-01-21 10:12:32 +01:00 committed by GitHub
commit d0008c175c

View File

@ -1,14 +1,10 @@
# Copyright 2011-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
# Flatcar: this file is modified to still support old EAPIs.
# @ECLASS: systemd.eclass
# @MAINTAINER:
# systemd@gentoo.org
# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
# @SUPPORTED_EAPIS: 5 6 7 8
# @BLURB: helper functions to install systemd units
# @DESCRIPTION:
# This eclass provides a set of functions to install unit files for
@ -28,14 +24,14 @@
# }
# @CODE
inherit toolchain-funcs
case ${EAPI:-0} in
0|1|2|3|4|5|6|7) ;;
*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
case ${EAPI} in
5|6|7|8) ;;
*) die "${ECLASS}: EAPI ${EAPI:-0} not supported" ;;
esac
if [[ ${EAPI:-0} == [0123456] ]]; then
inherit toolchain-funcs
if [[ ${EAPI} == [56] ]]; then
DEPEND="virtual/pkgconfig"
else
BDEPEND="virtual/pkgconfig"
@ -65,7 +61,7 @@ _systemd_get_dir() {
echo "${d}"
}
# @FUNCTION: _systemd_get_unitdir
# @FUNCTION: _systemd_get_systemunitdir
# @INTERNAL
# @DESCRIPTION:
# Get unprefixed unitdir.
@ -79,7 +75,6 @@ _systemd_get_systemunitdir() {
# ${D}). This function always succeeds, even if systemd is not
# installed.
systemd_get_systemunitdir() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_systemd_get_systemunitdir)"
@ -89,7 +84,7 @@ systemd_get_systemunitdir() {
# @DESCRIPTION:
# Deprecated alias for systemd_get_systemunitdir.
systemd_get_unitdir() {
[[ ${EAPI} == [012345] ]] || die "${FUNCNAME} is banned in EAPI 6, use systemd_get_systemunitdir instead"
[[ ${EAPI} == 5 ]] || die "${FUNCNAME} is banned in EAPI 6, use systemd_get_systemunitdir instead"
systemd_get_systemunitdir
}
@ -108,7 +103,6 @@ _systemd_get_userunitdir() {
# ${D}). This function always succeeds, even if systemd is not
# installed.
systemd_get_userunitdir() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_systemd_get_userunitdir)"
@ -128,7 +122,6 @@ _systemd_get_utildir() {
# ${D}). This function always succeeds, even if systemd is not
# installed.
systemd_get_utildir() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_systemd_get_utildir)"
@ -147,7 +140,6 @@ _systemd_get_systemgeneratordir() {
# Output the path for the systemd system generator directory (not including
# ${D}). This function always succeeds, even if systemd is not installed.
systemd_get_systemgeneratordir() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_systemd_get_systemgeneratordir)"
@ -174,8 +166,7 @@ systemd_get_systempresetdir() {
# @FUNCTION: systemd_dounit
# @USAGE: <unit>...
# @DESCRIPTION:
# Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4
# and non-fatal in earlier EAPIs.
# Install systemd unit(s). Uses doins, thus it is fatal.
systemd_dounit() {
debug-print-function ${FUNCNAME} "${@}"
@ -189,8 +180,7 @@ systemd_dounit() {
# @FUNCTION: systemd_newunit
# @USAGE: <old-name> <new-name>
# @DESCRIPTION:
# Install systemd unit with a new name. Uses newins, thus it is fatal
# in EAPI 4 and non-fatal in earlier EAPIs.
# Install systemd unit with a new name. Uses newins, thus it is fatal.
systemd_newunit() {
debug-print-function ${FUNCNAME} "${@}"
@ -204,8 +194,7 @@ systemd_newunit() {
# @FUNCTION: systemd_douserunit
# @USAGE: <unit>...
# @DESCRIPTION:
# Install systemd user unit(s). Uses doins, thus it is fatal in EAPI 4
# and non-fatal in earlier EAPIs.
# Install systemd user unit(s). Uses doins, thus it is fatal.
systemd_douserunit() {
debug-print-function ${FUNCNAME} "${@}"
@ -220,7 +209,7 @@ systemd_douserunit() {
# @USAGE: <old-name> <new-name>
# @DESCRIPTION:
# Install systemd user unit with a new name. Uses newins, thus it
# is fatal in EAPI 4 and non-fatal in earlier EAPIs.
# is fatal.
systemd_newuserunit() {
debug-print-function ${FUNCNAME} "${@}"
@ -265,8 +254,7 @@ systemd_install_serviced() {
# @USAGE: <target> <service>
# @DESCRIPTION:
# Enable service in desired target, e.g. install a symlink for it.
# Uses dosym, thus it is fatal in EAPI 4 and non-fatal in earlier
# EAPIs.
# Uses dosym, thus it is fatal.
systemd_enable_service() {
debug-print-function ${FUNCNAME} "${@}"
@ -289,8 +277,7 @@ systemd_enable_service() {
# and name, while the remaining arguments list service units that will
# be added to that file.
#
# Uses doins, thus it is fatal in EAPI 4 and non-fatal in earlier
# EAPIs.
# Uses doins, thus it is fatal.
#
# Doc: https://www.freedesktop.org/wiki/Software/systemd/timedated/
systemd_enable_ntpunit() {
@ -345,7 +332,7 @@ systemd_enable_ntpunit() {
# argument to this function (`$(systemd_with_unitdir systemdunitdir)'). Please
# remember to report a bug upstream as well.
systemd_with_unitdir() {
[[ ${EAPI:-0} != [012345] ]] && die "${FUNCNAME} is banned in EAPI ${EAPI}, use --with-${1:-systemdsystemunitdir}=\"\$(systemd_get_systemunitdir)\" instead"
[[ ${EAPI} == 5 ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use --with-${1:-systemdsystemunitdir}=\"\$(systemd_get_systemunitdir)\" instead"
debug-print-function ${FUNCNAME} "${@}"
local optname=${1:-systemdsystemunitdir}
@ -362,7 +349,7 @@ systemd_with_unitdir() {
# systemd helpers. This function always succeeds. Its output may be quoted
# in order to preserve whitespace in paths.
systemd_with_utildir() {
[[ ${EAPI:-0} != [012345] ]] && die "${FUNCNAME} is banned in EAPI ${EAPI}, use --with-systemdutildir=\"\$(systemd_get_utildir)\" instead"
[[ ${EAPI} == 5 ]] || die "${FUNCNAME} is banned in EAPI ${EAPI}, use --with-systemdutildir=\"\$(systemd_get_utildir)\" instead"
debug-print-function ${FUNCNAME} "${@}"