* [gentoo-dev] [PATCH 1/8] systemd.eclass: Introduce a common getter for systemd directories
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
@ 2015-11-30 15:01 ` Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 2/8] systemd.eclass: systemd_get_unitdir -> *systemunitdir for consistency Michał Górny
` (7 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-11-30 15:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Add a _systemd_get_dir function that serves as a common getter for
all directories returned by the eclass. Add proper error handling for
the variable getter.
---
eclass/systemd.eclass | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index 278d319..245e803 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -34,16 +34,32 @@ esac
DEPEND="virtual/pkgconfig"
-# @FUNCTION: _systemd_get_unitdir
+# @FUNCTION: _systemd_get_dir
+# @USAGE: <variable-name> <fallback-directory>
# @INTERNAL
# @DESCRIPTION:
-# Get unprefixed unitdir.
-_systemd_get_unitdir() {
+# Try to obtain the <variable-name> variable from systemd.pc.
+# If pkg-config or systemd is not installed, return <fallback-directory>
+# instead.
+_systemd_get_dir() {
+ [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <variable-name> <fallback-directory>"
+ local variable=${1} fallback=${2} d
+
if $(tc-getPKG_CONFIG) --exists systemd; then
- echo "$($(tc-getPKG_CONFIG) --variable=systemdsystemunitdir systemd)"
+ d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die
else
- echo /usr/lib/systemd/system
+ d=${fallback}
fi
+
+ echo "${d}"
+}
+
+# @FUNCTION: _systemd_get_unitdir
+# @INTERNAL
+# @DESCRIPTION:
+# Get unprefixed unitdir.
+_systemd_get_unitdir() {
+ _systemd_get_dir systemdsystemunitdir /usr/lib/systemd/system
}
# @FUNCTION: systemd_get_unitdir
@@ -62,11 +78,7 @@ systemd_get_unitdir() {
# @DESCRIPTION:
# Get unprefixed userunitdir.
_systemd_get_userunitdir() {
- if $(tc-getPKG_CONFIG) --exists systemd; then
- echo "$($(tc-getPKG_CONFIG) --variable=systemduserunitdir systemd)"
- else
- echo /usr/lib/systemd/user
- fi
+ _systemd_get_dir systemduserunitdir /usr/lib/systemd/user
}
# @FUNCTION: systemd_get_userunitdir
@@ -86,11 +98,7 @@ systemd_get_userunitdir() {
# @DESCRIPTION:
# Get unprefixed utildir.
_systemd_get_utildir() {
- if $(tc-getPKG_CONFIG) --exists systemd; then
- echo "$($(tc-getPKG_CONFIG) --variable=systemdutildir systemd)"
- else
- echo /usr/lib/systemd
- fi
+ _systemd_get_dir systemdutildir /usr/lib/systemd
}
# @FUNCTION: systemd_get_utildir
--
2.6.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-dev] [PATCH 2/8] systemd.eclass: systemd_get_unitdir -> *systemunitdir for consistency
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 1/8] systemd.eclass: Introduce a common getter for systemd directories Michał Górny
@ 2015-11-30 15:01 ` Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 3/8] systemd.eclass: Update the example for best practices Michał Górny
` (6 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-11-30 15:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Rename systemd_get_unitdir to systemd_get_systemunitdir for consistency
with other functions. Ban the old name in EAPI 6 onwards.
---
eclass/systemd.eclass | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index 245e803..7dd914a 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -58,19 +58,29 @@ _systemd_get_dir() {
# @INTERNAL
# @DESCRIPTION:
# Get unprefixed unitdir.
-_systemd_get_unitdir() {
+_systemd_get_systemunitdir() {
_systemd_get_dir systemdsystemunitdir /usr/lib/systemd/system
}
-# @FUNCTION: systemd_get_unitdir
+# @FUNCTION: systemd_get_systemunitdir
# @DESCRIPTION:
-# Output the path for the systemd unit directory (not including ${D}).
-# This function always succeeds, even if systemd is not installed.
-systemd_get_unitdir() {
+# Output the path for the systemd system unit directory (not including
+# ${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_unitdir)"
+ echo "${EPREFIX}$(_systemd_get_systemunitdir)"
+}
+
+# @FUNCTION: systemd_get_unitdir
+# @DESCRIPTION:
+# Deprecated alias for systemd_get_systemunitdir.
+systemd_get_unitdir() {
+ [[ ${EAPI} == [012345] ]] || die "${FUNCNAME} is banned in EAPI 6, use systemd_get_systemunitdir instead"
+
+ systemd_get_systemunitdir
}
# @FUNCTION: _systemd_get_userunitdir
@@ -122,7 +132,7 @@ systemd_dounit() {
debug-print-function ${FUNCNAME} "${@}"
(
- insinto "$(_systemd_get_unitdir)"
+ insinto "$(_systemd_get_systemunitdir)"
doins "${@}"
)
}
@@ -136,7 +146,7 @@ systemd_newunit() {
debug-print-function ${FUNCNAME} "${@}"
(
- insinto "$(_systemd_get_unitdir)"
+ insinto "$(_systemd_get_systemunitdir)"
newins "${@}"
)
}
@@ -247,7 +257,7 @@ systemd_enable_service() {
local target=${1}
local service=${2}
- local ud=$(_systemd_get_unitdir)
+ local ud=$(_systemd_get_systemunitdir)
local destname=${service##*/}
dodir "${ud}"/"${target}".wants && \
@@ -281,7 +291,7 @@ systemd_enable_ntpunit() {
die "The .list suffix is appended implicitly to ntpunit.d name."
fi
- local unitdir=$(systemd_get_unitdir)
+ local unitdir=$(systemd_get_systemunitdir)
local s
for s in "${services[@]}"; do
if [[ ! -f "${D}${unitdir}/${s}" ]]; then
@@ -317,7 +327,7 @@ systemd_with_unitdir() {
debug-print-function ${FUNCNAME} "${@}"
local optname=${1:-systemdsystemunitdir}
- echo --with-${optname}="$(systemd_get_unitdir)"
+ echo --with-${optname}="$(systemd_get_systemunitdir)"
}
# @FUNCTION: systemd_with_utildir
@@ -344,7 +354,7 @@ systemd_to_myeconfargs() {
myeconfargs=(
"${myeconfargs[@]}"
- --with-systemdsystemunitdir="$(systemd_get_unitdir)"
+ --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
)
}
--
2.6.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-dev] [PATCH 3/8] systemd.eclass: Update the example for best practices
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 1/8] systemd.eclass: Introduce a common getter for systemd directories Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 2/8] systemd.eclass: systemd_get_unitdir -> *systemunitdir for consistency Michał Górny
@ 2015-11-30 15:01 ` Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 4/8] systemd.eclass: Remove long-deprecated systemd_to_myeconfargs Michał Górny
` (5 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-11-30 15:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
---
eclass/systemd.eclass | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index 7dd914a..72771df 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -15,13 +15,12 @@
# inherit systemd
#
# src_configure() {
-# local myeconfargs=(
+# local myconf=(
# --enable-foo
-# --disable-bar
-# "$(systemd_with_unitdir)"
+# --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
# )
#
-# econf "${myeconfargs[@]}"
+# econf "${myconf[@]}"
# }
# @CODE
--
2.6.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-dev] [PATCH 4/8] systemd.eclass: Remove long-deprecated systemd_to_myeconfargs
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
` (2 preceding siblings ...)
2015-11-30 15:01 ` [gentoo-dev] [PATCH 3/8] systemd.eclass: Update the example for best practices Michał Górny
@ 2015-11-30 15:01 ` Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 5/8] systemd.eclass: Add missing ||die on ntp file writes Michał Górny
` (4 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-11-30 15:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Remove systemd_to_myeconfargs function that was supposed to be removed
2013-10-11. It is no longer used by any ebuild in the repository.
---
eclass/systemd.eclass | 19 +------------------
1 file changed, 1 insertion(+), 18 deletions(-)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index 72771df..e4349bc 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -24,7 +24,7 @@
# }
# @CODE
-inherit eutils toolchain-funcs
+inherit toolchain-funcs
case ${EAPI:-0} in
0|1|2|3|4|5) ;;
@@ -340,23 +340,6 @@ systemd_with_utildir() {
echo --with-systemdutildir="$(systemd_get_utildir)"
}
-# @FUNCTION: systemd_to_myeconfargs
-# @DESCRIPTION:
-# Add '--with-systemdsystemunitdir' as expected by systemd-aware configure
-# scripts to the myeconfargs variable used by autotools-utils eclass. Handles
-# quoting automatically.
-systemd_to_myeconfargs() {
- debug-print-function ${FUNCNAME} "${@}"
-
- eqawarn 'systemd_to_myeconfargs() is deprecated and will be removed on 2013-10-11.'
- eqawarn 'Please use $(systemd_with_unitdir) instead.'
-
- myeconfargs=(
- "${myeconfargs[@]}"
- --with-systemdsystemunitdir="$(systemd_get_systemunitdir)"
- )
-}
-
# @FUNCTION: systemd_update_catalog
# @DESCRIPTION:
# Update the journald catalog. This needs to be called after installing
--
2.6.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-dev] [PATCH 5/8] systemd.eclass: Add missing ||die on ntp file writes
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
` (3 preceding siblings ...)
2015-11-30 15:01 ` [gentoo-dev] [PATCH 4/8] systemd.eclass: Remove long-deprecated systemd_to_myeconfargs Michał Górny
@ 2015-11-30 15:01 ` Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 6/8] systemd.eclass: Ban systemd_with_* in EAPI 6 Michał Górny
` (3 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-11-30 15:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
---
eclass/systemd.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index e4349bc..8ec0c5d 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -296,7 +296,7 @@ systemd_enable_ntpunit() {
if [[ ! -f "${D}${unitdir}/${s}" ]]; then
die "ntp-units.d provider ${s} not installed (yet?) in \${D}."
fi
- echo "${s}" >> "${T}"/${ntpunit_name}.list
+ echo "${s}" >> "${T}"/${ntpunit_name}.list || die
done
(
--
2.6.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-dev] [PATCH 6/8] systemd.eclass: Ban systemd_with_* in EAPI 6
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
` (4 preceding siblings ...)
2015-11-30 15:01 ` [gentoo-dev] [PATCH 5/8] systemd.eclass: Add missing ||die on ntp file writes Michał Górny
@ 2015-11-30 15:01 ` Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 7/8] systemd.eclass: Allow systemd_update_catalog only during pkg_post* Michał Górny
` (2 subsequent siblings)
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-11-30 15:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
Deprecate systemd_with_* and ban it in EAPI 6. Those are only
convenience wrappers for systemd_get_* which barely save typing and are
much less readable than explicit --with-* parameters.
---
eclass/systemd.eclass | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index 8ec0c5d..c0c21a1 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -313,6 +313,9 @@ systemd_enable_ntpunit() {
# @FUNCTION: systemd_with_unitdir
# @USAGE: [<configure-option-name>]
# @DESCRIPTION:
+# Note: deprecated and banned in EAPI 6. Please use full --with-...=
+# parameter for improved ebuild readability.
+#
# Output '--with-systemdsystemunitdir' as expected by systemd-aware configure
# scripts. This function always succeeds. Its output may be quoted in order
# to preserve whitespace in paths. systemd_to_myeconfargs() is preferred over
@@ -323,6 +326,8 @@ 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"
+
debug-print-function ${FUNCNAME} "${@}"
local optname=${1:-systemdsystemunitdir}
@@ -331,10 +336,15 @@ systemd_with_unitdir() {
# @FUNCTION: systemd_with_utildir
# @DESCRIPTION:
+# Note: deprecated and banned in EAPI 6. Please use full --with-...=
+# parameter for improved ebuild readability.
+#
# Output '--with-systemdsystemutildir' as used by some packages to install
# 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"
+
debug-print-function ${FUNCNAME} "${@}"
echo --with-systemdutildir="$(systemd_get_utildir)"
--
2.6.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-dev] [PATCH 7/8] systemd.eclass: Allow systemd_update_catalog only during pkg_post*
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
` (5 preceding siblings ...)
2015-11-30 15:01 ` [gentoo-dev] [PATCH 6/8] systemd.eclass: Ban systemd_with_* in EAPI 6 Michał Górny
@ 2015-11-30 15:01 ` Michał Górny
2015-11-30 15:01 ` [gentoo-dev] [PATCH 8/8] systemd.eclass: Enable EAPI=6 Michał Górny
2015-12-01 22:08 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-11-30 15:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
---
eclass/systemd.eclass | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index c0c21a1..ae933aa 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -353,7 +353,7 @@ systemd_with_utildir() {
# @FUNCTION: systemd_update_catalog
# @DESCRIPTION:
# Update the journald catalog. This needs to be called after installing
-# or removing catalog files.
+# or removing catalog files. This must be called in pkg_post* phases.
#
# If systemd is not installed, no operation will be done. The catalog
# will be (re)built once systemd is installed.
@@ -362,6 +362,9 @@ systemd_with_utildir() {
systemd_update_catalog() {
debug-print-function ${FUNCNAME} "${@}"
+ [[ ${EBUILD_PHASE} == post* ]] \
+ || die "${FUNCNAME} disallowed during ${EBUILD_PHASE_FUNC:-${EBUILD_PHASE}}"
+
# Make sure to work on the correct system.
local journalctl=${EPREFIX}/usr/bin/journalctl
--
2.6.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [gentoo-dev] [PATCH 8/8] systemd.eclass: Enable EAPI=6
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
` (6 preceding siblings ...)
2015-11-30 15:01 ` [gentoo-dev] [PATCH 7/8] systemd.eclass: Allow systemd_update_catalog only during pkg_post* Michał Górny
@ 2015-11-30 15:01 ` Michał Górny
2015-12-01 22:08 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-11-30 15:01 UTC (permalink / raw
To: gentoo-dev; +Cc: Michał Górny
---
eclass/systemd.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index ae933aa..f6cc004 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -27,7 +27,7 @@
inherit toolchain-funcs
case ${EAPI:-0} in
- 0|1|2|3|4|5) ;;
+ 0|1|2|3|4|5|6) ;;
*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
esac
--
2.6.3
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support
2015-11-30 15:01 ` [gentoo-dev] [v2] systemd.eclass cleanup & EAPI 6 support Michał Górny
` (7 preceding siblings ...)
2015-11-30 15:01 ` [gentoo-dev] [PATCH 8/8] systemd.eclass: Enable EAPI=6 Michał Górny
@ 2015-12-01 22:08 ` Michał Górny
8 siblings, 0 replies; 18+ messages in thread
From: Michał Górny @ 2015-12-01 22:08 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 399 bytes --]
On Mon, 30 Nov 2015 16:01:14 +0100
Michał Górny <mgorny@gentoo.org> wrote:
> Hi,
>
> Here's an updated patch set. Two major changes:
>
> - systemd_get_unitdir replaced by systemd_get_systemunitdir, for
> consistency with other functions,
>
> - ban messages now explicitly suggest replacement.
And merged.
--
Best regards,
Michał Górny
<http://dev.gentoo.org/~mgorny/>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread