public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] Review for initial systemd.eclass
@ 2011-04-29  5:58 Michał Górny
  2011-04-30 21:17 ` Michał Górny
  0 siblings, 1 reply; 5+ messages in thread
From: Michał Górny @ 2011-04-29  5:58 UTC (permalink / raw
  To: gentoo-dev


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

Hello,

I'd like to submit an initial version of systemd.eclass, providing
helper functions for packages installing systemd unit files. Such
an eclass would be pushed to gx86 before first systemd packages
to control the packages installing upstream systemd units.

The eclass currently provides four functions:
- systemd_get_unitdir() which simply outputs the unitdir (for insinto),
- systemd_dounit() which installs the specified units into unitdir,
- systemd_enable_service() which symlinks service ${2} into target ${1},
  creating that target if necessary,
- systemd_with_unitdir() which outputs
  the '--with-systemdsystemunitdir' option as expected
  by systemd-capable configure scripts.

The eclass currently assumes the following:
- systemd units are installed into /$(get_libdir)/systemd/system,
- systemd units are installed unconditionally.

Though it should be possible to change that behaviour within the eclass
without modifying the ebuild files.

I'm attaching the eclass file. It is also available in my devoverlay
[1].

[1] http://git.overlays.gentoo.org/gitweb/?p=dev/mgorny.git;a=blob;f=eclass/systemd.eclass

-- 
Best regards,
Michał Górny

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

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

# @ECLASS: systemd.eclass
# @MAINTAINER:
# mgorny@gentoo.org
# @BLURB: helper functions to install systemd units
# @DESCRIPTION:
# This eclass provides a set of functions to install unit files for
# sys-apps/systemd within ebuilds.

inherit multilib

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

# @FUNCTION: systemd_get_unitdir
# @DESCRIPTION:
# Output the path for the systemd unit directory (not including ${D}).
systemd_get_unitdir() {
	debug-print-function ${FUNCNAME} "${@}"

	echo /$(get_libdir)/systemd/system
}

# @FUNCTION: systemd_dounit
# @USAGE: unit1 [...]
# @DESCRIPTION:
# Install systemd unit(s).
systemd_dounit() {
	debug-print-function ${FUNCNAME} "${@}"

	(
		insinto "$(systemd_get_unitdir)"
		doins "${@}"
	)
}

# @FUNCTION: systemd_enable_service
# @USAGE: target service
# @DESCRIPTION:
# Enable service in desired target, e.g. install a symlink for it.
systemd_enable_service() {
	debug-print-function ${FUNCNAME} "${@}"

	local target=${1}
	local service=${2}
	local ud=$(systemd_get_unitdir)

	dodir "${ud}"/"${target}".wants && \
	dosym ../"${service}" "${ud}"/"${target}".wants
}

# @FUNCTION: systemd_with_unitdir
# @DESCRIPTION:
# Output '--with-systemdsystemunitdir' as expected by systemd-aware configure
# scripts.
systemd_with_unitdir() {
	debug-print-function ${FUNCNAME} "${@}"

	echo -n --with-systemdsystemunitdir="$(systemd_get_unitdir)"
}

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

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

* Re: [gentoo-dev] Review for initial systemd.eclass
  2011-04-29  5:58 [gentoo-dev] Review for initial systemd.eclass Michał Górny
@ 2011-04-30 21:17 ` Michał Górny
  2011-05-04 10:54   ` Michał Górny
  0 siblings, 1 reply; 5+ messages in thread
From: Michał Górny @ 2011-04-30 21:17 UTC (permalink / raw
  To: gentoo-dev


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

Here's the second version.

Changes:
- switched to /lib (like upstream and udev now does),
- polished docs and added an example of use,
- added systemd_to_myeconfargs() to allow clean argument appending with
  preservation of whitespace.

-- 
Best regards,
Michał Górny

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

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

# @ECLASS: systemd.eclass
# @MAINTAINER:
# mgorny@gentoo.org
# @BLURB: helper functions to install systemd units
# @DESCRIPTION:
# This eclass provides a set of functions to install unit files for
# sys-apps/systemd within ebuilds.
# @EXAMPLE:
#
# @CODE
# inherit autotools-utils systemd
# 
# src_configure() {
#	local myeconfargs=(
#		--enable-foo
#		--disable-bar
#	)
#
#	systemd_to_myeconfargs
#	autotools-utils_src_configure
# }
# @CODE

inherit multilib

case ${EAPI:-0} in
	0|1|2|3|4) ;;
	*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
esac

# @FUNCTION: systemd_get_unitdir
# @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() {
	debug-print-function ${FUNCNAME} "${@}"

	echo -n /lib/systemd/system
}

# @FUNCTION: systemd_dounit
# @USAGE: unit1 [...]
# @DESCRIPTION:
# Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4
# and non-fatal in earlier EAPIs.
systemd_dounit() {
	debug-print-function ${FUNCNAME} "${@}"

	(
		insinto "$(systemd_get_unitdir)"
		doins "${@}"
	)
}

# @FUNCTION: systemd_enable_service
# @USAGE: target service
# @DESCRIPTION:
# Enable service in desired target, e.g. install a symlink for it.
# Uses dosym, thus it is fatal in EAPI 4 and non-fatal in earlier
# EAPIs.
systemd_enable_service() {
	debug-print-function ${FUNCNAME} "${@}"

	[[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service"

	local target=${1}
	local service=${2}
	local ud=$(systemd_get_unitdir)

	dodir "${ud}"/"${target}".wants && \
	dosym ../"${service}" "${ud}"/"${target}".wants
}

# @FUNCTION: systemd_with_unitdir
# @DESCRIPTION:
# 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
# this function.
systemd_with_unitdir() {
	debug-print-function ${FUNCNAME} "${@}"

	echo -n --with-systemdsystemunitdir="$(systemd_get_unitdir)"
}

# @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} "${@}"

	myeconfargs=(
		"${myeconfargs[@]}"
		--with-systemdsystemunitdir="$(systemd_get_unitdir)"
	)
}

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

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

* Re: [gentoo-dev] Review for initial systemd.eclass
  2011-04-30 21:17 ` Michał Górny
@ 2011-05-04 10:54   ` Michał Górny
  2011-05-04 13:56     ` Henry Gebhardt
  0 siblings, 1 reply; 5+ messages in thread
From: Michał Górny @ 2011-05-04 10:54 UTC (permalink / raw
  To: gentoo-dev

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

On Sat, 30 Apr 2011 23:17:42 +0200
Michał Górny <mgorny@gentoo.org> wrote:

> Here's the second version.

I committed this version to gx86. All packages providing systemd units
are free to use it now, yet I'm still open to comments.

-- 
Best regards,
Michał Górny

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

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

* Re: [gentoo-dev] Review for initial systemd.eclass
  2011-05-04 10:54   ` Michał Górny
@ 2011-05-04 13:56     ` Henry Gebhardt
  2011-05-04 16:15       ` Michał Górny
  0 siblings, 1 reply; 5+ messages in thread
From: Henry Gebhardt @ 2011-05-04 13:56 UTC (permalink / raw
  To: gentoo-dev

On Wed, May 04, 2011 at 12:54:45PM +0200, Michał Górny wrote:
> On Sat, 30 Apr 2011 23:17:42 +0200
> Michał Górny <mgorny@gentoo.org> wrote:
> 
> > Here's the second version.

I think the "inherit multilib" line is no longer needed.

> I committed this version to gx86. All packages providing systemd units
> are free to use it now, yet I'm still open to comments.

Does this mean we can or should file bugs like [1] and [2] against
packages? I am in particular thinking of avahi, consolekit, and soon
networkmanager.


Thanks,

Henry

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



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

* Re: [gentoo-dev] Review for initial systemd.eclass
  2011-05-04 13:56     ` Henry Gebhardt
@ 2011-05-04 16:15       ` Michał Górny
  0 siblings, 0 replies; 5+ messages in thread
From: Michał Górny @ 2011-05-04 16:15 UTC (permalink / raw
  To: gentoo-dev; +Cc: hsggebhardt

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

On Wed, 4 May 2011 15:56:32 +0200
Henry Gebhardt <hsggebhardt@googlemail.com> wrote:

> On Wed, May 04, 2011 at 12:54:45PM +0200, Michał Górny wrote:
> > On Sat, 30 Apr 2011 23:17:42 +0200
> > Michał Górny <mgorny@gentoo.org> wrote:
> > 
> > > Here's the second version.
> 
> I think the "inherit multilib" line is no longer needed.

Thanks, fixed.

> > I committed this version to gx86. All packages providing systemd
> > units are free to use it now, yet I'm still open to comments.
> 
> Does this mean we can or should file bugs like [1] and [2] against
> packages? I am in particular thinking of avahi, consolekit, and soon
> networkmanager.

I'd wait with that until these two packages get updated. Then feel free
to proceed, though I think I'll file some of them myself.

-- 
Best regards,
Michał Górny

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

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

end of thread, other threads:[~2011-05-04 16:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-29  5:58 [gentoo-dev] Review for initial systemd.eclass Michał Górny
2011-04-30 21:17 ` Michał Górny
2011-05-04 10:54   ` Michał Górny
2011-05-04 13:56     ` Henry Gebhardt
2011-05-04 16:15       ` Michał Górny

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