From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 5119A1381F3 for ; Sat, 13 Apr 2013 19:43:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ED737E0ABB; Sat, 13 Apr 2013 19:43:20 +0000 (UTC) Received: from mail-qa0-f46.google.com (mail-qa0-f46.google.com [209.85.216.46]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 025AFE084B for ; Sat, 13 Apr 2013 19:43:19 +0000 (UTC) Received: by mail-qa0-f46.google.com with SMTP id j8so300698qah.12 for ; Sat, 13 Apr 2013 12:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id :mail-followup-to:mime-version:content-type:content-disposition :user-agent; bh=UVnbWkp58xxmuIC3bcCKs4cUyBGY7bfoS0TTDxoT25I=; b=ZaufOO4FSi9yh/6AHSN7eD3ZvOJzf/lzG6YpgumqkMG2bJoqZiz9C/uQrZmuwJBh2r 09s3g/wn9npu7ifHCWjERpV8tBB6PqG49YJJm988ds4fUsWmOUFMzhlCxD1YTE1ZtBCI Ux/BwqQFDdmcJgWHf70r7LEuQgujaMQC97S40mjWLvKxtNWJpen/yQpwD/KdY874JzU7 PjCpZ4XbXHCkhfdnN+ra0O1NRfyp35vd/cs6TZLVAvvnBH+0+6rdEXfgfK6+mOmrExgP QsYDYO5PKNQuRs7qJeXp0dREgIYU60r5iiWMtVjvD1D/HFw21kTE4hRDkP0ycJXbnr8m NetQ== X-Received: by 10.224.195.10 with SMTP id ea10mr17000598qab.9.1365882199162; Sat, 13 Apr 2013 12:43:19 -0700 (PDT) Received: from linux1 (cpe-76-187-91-128.tx.res.rr.com. [76.187.91.128]) by mx.google.com with ESMTPS id z2sm1874862qad.4.2013.04.13.12.43.15 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 13 Apr 2013 12:43:17 -0700 (PDT) Sender: William Hubbs Received: by linux1 (sSMTP sendmail emulation); Sat, 13 Apr 2013 14:43:14 -0500 Date: Sat, 13 Apr 2013 14:43:14 -0500 From: William Hubbs To: gentoo development Cc: ssuominen@gentoo.org Subject: [gentoo-dev] new eclass: systemd-next.eclass Message-ID: <20130413194314.GA31253@linux1> Mail-Followup-To: gentoo development , ssuominen@gentoo.org Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LpQ9ahxlCli8rRTG" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Archives-Salt: bd15756f-9daa-4cb0-b004-105789c313e1 X-Archives-Hash: 30364f1bc34528ab74e47e8967a2db05 --LpQ9ahxlCli8rRTG Content-Type: multipart/mixed; boundary="2oS5YaxWCcQjTEyO" Content-Disposition: inline --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --2oS5YaxWCcQjTEyO Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="systemd-next.eclass" # 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 } --2oS5YaxWCcQjTEyO-- --LpQ9ahxlCli8rRTG Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (GNU/Linux) iEYEARECAAYFAlFptVIACgkQblQW9DDEZTjj1wCfU2JpFGX4WLsEXrawBQ7maFW0 WvkAn0GMEH+YyCcpSpr+tI7qJtGj98p1 =+Pw7 -----END PGP SIGNATURE----- --LpQ9ahxlCli8rRTG--