# @ECLASS: systemd.eclass
# @MAINTAINER:
# systemd@gentoo.org
+# @SUPPORTED_EAPIS: 0 1 2 3 4 5 6 7
# @BLURB: helper functions to install systemd units
# @DESCRIPTION:
# This eclass provides a set of functions to install unit files for
inherit toolchain-funcs
case ${EAPI:-0} in
- 0|1|2|3|4|5|6) ;;
+ 0|1|2|3|4|5|6|7) ;;
*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
esac
-DEPEND="virtual/pkgconfig"
+if [[ ${EAPI:-0} == [0123456] ]]; then
+ DEPEND="virtual/pkgconfig"
+else
+ BDEPEND="virtual/pkgconfig"
+fi
# @FUNCTION: _systemd_get_dir
# @USAGE: <variable-name> <fallback-directory>
if $(tc-getPKG_CONFIG) --exists systemd; then
d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die
+ d=${d#${EPREFIX}}
else
d=${fallback}
fi
# @DESCRIPTION:
# Get unprefixed unitdir.
_systemd_get_systemunitdir() {
- _systemd_get_dir systemdsystemunitdir /usr/lib/systemd/system
+ _systemd_get_dir systemdsystemunitdir /lib/systemd/system
}
# @FUNCTION: systemd_get_systemunitdir
# @DESCRIPTION:
# Get unprefixed utildir.
_systemd_get_utildir() {
- _systemd_get_dir systemdutildir /usr/lib/systemd
+ _systemd_get_dir systemdutildir /lib/systemd
}
# @FUNCTION: systemd_get_utildir
# @DESCRIPTION:
# Get unprefixed systemgeneratordir.
_systemd_get_systemgeneratordir() {
- _systemd_get_dir systemdsystemgeneratordir /usr/lib/systemd/system-generators
+ _systemd_get_dir systemdsystemgeneratordir /lib/systemd/system-generators
}
# @FUNCTION: systemd_get_systemgeneratordir
debug-print-function ${FUNCNAME} "${@}"
(
+ insopts -m 0644
insinto "$(_systemd_get_systemunitdir)"
doins "${@}"
)
debug-print-function ${FUNCNAME} "${@}"
(
+ insopts -m 0644
insinto "$(_systemd_get_systemunitdir)"
newins "${@}"
)
debug-print-function ${FUNCNAME} "${@}"
(
+ insopts -m 0644
insinto "$(_systemd_get_userunitdir)"
doins "${@}"
)
debug-print-function ${FUNCNAME} "${@}"
(
+ insopts -m 0644
insinto "$(_systemd_get_userunitdir)"
newins "${@}"
)
[[ ${service} == *.d ]] && die "Service must not have .d suffix"
(
+ insopts -m 0644
insinto /etc/systemd/system/"${service}".d
newins "${src}" 00gentoo.conf
)
done
(
+ insopts -m 0644
insinto /usr/lib/tmpfiles.d/
doins "${@}"
)
|| die 'tmpfiles.d files need to have .conf suffix.'
(
+ insopts -m 0644
insinto /usr/lib/tmpfiles.d/
newins "${@}"
)
done
(
+ insopts -m 0644
insinto "$(_systemd_get_utildir)"/ntp-units.d
doins "${T}"/${ntpunit_name}.list
)
type systemctl &>/dev/null || return 0
local x
for x; do
- if systemctl --quiet --root="${ROOT}" is-enabled "${x}"; then
- systemctl --root="${ROOT}" reenable "${x}"
+ if systemctl --quiet --root="${ROOT:-/}" is-enabled "${x}"; then
+ systemctl --root="${ROOT:-/}" reenable "${x}"
fi
done
}