dev-qt/qtopengl: stable 5.14.2 for ppc, bug #719732
[gentoo.git] / eclass / systemd.eclass
index 63ff5609589d31992688cb3e95f62ee4e66266d1..04f277e94d64f06f43cd9cb7dc093180e8c3fce4 100644 (file)
@@ -4,6 +4,7 @@
 # @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>
@@ -45,6 +50,7 @@ _systemd_get_dir() {
 
        if $(tc-getPKG_CONFIG) --exists systemd; then
                d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die
+               d=${d#${EPREFIX}}
        else
                d=${fallback}
        fi
@@ -57,7 +63,7 @@ _systemd_get_dir() {
 # @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
@@ -106,7 +112,7 @@ systemd_get_userunitdir() {
 # @DESCRIPTION:
 # Get unprefixed utildir.
 _systemd_get_utildir() {
-       _systemd_get_dir systemdutildir /usr/lib/systemd
+       _systemd_get_dir systemdutildir /lib/systemd
 }
 
 # @FUNCTION: systemd_get_utildir
@@ -121,6 +127,26 @@ systemd_get_utildir() {
        echo "${EPREFIX}$(_systemd_get_utildir)"
 }
 
+# @FUNCTION: _systemd_get_systemgeneratordir
+# @INTERNAL
+# @DESCRIPTION:
+# Get unprefixed systemgeneratordir.
+_systemd_get_systemgeneratordir() {
+       _systemd_get_dir systemdsystemgeneratordir /lib/systemd/system-generators
+}
+
+# @FUNCTION: systemd_get_systemgeneratordir
+# @DESCRIPTION:
+# 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)"
+}
+
 # @FUNCTION: systemd_dounit
 # @USAGE: <unit>...
 # @DESCRIPTION:
@@ -130,6 +156,7 @@ systemd_dounit() {
        debug-print-function ${FUNCNAME} "${@}"
 
        (
+               insopts -m 0644
                insinto "$(_systemd_get_systemunitdir)"
                doins "${@}"
        )
@@ -144,6 +171,7 @@ systemd_newunit() {
        debug-print-function ${FUNCNAME} "${@}"
 
        (
+               insopts -m 0644
                insinto "$(_systemd_get_systemunitdir)"
                newins "${@}"
        )
@@ -158,6 +186,7 @@ systemd_douserunit() {
        debug-print-function ${FUNCNAME} "${@}"
 
        (
+               insopts -m 0644
                insinto "$(_systemd_get_userunitdir)"
                doins "${@}"
        )
@@ -172,6 +201,7 @@ systemd_newuserunit() {
        debug-print-function ${FUNCNAME} "${@}"
 
        (
+               insopts -m 0644
                insinto "$(_systemd_get_userunitdir)"
                newins "${@}"
        )
@@ -201,6 +231,7 @@ systemd_install_serviced() {
        [[ ${service} == *.d ]] && die "Service must not have .d suffix"
 
        (
+               insopts -m 0644
                insinto /etc/systemd/system/"${service}".d
                newins "${src}" 00gentoo.conf
        )
@@ -220,6 +251,7 @@ systemd_dotmpfilesd() {
        done
 
        (
+               insopts -m 0644
                insinto /usr/lib/tmpfiles.d/
                doins "${@}"
        )
@@ -237,6 +269,7 @@ systemd_newtmpfilesd() {
                || die 'tmpfiles.d files need to have .conf suffix.'
 
        (
+               insopts -m 0644
                insinto /usr/lib/tmpfiles.d/
                newins "${@}"
        )
@@ -299,6 +332,7 @@ systemd_enable_ntpunit() {
        done
 
        (
+               insopts -m 0644
                insinto "$(_systemd_get_utildir)"/ntp-units.d
                doins "${T}"/${ntpunit_name}.list
        )
@@ -434,8 +468,8 @@ systemd_reenable() {
        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
 }