From: William Hubbs <williamh@gentoo.org>
To: gentoo development <gentoo-dev@lists.gentoo.org>
Cc: ssuominen@gentoo.org
Subject: [gentoo-dev] new eclass: systemd-next.eclass
Date: Sat, 13 Apr 2013 14:43:14 -0500 [thread overview]
Message-ID: <20130413194314.GA31253@linux1> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 564 bytes --]
All,
this eclass is an alternative to systemd.eclass, and maintains
full compatibility with it; however, it expands it so that it can query
pkgconfig for the directory paths. It returns the same default paths as
systemd.eclass if there is an error with pkgconfig.
I am sending this out for review so we can commit it to the tree
when we commit our alternate systemd ebuild in a few days. This will be
set up so that users can choose which systemd package they want to
install, and it will default to the current systemd package.
Thanks,
the systemd-next team
[-- Attachment #1.2: systemd-next.eclass --]
[-- Type: text/plain, Size: 7287 bytes --]
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.22 2013/03/18 06:29:03 mgorny Exp $
# @ECLASS: systemd-next.eclass
# @MAINTAINER:
# williamh@gentoo.org
# ssuominen@gentoo.org
# @BLURB: helper functions to install systemd units
# @DESCRIPTION:
# This eclass provides a set of functions to install unit files for
# systemd within ebuilds. It maintains compatibility with
# systemd.eclass by default, but it also allows querying pkgconfig.
#
# @EXAMPLE:
#
# @CODE
# inherit autotools-utils systemd-next
#
# src_configure() {
# local myeconfargs=(
# --enable-foo
# --disable-bar
# )
#
# systemd_to_myeconfargs
# autotools-utils_src_configure
# }
# @CODE
inherit toolchain-funcs
case ${EAPI:-0} in
0|1|2|3|4|5) ;;
*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
esac
DEPEND="virtual/pkgconfig"
# @FUNCTION: _systemd_get_unitdir
# @INTERNAL
# @DESCRIPTION:
# Get unprefixed unitdir.
_systemd_get_unitdir() {
if $($(tc-getPKG_CONFIG) --exists systemd); then
echo "$($(tc-getPKG_CONFIG) --variable=systemdsystemunitdir systemd)"
else
echo /usr/lib/systemd/system
fi
}
# @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() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_systemd_get_unitdir)"
}
# @FUNCTION: _systemd_get_userunitdir
# @INTERNAL
# @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
}
# @FUNCTION: systemd_get_userunitdir
# @DESCRIPTION:
# Output the path for the systemd user unit directory (not including
# ${D}). This function always succeeds, even if systemd is not
# installed.
systemd_get_userunitdir() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_systemd_get_userunitdir)"
}
# @FUNCTION: _systemd_get_utildir
# @INTERNAL
# @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
}
# @FUNCTION: systemd_get_utildir
# @DESCRIPTION:
# Output the path for the systemd utility directory (not including
# ${D}). This function always succeeds, even if systemd is not
# installed.
systemd_get_utildir() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_systemd_get_utildir)"
}
# @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} "${@}"
local INSDESTTREE
insinto "$(_systemd_get_unitdir)"
doins "${@}"
}
# @FUNCTION: systemd_newunit
# @USAGE: oldname newname
# @DESCRIPTION:
# Install systemd unit with a new name. Uses newins, thus it is fatal
# in EAPI 4 and non-fatal in earlier EAPIs.
systemd_newunit() {
debug-print-function ${FUNCNAME} "${@}"
local INSDESTTREE
insinto "$(_systemd_get_unitdir)"
newins "${@}"
}
# @FUNCTION: systemd_dotmpfilesd
# @USAGE: tmpfilesd1 [...]
# @DESCRIPTION:
# Install systemd tmpfiles.d files. Uses doins, thus it is fatal
# in EAPI 4 and non-fatal in earlier EAPIs.
systemd_dotmpfilesd() {
debug-print-function ${FUNCNAME} "${@}"
for f; do
[[ ${f} == *.conf ]] \
|| die 'tmpfiles.d files need to have .conf suffix.'
done
local INSDESTTREE
insinto /usr/lib/tmpfiles.d/
doins "${@}"
}
# @FUNCTION: systemd_newtmpfilesd
# @USAGE: oldname newname.conf
# @DESCRIPTION:
# Install systemd tmpfiles.d file under a new name. Uses newins, thus it
# is fatal in EAPI 4 and non-fatal in earlier EAPIs.
systemd_newtmpfilesd() {
debug-print-function ${FUNCNAME} "${@}"
[[ ${2} == *.conf ]] \
|| die 'tmpfiles.d files need to have .conf suffix.'
local INSDESTTREE
insinto /usr/lib/tmpfiles.d/
newins "${@}"
}
# @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)
local destname=$(basename "${service}")
dodir "${ud}"/"${target}".wants && \
dosym ../"${service}" "${ud}"/"${target}".wants/"${destname}"
}
# @FUNCTION: systemd_with_unitdir
# @USAGE: [configure option]
# @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. If you are using autotools-utils,
# systemd_to_myeconfargs() is preferred over this function.
#
# If upstream uses an invalid configure option to handle installing systemd
# units (e.g. `--with-systemdunitdir'), you can pass the 'suffix' as an optional
# argument to this function (`$(systemd_with_unitdir systemdunitdir)'). Please
# remember to report a bug upstream as well.
systemd_with_unitdir() {
debug-print-function ${FUNCNAME} "${@}"
local optname=${1:-systemdsystemunitdir}
echo --with-${optname}="$(systemd_get_unitdir)"
}
# @FUNCTION: systemd_with_utildir
# @DESCRIPTION:
# 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() {
debug-print-function ${FUNCNAME} "${@}"
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} "${@}"
myeconfargs=(
"${myeconfargs[@]}"
--with-systemdsystemunitdir="$(systemd_get_unitdir)"
)
}
# @FUNCTION: systemd_update_catalog
# @DESCRIPTION:
# Update the journald catalog. This needs to be called after installing
# or removing catalog files.
#
# If systemd is not installed, no operation will be done. The catalog
# will be (re)built once systemd is installed.
#
# See: http://www.freedesktop.org/wiki/Software/systemd/catalog
systemd_update_catalog() {
debug-print-function ${FUNCNAME} "${@}"
# Make sure to work on the correct system.
local journalctl
if [[ -x ${EPREFIX}/usr/bin/journalctl ]]; then
journalctl="${EPREFIX}/usr/bin/journalctl"
elif [[ -x ${EPREFIX}/bin/journalctl ]]; then
journalctl="${EPREFIX}"/bin/journalctl
fi
if [[ -x ${journalctl} ]]; then
ebegin "Updating systemd journal catalogs"
journalctl --update-catalog
eend $?
else
debug-print "${FUNCNAME}: journalctl not found."
fi
}
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
next reply other threads:[~2013-04-13 19:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-13 19:43 William Hubbs [this message]
2013-04-13 20:15 ` [gentoo-dev] new eclass: systemd-next.eclass Rich Freeman
2013-04-13 20:41 ` Diego Elio Pettenò
2013-04-13 20:57 ` William Hubbs
2013-04-13 21:22 ` Rich Freeman
2013-04-13 21:27 ` Michał Górny
2013-04-13 21:30 ` William Hubbs
2013-04-13 23:41 ` Markos Chandras
2013-04-14 0:49 ` William Hubbs
2013-04-14 5:47 ` Michał Górny
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=20130413194314.GA31253@linux1 \
--to=williamh@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
--cc=ssuominen@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