public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Sergei Trofimovich <slyfox@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: gentoo-dev-announce@lists.gentoo.org
Subject: [gentoo-dev] [RFC] new tmpfilesd.eclass
Date: Wed, 15 Aug 2012 23:57:57 +0300	[thread overview]
Message-ID: <20120815235757.14b3053e@sf> (raw)


[-- 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 --]

             reply	other threads:[~2012-08-15 20:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-15 20:57 Sergei Trofimovich [this message]
2012-08-15 21:25 ` [gentoo-dev] [RFC] new tmpfilesd.eclass 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120815235757.14b3053e@sf \
    --to=slyfox@gentoo.org \
    --cc=gentoo-dev-announce@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox