public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [RFC] new tmpfilesd.eclass
@ 2012-08-15 20:57 Sergei Trofimovich
  2012-08-15 21:25 ` Michał Górny
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sergei Trofimovich @ 2012-08-15 20:57 UTC (permalink / raw
  To: gentoo-dev; +Cc: gentoo-dev-announce


[-- Attachment #1.1: Type: text/plain, Size: 1739 bytes --]

As gentoo switched to /var/run/ -> /run in tmpfs recently
people got into problems [1] of missing directories like:

    /var/run/screen/
    /var/run/openfire/
    /var/run/proftpd/

they did bite me personally.

openrc-0.10 brought [2] basic support for systemd's tmpfiles'd:

  http://0pointer.de/public/systemd-man/tmpfiles.d.html

But there is no simple way to install such helpers from ebuilds.
The tmpfiles.d is aimed to help in such situations.

I've picked proftpd as an example as it's situation is very similar
to screen's situation. There is inetd mode (opposed to standalone
mode) when you don't have any init.d code to create /var/run/
directories for you. Thus tmpfiles.d for the rescue.

See attach for the whole eclass code. It's almost a copy of Michał's
bash-completion-r1.eclass which I find very easy to use.

I'll show eclass usage example for proftpd:

--- proftpd-1.3.4a-r1.ebuild    2012-05-29 20:16:51.000000000 +0300
+++ proftpd-1.3.4a-r2.ebuild    2012-08-15 23:10:49.000000000 +0300
@@ -3,7 +3,7 @@
 # $Header: /var/cvsroot/gentoo-x86/net-ftp/proftpd/proftpd-1.3.4a-r1.ebuild,v 1.2 2012/05/13 10:49:47 swift Exp $
 
 EAPI=4
-inherit eutils
+inherit eutils tmpfilesd
 
 MOD_CASE="0.7"
 MOD_CLAMAV="0.11rc"
@@ -216,6 +216,8 @@
                docinto rfc
                dodoc doc/rfc/*.txt
        fi
+
+       newtmpfilesd ${FILESDIR}/tmpfilesd.conf ${PN}.conf
 }
 
 pkg_postinst() {

The caveats:
- files get created only if I run /lib/rc/sh/tmpfiles.sh manually
- haven't tested with systemd, but i'd expect it to work

Thanks!

[1]: https://bugs.gentoo.org/show_bug.cgi?id=361349
[2]: https://bugs.gentoo.org/show_bug.cgi?id=396003

-- 

  Sergei

[-- Attachment #1.2: tmpfilesd.eclass --]
[-- Type: application/octet-stream, Size: 1230 bytes --]

# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header:  $

# @ECLASS: tmpfilesd.eclass
# @MAINTAINER:
# slyfox@gentoo.org
# @AUTHOR:
# Based on bash-completion-r1.eclass by Michał Górny <mgorny@gentoo.org>.
# @BLURB: Helpers to install tmpfiles.d files.
# @DESCRIPTION:
# As described in http://0pointer.de/public/systemd-man/tmpfiles.d.html
# helpers allow installing package's tmpfiles.d into /usr/lib/tmpfiles.d
# @EXAMPLE:
#
# @CODE
# EAPI=4
#
# src_install() {
# 	default
#
# 	newtmpfilesd ${FILESDIR}/tmpfilesd.conf ${PN}.conf
# }
# @CODE

case ${EAPI:-0} in
	0|1|2|3|4) ;;
	*) die "EAPI ${EAPI} is unknown."
esac

# @FUNCTION: dotmpfilesd
# @USAGE: file [...]
# @DESCRIPTION:
# Install tmpfiles.d files passed as args. Has EAPI-dependant failure
# behavior (like doins).
dotmpfilesd() {
	debug-print-function ${FUNCNAME} "${@}"

	(
		insinto /usr/lib/tmpfiles.d
		doins "${@}"
	)
}

# @FUNCTION: newtmpfilesd
# @USAGE: file newname
# @DESCRIPTION:
# Install tmpfiles.d file under a new name. Has EAPI-dependant failure
# behavior (like newins).
newtmpfilesd() {
	debug-print-function ${FUNCNAME} "${@}"

	(
		insinto /usr/lib/tmpfiles.d
		newins "${@}"
	)
}

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [gentoo-dev] [RFC] new tmpfilesd.eclass
  2012-08-15 20:57 [gentoo-dev] [RFC] new tmpfilesd.eclass Sergei Trofimovich
@ 2012-08-15 21:25 ` Michał Górny
  2012-08-16  7:38   ` Sergei Trofimovich
  2012-08-15 22:26 ` William Hubbs
  2012-08-16  6:19 ` Robin H. Johnson
  2 siblings, 1 reply; 9+ messages in thread
From: Michał Górny @ 2012-08-15 21:25 UTC (permalink / raw
  To: gentoo-dev; +Cc: slyfox, gentoo-dev-announce

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

On Wed, 15 Aug 2012 23:57:57 +0300
Sergei Trofimovich <slyfox@gentoo.org> wrote:

> But there is no simple way to install such helpers from ebuilds.
> The tmpfiles.d is aimed to help in such situations.

Yes, there is.

$ grep dotmpfiles *.eclass
systemd.eclass:# @FUNCTION: systemd_dotmpfilesd
systemd.eclass:systemd_dotmpfilesd() {

Well, it doesn't have a new* variant but I guess that can be added if
necessary.

Also, maybe for some devs a easy make_tmpfiles_d() function will be
useful too...

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]

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

* Re: [gentoo-dev] [RFC] new tmpfilesd.eclass
  2012-08-15 20:57 [gentoo-dev] [RFC] new tmpfilesd.eclass Sergei Trofimovich
  2012-08-15 21:25 ` Michał Górny
@ 2012-08-15 22:26 ` William Hubbs
  2012-08-16  6:19 ` Robin H. Johnson
  2 siblings, 0 replies; 9+ messages in thread
From: William Hubbs @ 2012-08-15 22:26 UTC (permalink / raw
  To: gentoo-dev

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

I have a couple of minor requests for readability.

Can you call the eclass tmpfiles-d.eclass?
Then, for the functions themselves, use names like,

dotmpfiles_d
newtmpfiles_d

so they will be a bit more readable?

Thanks,

William


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

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

* Re: [gentoo-dev] [RFC] new tmpfilesd.eclass
  2012-08-15 20:57 [gentoo-dev] [RFC] new tmpfilesd.eclass Sergei Trofimovich
  2012-08-15 21:25 ` Michał Górny
  2012-08-15 22:26 ` William Hubbs
@ 2012-08-16  6:19 ` Robin H. Johnson
  2012-08-16  7:13   ` Sergei Trofimovich
  2 siblings, 1 reply; 9+ messages in thread
From: Robin H. Johnson @ 2012-08-16  6:19 UTC (permalink / raw
  To: gentoo-dev

On Wed, Aug 15, 2012 at 11:57:57PM +0300, Sergei Trofimovich wrote:
> As gentoo switched to /var/run/ -> /run in tmpfs recently
> people got into problems [1] of missing directories like:
>     /var/run/screen/
>     /var/run/openfire/
>     /var/run/proftpd/
> they did bite me personally.
If the package has an init.d script, it should be doing creation of the
needed dirs. I know this doesn't help screen however.

> openrc-0.10 brought [2] basic support for systemd's tmpfiles'd:
> [2]: https://bugs.gentoo.org/show_bug.cgi?id=396003
>   http://0pointer.de/public/systemd-man/tmpfiles.d.html
Ok, missing functionality:
tmpfiles.sh:
- clean-up (age column)
- 'x' type (used only during clean-up to exclude locations from
  cleaning).

openrc:
When are the right times to call the tmpfiles code? Where in the early
boot for one, and what other times?

-- 
Robin Hugh Johnson
Gentoo Linux: Developer, Trustee & Infrastructure Lead
E-Mail     : robbat2@gentoo.org
GnuPG FP   : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85


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

* Re: [gentoo-dev] [RFC] new tmpfilesd.eclass
  2012-08-16  6:19 ` Robin H. Johnson
@ 2012-08-16  7:13   ` Sergei Trofimovich
  2012-08-16 18:47     ` Robin H. Johnson
  0 siblings, 1 reply; 9+ messages in thread
From: Sergei Trofimovich @ 2012-08-16  7:13 UTC (permalink / raw
  To: gentoo-dev; +Cc: robbat2

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

On Thu, 16 Aug 2012 06:19:55 +0000
"Robin H. Johnson" <robbat2@gentoo.org> wrote:

> On Wed, Aug 15, 2012 at 11:57:57PM +0300, Sergei Trofimovich wrote:
> > As gentoo switched to /var/run/ -> /run in tmpfs recently
> > people got into problems [1] of missing directories like:
> >     /var/run/screen/
> >     /var/run/openfire/
> >     /var/run/proftpd/
> > they did bite me personally.
> If the package has an init.d script, it should be doing creation of the
> needed dirs. I know this doesn't help screen however.

$ sudo /etc/init.d/proftpd restart
proftpd        | * Starting ProFTPD ...                                                                                  [ !! ]
proftpd        | * ERROR: proftpd failed to start

in inetd mode it's an error to attempt to start daemon.
It does create /var/run/ entry though.

> > openrc-0.10 brought [2] basic support for systemd's tmpfiles'd:
> > [2]: https://bugs.gentoo.org/show_bug.cgi?id=396003
> >   http://0pointer.de/public/systemd-man/tmpfiles.d.html
> Ok, missing functionality:
> tmpfiles.sh:
> - clean-up (age column)
> - 'x' type (used only during clean-up to exclude locations from
>   cleaning).

Another misfeature: some fields seem to be optional and tmpfiles.sh
dislikes it (example is taken from the bottom of tmpfiles.d.html).
Looks like just missing quotes in tests:

tmpfiles.d # cat screen.conf 
d /var/run/screens  1777 root root 10d
d /var/run/uscreens 0755 root root 10d12h
sf tmpfiles.d # /lib/rc/sh/tmpfiles.sh --create
/lib/rc/sh/tmpfiles.sh: 274: [: =: unexpected operator
/lib/rc/sh/tmpfiles.sh: 274: [: =: unexpected operator

-- 

  Sergei

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [gentoo-dev] [RFC] new tmpfilesd.eclass
  2012-08-15 21:25 ` Michał Górny
@ 2012-08-16  7:38   ` Sergei Trofimovich
  2012-08-16  7:47     ` Michał Górny
  0 siblings, 1 reply; 9+ messages in thread
From: Sergei Trofimovich @ 2012-08-16  7:38 UTC (permalink / raw
  To: gentoo-dev; +Cc: mgorny

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

On Wed, 15 Aug 2012 23:25:16 +0200
Michał Górny <mgorny@gentoo.org> wrote:

> On Wed, 15 Aug 2012 23:57:57 +0300
> Sergei Trofimovich <slyfox@gentoo.org> wrote:
> 
> > But there is no simple way to install such helpers from ebuilds.
> > The tmpfiles.d is aimed to help in such situations.
> 
> Yes, there is.
> 
> $ grep dotmpfiles *.eclass
> systemd.eclass:# @FUNCTION: systemd_dotmpfilesd
> systemd.eclass:systemd_dotmpfilesd() {
> 
> Well, it doesn't have a new* variant but I guess that can be added if
> necessary.

Oh, nice. What do you think of moving those helper implementations to
tmpfiles-d.eclass and make

    systemd_dotmpfilesd() { dotmpfiles_d "$@"; }

as William suggested? That way we would not impose blocker DEPENDs from
systemd.eclass to users and might help adding {do,new}tmpfiles_d to later EAPIs

> Also, maybe for some devs a easy make_tmpfiles_d() function will be
> useful too...

Yeah, it would be handier to have more freedom in file naming in ${FILESDIR}
like 'proftpd/files/tmpfiles.d-r1.conf' and not just proftpd.conf (which is the
name of server config file)

I don't care who will write/commit tmpfiles-d.eclass :]

Thanks!

-- 

  Sergei

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [gentoo-dev] [RFC] new tmpfilesd.eclass
  2012-08-16  7:38   ` Sergei Trofimovich
@ 2012-08-16  7:47     ` Michał Górny
  2012-08-16  8:18       ` Sergei Trofimovich
  0 siblings, 1 reply; 9+ messages in thread
From: Michał Górny @ 2012-08-16  7:47 UTC (permalink / raw
  To: gentoo-dev; +Cc: slyfox

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

On Thu, 16 Aug 2012 10:38:06 +0300
Sergei Trofimovich <slyfox@gentoo.org> wrote:

> On Wed, 15 Aug 2012 23:25:16 +0200
> Michał Górny <mgorny@gentoo.org> wrote:
> 
> > On Wed, 15 Aug 2012 23:57:57 +0300
> > Sergei Trofimovich <slyfox@gentoo.org> wrote:
> > 
> > > But there is no simple way to install such helpers from ebuilds.
> > > The tmpfiles.d is aimed to help in such situations.
> > 
> > Yes, there is.
> > 
> > $ grep dotmpfiles *.eclass
> > systemd.eclass:# @FUNCTION: systemd_dotmpfilesd
> > systemd.eclass:systemd_dotmpfilesd() {
> > 
> > Well, it doesn't have a new* variant but I guess that can be added
> > if necessary.
> 
> Oh, nice. What do you think of moving those helper implementations to
> tmpfiles-d.eclass and make
> 
>     systemd_dotmpfilesd() { dotmpfiles_d "$@"; }
> 
> as William suggested? That way we would not impose blocker DEPENDs
> from systemd.eclass to users and might help adding {do,new}tmpfiles_d
> to later EAPIs

These blockers do not hurt. They're against ancient systemd versions,
and they're going to be removed soon as well.

> > Also, maybe for some devs a easy make_tmpfiles_d() function will be
> > useful too...
> 
> Yeah, it would be handier to have more freedom in file naming in
> ${FILESDIR} like 'proftpd/files/tmpfiles.d-r1.conf' and not just
> proftpd.conf (which is the name of server config file)

I mean function where you wouldn't have to learn the syntax, like we
have make_desktop_entry().

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 316 bytes --]

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

* Re: [gentoo-dev] [RFC] new tmpfilesd.eclass
  2012-08-16  7:47     ` Michał Górny
@ 2012-08-16  8:18       ` Sergei Trofimovich
  0 siblings, 0 replies; 9+ messages in thread
From: Sergei Trofimovich @ 2012-08-16  8:18 UTC (permalink / raw
  To: gentoo-dev; +Cc: Michał Górny

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

> > Oh, nice. What do you think of moving those helper implementations to
> > tmpfiles-d.eclass and make
> > 
> >     systemd_dotmpfilesd() { dotmpfiles_d "$@"; }
> > 
> > as William suggested? That way we would not impose blocker DEPENDs
> > from systemd.eclass to users and might help adding {do,new}tmpfiles_d
> > to later EAPIs
> 
> These blockers do not hurt. They're against ancient systemd versions,
> and they're going to be removed soon as well.

Sounds good.

> > > Also, maybe for some devs a easy make_tmpfiles_d() function will be
> > > useful too...
> > 
> > Yeah, it would be handier to have more freedom in file naming in
> > ${FILESDIR} like 'proftpd/files/tmpfiles.d-r1.conf' and not just
> > proftpd.conf (which is the name of server config file)
> 
> I mean function where you wouldn't have to learn the syntax, like we
> have make_desktop_entry().

Ah, I see. There is not much to abstract over, but tiny wrapper for

    echo "${entry}" > "${T}/${1}".conf || die; dotmpfiles_d "${T}/${1}".conf

would make sense.

-- 

  Sergei

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [gentoo-dev] [RFC] new tmpfilesd.eclass
  2012-08-16  7:13   ` Sergei Trofimovich
@ 2012-08-16 18:47     ` Robin H. Johnson
  0 siblings, 0 replies; 9+ messages in thread
From: Robin H. Johnson @ 2012-08-16 18:47 UTC (permalink / raw
  To: gentoo-dev

On Thu, Aug 16, 2012 at 10:13:43AM +0300, Sergei Trofimovich wrote:
> Another misfeature: some fields seem to be optional and tmpfiles.sh
> dislikes it (example is taken from the bottom of tmpfiles.d.html).
> Looks like just missing quotes in tests:
> 
> tmpfiles.d # cat screen.conf 
> d /var/run/screens  1777 root root 10d
> d /var/run/uscreens 0755 root root 10d12h
> sf tmpfiles.d # /lib/rc/sh/tmpfiles.sh --create
> /lib/rc/sh/tmpfiles.sh: 274: [: =: unexpected operator
> /lib/rc/sh/tmpfiles.sh: 274: [: =: unexpected operator
Fixed in commit c870335.

The documentation http://0pointer.de/public/systemd-man/tmpfiles.d.html
is very inconsistent: it mentioned omitted for mode/uid/gid/age, but not
argument.

-- 
Robin Hugh Johnson
Gentoo Linux: Developer, Trustee & Infrastructure Lead
E-Mail     : robbat2@gentoo.org
GnuPG FP   : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85


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

end of thread, other threads:[~2012-08-16 18:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-15 20:57 [gentoo-dev] [RFC] new tmpfilesd.eclass Sergei Trofimovich
2012-08-15 21:25 ` Michał Górny
2012-08-16  7:38   ` Sergei Trofimovich
2012-08-16  7:47     ` Michał Górny
2012-08-16  8:18       ` Sergei Trofimovich
2012-08-15 22:26 ` William Hubbs
2012-08-16  6:19 ` Robin H. Johnson
2012-08-16  7:13   ` Sergei Trofimovich
2012-08-16 18:47     ` Robin H. Johnson

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