public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [RFC] systemd.eclass: Patch for new function systemd_get_udevdir()
@ 2012-08-06 10:00 Samuli Suominen
  2012-08-06 10:20 ` Michał Górny
  0 siblings, 1 reply; 17+ messages in thread
From: Samuli Suominen @ 2012-08-06 10:00 UTC (permalink / raw
  To: gentoo-dev

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

Patch to avoid duplicating this code to every ebuild.

The second attachment is an example use case for the function.

Soon as this is in, I'll start mass converting the tree for this...

- Samuli

[-- Attachment #2: systemd.eclass.patch --]
[-- Type: text/x-patch, Size: 1146 bytes --]

--- systemd.eclass	2012-08-06 12:49:20.532528219 +0300
+++ /tmp/systemd.eclass	2012-08-06 12:57:28.333542735 +0300
@@ -25,6 +25,8 @@
 # }
 # @CODE
 
+inherit toolchain-funcs
+
 case ${EAPI:-0} in
 	0|1|2|3|4) ;;
 	*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
@@ -34,6 +36,31 @@
 DEPEND="!<sys-apps/systemd-29-r4
 	!=sys-apps/systemd-37-r1"
 
+# @FUNCTION: _systemd_get_udevdir
+# @INTERNAL
+# @DESCRIPTION:
+# Get unprefixed udevdir.
+_systemd_get_udevdir() {
+	if $($(tc-getPKG_CONFIG) --exists udev); then
+		echo -n "$($(tc-getPKG_CONFIG) --variable=udevdir udev)"
+	else
+		echo -n /lib/udev
+	fi
+}
+
+# @FUNCTION: systemd_get_udevdir
+# @DESCRIPTION:
+# Output the path for the udev directory (not including ${D}).
+# This function always succeeds, even if udev is not installed.
+# Dependencies need to include sys-fs/udev or otherwise
+# the fallback return value is /lib/udev.
+systemd_get_udevdir() {
+	has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
+	debug-print-function ${FUNCNAME} "${@}"
+
+	echo -n "${EPREFIX}$(_systemd_get_udevdir)"
+}
+
 # @FUNCTION: _systemd_get_unitdir
 # @INTERNAL
 # @DESCRIPTION:

[-- Attachment #3: usb_modeswitch-1.2.3_p20120531-r2.ebuild.patch --]
[-- Type: text/x-patch, Size: 965 bytes --]

--- usb_modeswitch-1.2.3_p20120531-r2.ebuild	2012-08-06 12:59:07.308545675 +0300
+++ /tmp/usb_modeswitch-1.2.3_p20120531-r2.ebuild	2012-08-06 12:46:17.556522775 +0300
@@ -3,7 +3,7 @@
 # $Header: /var/cvsroot/gentoo-x86/sys-apps/usb_modeswitch/usb_modeswitch-1.2.3_p20120531-r2.ebuild,v 1.2 2012/08/06 08:22:44 ssuominen Exp $
 
 EAPI=4
-inherit linux-info toolchain-funcs
+inherit linux-info toolchain-funcs systemd
 
 MY_PN=${PN/_/-}
 MY_P=${MY_PN}-${PV/_p*}
@@ -42,7 +42,7 @@
 src_install() {
 	emake \
 		DESTDIR="${D}" \
-		UDEVDIR="${D}/$($(tc-getPKG_CONFIG) --variable=udevdir udev)" \
+		UDEVDIR="${D}/$(systemd_get_udevdir)" \
 		install
 
 	dodoc ChangeLog README
@@ -50,7 +50,7 @@
 	pushd ../${MY_PN}-data-${DATA_VER} >/dev/null
 	emake \
 		DESTDIR="${D}" \
-		RULESDIR="${D}/$($(tc-getPKG_CONFIG) --variable=udevdir udev)/rules.d" \
+		RULESDIR="${D}/$(systemd_get_udevdir)/rules.d" \
 		files-install db-install
 	docinto data
 	dodoc ChangeLog README

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

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

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-06 10:00 [gentoo-dev] [RFC] systemd.eclass: Patch for new function systemd_get_udevdir() Samuli Suominen
2012-08-06 10:20 ` Michał Górny
2012-08-06 10:37   ` Samuli Suominen
2012-08-06 10:42     ` Fabian Groffen
2012-08-06 11:02       ` Samuli Suominen
2012-08-06 11:20         ` Fabian Groffen
2012-08-06 11:49       ` Rich Freeman
2012-08-06 11:56         ` Fabian Groffen
2012-08-06 12:05           ` Rich Freeman
2012-08-06 12:15             ` Michał Górny
2012-08-06 18:16           ` Olivier Crête
2012-08-06 18:28             ` Fabian Groffen
2012-08-06 18:40               ` Olivier Crête
2012-08-06 18:44                 ` Fabian Groffen
2012-08-06 12:10         ` Michał Górny
2012-08-06 11:10   ` Samuli Suominen
2012-08-06 11:44   ` Rich Freeman

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