public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems
@ 2017-04-30 19:06 Michał Górny
  2017-04-30 19:06 ` [gentoo-dev] [PATCH 2/3] tmpfiles.eclass: Explicit warn on ROOT != / to avoid breakage Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michał Górny @ 2017-04-30 19:06 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Fix the eclass code to remove the misguided Linux conditionals.
The whole purpose of the eclass was to avoid having to implement
fallback logic for systems not having service manager tmpfiles.d
support. Making it conditional to Linux implied that for non-Linux
systems (Prefix, FreeBSD) we would have to implement explicit fallback
to create the necessary directories.

While systemd (and therefore systemd-tmpfilesd) is indeed
Linux-specific, the opentmpfiles implementation should be pretty
portable and there is no reason to restrict it to Linux only, or to
prevent using it on non-Linux OpenRC (and non-OpenRC) systems.
---
 eclass/tmpfiles.eclass | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/eclass/tmpfiles.eclass b/eclass/tmpfiles.eclass
index 2a158c482a58..9cf040de987f 100644
--- a/eclass/tmpfiles.eclass
+++ b/eclass/tmpfiles.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2016 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 # @ECLASS: tmpfiles.eclass
@@ -17,10 +17,16 @@
 # https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
 #
 # The dotmpfiles and newtmpfiles functions are used to install
-# configuration files into /usr/lib/tmpfiles.d, then in pkg_postinst, the
-# tmpfiles_process function can be called to process the newly
+# configuration files into /usr/lib/tmpfiles.d, then in pkg_postinst,
+# the tmpfiles_process function must be called to process the newly
 # installed tmpfiles.d entries.
 #
+# The tmpfiles.d files can be used by service managers to recreate/clean
+# up temporary directories on boot or periodically. Additionally,
+# the pkg_postinst() call ensures that the directories are created
+# on systems that do not support tmpfiles.d natively, without a need
+# for explicit fallback.
+#
 # @EXAMPLE:
 # Typical usage of this eclass:
 #
@@ -53,7 +59,7 @@ case "${EAPI}" in
 *) die "API is undefined for EAPI ${EAPI}" ;;
 esac
 
-RDEPEND="kernel_linux? ( virtual/tmpfiles )"
+RDEPEND="virtual/tmpfiles"
 
 # @FUNCTION: dotmpfiles
 # @USAGE: dotmpfiles <tmpfiles.d_file> ...
@@ -62,7 +68,6 @@ RDEPEND="kernel_linux? ( virtual/tmpfiles )"
 dotmpfiles() {
 	debug-print-function "${FUNCNAME}" "$@"
 
-	use kernel_linux || return 0
 	local f
 	for f; do
 		if [[ ${f} != *.conf ]]; then
@@ -83,7 +88,6 @@ dotmpfiles() {
 newtmpfiles() {
 	debug-print-function "${FUNCNAME}" "$@"
 
-	use kernel_linux || return 0
 	if [[ $2 != *.conf ]]; then
 		die "tmpfiles.d files must end with .conf"
 	fi
@@ -102,7 +106,6 @@ newtmpfiles() {
 tmpfiles_process() {
 	debug-print-function "${FUNCNAME}" "$@"
 
-	use kernel_linux || return 0
 	[[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst"
 	[[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename"
 
-- 
2.13.0.rc1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-dev] [PATCH 2/3] tmpfiles.eclass: Explicit warn on ROOT != / to avoid breakage
  2017-04-30 19:06 [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems Michał Górny
@ 2017-04-30 19:06 ` Michał Górny
  2017-04-30 19:06 ` [gentoo-dev] [PATCH 3/3] app-portage/eix: Convert to tmpfiles.eclass (example) Michał Górny
  2017-05-02 14:38 ` [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems William Hubbs
  2 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2017-04-30 19:06 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

---
 eclass/tmpfiles.eclass | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/eclass/tmpfiles.eclass b/eclass/tmpfiles.eclass
index 9cf040de987f..018ea45d4182 100644
--- a/eclass/tmpfiles.eclass
+++ b/eclass/tmpfiles.eclass
@@ -110,7 +110,18 @@ tmpfiles_process() {
 	[[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename"
 
 	# Only process tmpfiles for the currently running system
-	[[ ${ROOT} == / ]] || return 0
+	if [[ ${ROOT} != / ]]; then
+		ewarn "Warning: tmpfiles.d not processed on ROOT != /. If you do not use"
+		ewarn "a service manager supporting tmpfiles.d, you need to run"
+		ewarn "the following command after booting (or chroot-ing with all"
+		ewarn "appropriate filesystems mounted) into the ROOT:"
+		ewarn
+		ewarn "  tmpfiles --create"
+		ewarn
+		ewarn "Failure to do so may result in missing runtime directories"
+		ewarn "and failures to run programs or start services."
+		return
+	fi
 
 	if type systemd-tmpfiles &> /dev/null; then
 		systemd-tmpfiles --create "$@"
-- 
2.13.0.rc1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [gentoo-dev] [PATCH 3/3] app-portage/eix: Convert to tmpfiles.eclass (example)
  2017-04-30 19:06 [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems Michał Górny
  2017-04-30 19:06 ` [gentoo-dev] [PATCH 2/3] tmpfiles.eclass: Explicit warn on ROOT != / to avoid breakage Michał Górny
@ 2017-04-30 19:06 ` Michał Górny
  2017-05-02 14:38 ` [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems William Hubbs
  2 siblings, 0 replies; 6+ messages in thread
From: Michał Górny @ 2017-04-30 19:06 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

Replace the use of systemd.eclass with more generic tmpfiles.eclass to
install the tmpfiles.d file. Use tmpfiles_process to ensure that
the directory is created and correctly owned instead of keepdir-ing it
(which triggers QA warnings from Portage) and chown-ing it
in pkg_postinst() (which is a hack to workaround Portage design issues).
---
 app-portage/eix/{eix-0.32.5-r1.ebuild => eix-0.32.5-r2.ebuild} | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
 rename app-portage/eix/{eix-0.32.5-r1.ebuild => eix-0.32.5-r2.ebuild} (93%)

diff --git a/app-portage/eix/eix-0.32.5-r1.ebuild b/app-portage/eix/eix-0.32.5-r2.ebuild
similarity index 93%
rename from app-portage/eix/eix-0.32.5-r1.ebuild
rename to app-portage/eix/eix-0.32.5-r2.ebuild
index 2026b44a4b15..1d6fa3801834 100644
--- a/app-portage/eix/eix-0.32.5-r1.ebuild
+++ b/app-portage/eix/eix-0.32.5-r2.ebuild
@@ -4,7 +4,7 @@
 EAPI=6
 
 PLOCALES="de ru"
-inherit autotools bash-completion-r1 l10n systemd flag-o-matic
+inherit autotools bash-completion-r1 l10n flag-o-matic tmpfiles
 
 DESCRIPTION="Search and query ebuilds"
 HOMEPAGE="https://github.com/vaeth/eix/"
@@ -83,20 +83,18 @@ src_configure() {
 src_install() {
 	default
 	dobashcomp bash/eix
-	systemd_dotmpfilesd tmpfiles.d/eix.conf
+	dotmpfiles tmpfiles.d/eix.conf
 
 	insinto /usr/share/${PN}
 	doins "${ED}"/usr/bin/eix-functions.sh
 	rm -r "${ED}"/usr/bin/eix-functions.sh || die
-
-	keepdir /var/cache/eix
 }
 
 pkg_postinst() {
 	if ! use prefix; then
 		# note: if this is done in src_install(), portage:portage
 		# ownership may be reset to root
-		chown portage:portage "${EROOT%/}"/var/cache/eix || die
+		tmpfiles_process eix.conf
 	fi
 
 	local obs=${EROOT%/}/var/cache/eix.previous
-- 
2.13.0.rc1



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems
  2017-04-30 19:06 [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems Michał Górny
  2017-04-30 19:06 ` [gentoo-dev] [PATCH 2/3] tmpfiles.eclass: Explicit warn on ROOT != / to avoid breakage Michał Górny
  2017-04-30 19:06 ` [gentoo-dev] [PATCH 3/3] app-portage/eix: Convert to tmpfiles.eclass (example) Michał Górny
@ 2017-05-02 14:38 ` William Hubbs
  2017-05-02 14:56   ` Michał Górny
  2017-05-02 16:21   ` Mike Gilbert
  2 siblings, 2 replies; 6+ messages in thread
From: William Hubbs @ 2017-05-02 14:38 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1440 bytes --]

On Sun, Apr 30, 2017 at 09:06:53PM +0200, Michał Górny wrote:
> Fix the eclass code to remove the misguided Linux conditionals.
> The whole purpose of the eclass was to avoid having to implement
> fallback logic for systems not having service manager tmpfiles.d
> support. Making it conditional to Linux implied that for non-Linux
> systems (Prefix, FreeBSD) we would have to implement explicit fallback
> to create the necessary directories.
> 
> While systemd (and therefore systemd-tmpfilesd) is indeed
> Linux-specific, the opentmpfiles implementation should be pretty
> portable and there is no reason to restrict it to Linux only, or to
> prevent using it on non-Linux OpenRC (and non-OpenRC) systems.

Opentmpfiles can run right now on non-openrc systems, but it requires a
linux host; that is why the Linux conditionals are there. We currently support
selinux and even more specific linux code is coming with the btrfs
subvolume support.

The purpose of opentmpfiles is to provide a non-systemd program that
mirrors the behavior of systemd-tmpfiles so that Linux users do not have
to install systemd, but there are features that definitely would not
work on other hosts.

Also, the tmpfiles.d standard doesn't allow tmpfiles to do things based
on operating systems, and the configuration search paths (particularly
/run/tmpfiles.d and the non-support of /lib/tmpfiles.d) are linux specific.

William


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems
  2017-05-02 14:38 ` [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems William Hubbs
@ 2017-05-02 14:56   ` Michał Górny
  2017-05-02 16:21   ` Mike Gilbert
  1 sibling, 0 replies; 6+ messages in thread
From: Michał Górny @ 2017-05-02 14:56 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 2295 bytes --]

On wto, 2017-05-02 at 09:38 -0500, William Hubbs wrote:
> On Sun, Apr 30, 2017 at 09:06:53PM +0200, Michał Górny wrote:
> > Fix the eclass code to remove the misguided Linux conditionals.
> > The whole purpose of the eclass was to avoid having to implement
> > fallback logic for systems not having service manager tmpfiles.d
> > support. Making it conditional to Linux implied that for non-Linux
> > systems (Prefix, FreeBSD) we would have to implement explicit fallback
> > to create the necessary directories.
> > 
> > While systemd (and therefore systemd-tmpfilesd) is indeed
> > Linux-specific, the opentmpfiles implementation should be pretty
> > portable and there is no reason to restrict it to Linux only, or to
> > prevent using it on non-Linux OpenRC (and non-OpenRC) systems.
> 
> Opentmpfiles can run right now on non-openrc systems, but it requires a
> linux host; that is why the Linux conditionals are there. We currently support
> selinux and even more specific linux code is coming with the btrfs
> subvolume support.

It's funny because I've just got a confirmation that it works
on FreeBSD.

> The purpose of opentmpfiles is to provide a non-systemd program that
> mirrors the behavior of systemd-tmpfiles so that Linux users do not have
> to install systemd, but there are features that definitely would not
> work on other hosts.

We need a tool that works for everyone. Not excuses not to support Linux
just because systemd does not.

> Also, the tmpfiles.d standard doesn't allow tmpfiles to do things based
> on operating systems,

And what's the problem with installing tmpfiles.d files aligned to
the operating system in question? After all, you don't tell everyone not
to use OpenRC outside Linux just because someone might have put Linux-
specific paths in the init.d file.

> and the configuration search paths (particularly
> /run/tmpfiles.d and the non-support of /lib/tmpfiles.d) are linux specific.
> 

Does that hurt anyone? We're talking about Gentoo/FBSD and Gentoo
Prefix, i.e. Gentoo-flavored systems which we have control over. If you
really insist, I can ask our FBSD/Prefix teams to look through the code
and make sure that it works across all interesting platforms.

-- 
Best regards,
Michał Górny

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 963 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems
  2017-05-02 14:38 ` [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems William Hubbs
  2017-05-02 14:56   ` Michał Górny
@ 2017-05-02 16:21   ` Mike Gilbert
  1 sibling, 0 replies; 6+ messages in thread
From: Mike Gilbert @ 2017-05-02 16:21 UTC (permalink / raw
  To: Gentoo Dev

On Tue, May 2, 2017 at 10:38 AM, William Hubbs <williamh@gentoo.org> wrote:
> On Sun, Apr 30, 2017 at 09:06:53PM +0200, Michał Górny wrote:
>> Fix the eclass code to remove the misguided Linux conditionals.
>> The whole purpose of the eclass was to avoid having to implement
>> fallback logic for systems not having service manager tmpfiles.d
>> support. Making it conditional to Linux implied that for non-Linux
>> systems (Prefix, FreeBSD) we would have to implement explicit fallback
>> to create the necessary directories.
>>
>> While systemd (and therefore systemd-tmpfilesd) is indeed
>> Linux-specific, the opentmpfiles implementation should be pretty
>> portable and there is no reason to restrict it to Linux only, or to
>> prevent using it on non-Linux OpenRC (and non-OpenRC) systems.
>
> Opentmpfiles can run right now on non-openrc systems, but it requires a
> linux host; that is why the Linux conditionals are there. We currently support
> selinux and even more specific linux code is coming with the btrfs
> subvolume support.

My Linux system does not support selinux. Other people have Linux
systems which do not support btrfs. tmpfiles still works on such
systems.

What exactly breaks on non-Linux systems?


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-05-02 16:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-30 19:06 [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems Michał Górny
2017-04-30 19:06 ` [gentoo-dev] [PATCH 2/3] tmpfiles.eclass: Explicit warn on ROOT != / to avoid breakage Michał Górny
2017-04-30 19:06 ` [gentoo-dev] [PATCH 3/3] app-portage/eix: Convert to tmpfiles.eclass (example) Michał Górny
2017-05-02 14:38 ` [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems William Hubbs
2017-05-02 14:56   ` Michał Górny
2017-05-02 16:21   ` Mike Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox