public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Peter Alfredsen <loki_val@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev]  Re: Proposed change to base.eclass: EAPI-2 support
Date: Mon, 3 Nov 2008 21:53:55 +0200	[thread overview]
Message-ID: <200811032053.59249.loki_val@gentoo.org> (raw)
In-Reply-To: <gemcq9$ac8$1@ger.gmane.org>


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

On Monday 03 November 2008, Steve Long wrote:
> Peter Alfredsen wrote:
> > debug-print-function $FUNCNAME $*
>
> You should be using "$@" not unquoted $*.

Fixed. Also fixed base_src_unpack and base_src_compile calling their 
grunt functions with $1, when clearly it should have been $@.

> Seems like the FUNCNAME bit should just be rolled into the function
> with "${FUNCNAME[1]}" which could be done tree-wide quite easily.

I guess that function was written before bash-3 when FUNCNAME was turned 
into an array.


-- 
/PA

[-- Attachment #1.2: base.eclass.patch --]
[-- Type: text/x-diff, Size: 4230 bytes --]

--- /usr/portage/eclass/base.eclass	2008-07-17 12:06:27.000000000 +0200
+++ base.eclass	2008-11-03 20:45:44.000000000 +0100
@@ -2,32 +2,78 @@
 # Distributed under the terms of the GNU General Public License v2
 # $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.34 2008/07/17 09:49:14 pva Exp $
 
 # @ECLASS: base.eclass
 # @MAINTAINER:
-# ???
+# Peter Alfredsen <loki_val@gentoo.org>
 #
 # Original author Dan Armak <danarmak@gentoo.org>
 # @BLURB: The base eclass defines some default functions and variables.
 # @DESCRIPTION:
 # The base eclass defines some default functions and variables. Nearly
 # everything else inherits from here.
+#
+# NOTE: You must define EAPI before inheriting from base, or the wrong functions
+# may be exported.
 
 
 inherit eutils
 
+case "${EAPI:-0}" in
+	2)
+		EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
+		;;
+	*)
+		EXPORT_FUNCTIONS src_unpack src_compile src_install
+		;;
+esac
+
 DESCRIPTION="Based on the $ECLASS eclass"
 
 # @FUNCTION: base_src_unpack
 # @USAGE: [ unpack ] [ patch ] [ autopatch ] [ all ]
 # @DESCRIPTION:
 # The base src_unpack function, which is exported. If no argument is given,
-# "all" is assumed.
+# "all" is assumed if EAPI!=2, "unpack" if EAPI=2.
 base_src_unpack() {
 
-	debug-print-function $FUNCNAME $*
-	[ -z "$1" ] && base_src_unpack all
+	debug-print-function $FUNCNAME "$@"
+
+	if [ -z "$1" ]
+	then
+		case "${EAPI:-0}" in
+			2)
+				base_src_util unpack
+				;;
+			*)
+				base_src_util all
+				;;
+		esac
+	else
+		base_src_util $@
+	fi
+}
+
+# @FUNCTION: base_src_prepare
+# @DESCRIPTION:
+# The base src_prepare function, which is exported when EAPI=2. Performs
+# "base_src_util autopatch".
+base_src_prepare() {
+
+	debug-print-function $FUNCNAME "$@"
+
+	base_src_util autopatch
+}
+
+# @FUNCTION: base_src_util
+# @USAGE: [ unpack ] [ patch ] [ autopatch ] [ all ]
+# @DESCRIPTION:
+# The base_src_util function is the grunt function for base src_unpack
+# and base src_prepare.
+base_src_util() {
+
+	debug-print-function $FUNCNAME "$@"
 
 	cd "${WORKDIR}"
 
 	while [ "$1" ]; do
 
@@ -57,28 +103,62 @@
 				done
 			fi
 			;;
 		all)
 			debug-print-section all
-			base_src_unpack unpack autopatch
+			base_src_util unpack autopatch
 			;;
 		esac
 
 	shift
 	done
 
 }
 
+# @FUNCTION: base_src_configure
+# @DESCRIPTION:
+# The base src_prepare function, which is exported when EAPI=2. Performs
+# "base_src_work configure".
+base_src_configure() {
+
+	debug-print-function $FUNCNAME "$@"
+
+	base_src_work configure
+}
+
 # @FUNCTION: base_src_compile
 # @USAGE: [ configure ] [ make ] [ all ]
 # @DESCRIPTION:
 # The base src_compile function, which is exported. If no argument is given,
-# "all" is asasumed.
+# "all" is assumed if EAPI!=2, "make" if EAPI=2.
 base_src_compile() {
 
-	debug-print-function $FUNCNAME $*
-	[ -z "$1" ] && base_src_compile all
+	debug-print-function $FUNCNAME "$@"
+
+	if [ -z "$1" ]
+	then
+		case "${EAPI:-0}" in
+			2)
+				base_src_work make
+				;;
+			*)
+				base_src_work all
+				;;
+		esac
+	else
+		base_src_work $@
+	fi
+}
+
+# @FUNCTION: base_src_work
+# @USAGE: [ configure ] [ make ] [ all ]
+# @DESCRIPTION:
+# The base_src_work function is the grunt function for base src_configure
+# and base src_compile.
+base_src_work() {
+
+	debug-print-function $FUNCNAME "$@"
 
 	cd "${S}"
 
 	while [ "$1" ]; do
 
@@ -91,11 +171,11 @@
 			debug-print-section make
 			emake || die "died running emake, $FUNCNAME:make"
 			;;
 		all)
 			debug-print-section all
-			base_src_compile configure make
+			base_src_work configure make
 			;;
 	esac
 
 	shift
 	done
@@ -107,11 +187,11 @@
 # @DESCRIPTION:
 # The base src_install function, which is exported. If no argument is given,
 # "all" is assumed.
 base_src_install() {
 
-	debug-print-function $FUNCNAME $*
+	debug-print-function $FUNCNAME "$@"
 	[ -z "$1" ] && base_src_install all
 
 	cd "${S}"
 
 	while [ "$1" ]; do
@@ -129,7 +209,5 @@
 
 	shift
 	done
 
 }
-
-EXPORT_FUNCTIONS src_unpack src_compile src_install

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

  reply	other threads:[~2008-11-03 19:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-02 22:08 [gentoo-dev] Proposed change to base.eclass: EAPI-2 support Peter Alfredsen
2008-11-02 22:23 ` Peter Alfredsen
2008-11-03  4:49 ` Donnie Berkholz
2008-11-03  4:51   ` Donnie Berkholz
2008-11-03  6:00   ` Peter Alfredsen
2008-11-03  8:29     ` [gentoo-dev] " Steve Long
2008-11-03 19:53       ` Peter Alfredsen [this message]
2008-11-05 18:26         ` Thomas Sachau
2008-11-05 18:45           ` Peter Alfredsen
2008-11-05 20:20             ` Thomas Sachau
2008-11-05 20:54               ` Ciaran McCreesh
2008-11-05 23:06               ` Thomas Anderson
2008-11-06  1:27               ` Thomas Rösner
2008-11-06 13:41                 ` Duncan
2008-11-06  3:07               ` Javier Villavicencio
2008-11-09 15:47 ` [gentoo-dev] " Peter Alfredsen

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=200811032053.59249.loki_val@gentoo.org \
    --to=loki_val@gentoo.org \
    --cc=gentoo-dev@lists.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