public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] x-modular.eclass: A modified approach to EAPI support
@ 2009-03-06 20:57 Donnie Berkholz
  2009-03-06 21:37 ` [gentoo-dev] " Christian Faulhammer
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Donnie Berkholz @ 2009-03-06 20:57 UTC (permalink / raw
  To: gentoo-dev


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

I decided to try something a little different because I had some ideas 
for improving the existing EAPI patches I've seen going into other 
eclasses. So here is my patch for x-modular.eclass. I tested it with 
ebuilds using EAPIs 0, 1, and 2, and it appeared to work fine. It 
already happened to have a function called src_configure, so that 
doesn't appear in the patch.

One thing I see as an improvement is a lack of EAPI value checks 
throughout the ebuild to avoid repetition between the function export 
and the function call. Things just check whether a function was 
exported, which is the only place where EAPI value checks happen.

Additionally, the fallback in case statements is "I don't know what to 
do" and supported EAPIs are explicitly defined. This will make it 
obvious when the eclass doesn't support a new EAPI instead of it 
randomly failing after you try it.

Any thoughts?

-- 
Thanks,
Donnie

Donnie Berkholz
Developer, Gentoo Linux
Blog: http://dberkholz.wordpress.com

[-- Attachment #1.2: x-modular.eclass.diff --]
[-- Type: text/plain, Size: 1638 bytes --]

--- /home/donnie/src/gentoo-x86/eclass/x-modular.eclass	2009-03-06 12:11:38.000000000 -0800
+++ x-modular.eclass	2009-03-06 12:16:25.000000000 -0800
@@ -26,6 +26,21 @@
 # there. You may also want to change the SLOT.
 XDIR="/usr"
 
+EXPORTED_FUNCTIONS="src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm"
+
+case "${EAPI:-0}" in
+	0|1)
+		;;
+	2)
+		EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare src_configure"
+		;;
+	*)
+		die "Unknown EAPI ${EAPI}"
+		;;
+esac
+
+EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
+
 IUSE=""
 HOMEPAGE="http://xorg.freedesktop.org/"
 
@@ -297,6 +312,15 @@
 	elibtoolize
 }
 
+# @FUNCTION: x-modular_src_prepare
+# @USAGE:
+# @DESCRIPTION:
+# Prepare a package after unpacking, performing all X-related tasks.
+x-modular_src_prepare() {
+	x-modular_patch_source
+	x-modular_reconf_source
+}
+
 # @FUNCTION: x-modular_src_unpack
 # @USAGE:
 # @DESCRIPTION:
@@ -306,8 +330,7 @@
 	x-modular_server_supports_drivers_check
 	x-modular_dri_check
 	x-modular_unpack_source
-	x-modular_patch_source
-	x-modular_reconf_source
+	has src_prepare ${EXPORTED_FUNCTIONS} || x-modular_src_prepare
 }
 
 # @FUNCTION: x-modular_font_configure
@@ -390,7 +413,7 @@
 # @DESCRIPTION:
 # Compile a package, performing all X-related tasks.
 x-modular_src_compile() {
-	x-modular_src_configure
+	has src_configure ${EXPORTED_FUNCTIONS} || x-modular_src_configure
 	x-modular_src_make
 }
 
@@ -645,5 +668,3 @@
 create_font_cache() {
 	font_pkg_postinst
 }
-
-EXPORT_FUNCTIONS src_unpack src_compile src_install pkg_preinst pkg_postinst pkg_postrm

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

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

end of thread, other threads:[~2009-03-08 22:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-06 20:57 [gentoo-dev] x-modular.eclass: A modified approach to EAPI support Donnie Berkholz
2009-03-06 21:37 ` [gentoo-dev] " Christian Faulhammer
2009-03-06 22:33 ` [gentoo-dev] " Petteri Räty
2009-03-07  7:58 ` Rémi Cardona
2009-03-07  9:50 ` Ulrich Mueller
2009-03-07 10:06   ` Nirbheek Chauhan
2009-03-08 20:23     ` Alistair Bush
2009-03-08  5:22 ` Donnie Berkholz
2009-03-08 10:38   ` David Leverton
2009-03-08 22:38     ` Zac Medico

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