Gentoo Logo
Gentoo Spaceship




Note: Due to technical difficulties, the Archives are currently not up to date. GMANE provides an alternative service for most mailing lists.
c.f. bug 424647
List Archive: gentoo-commits
Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Headers:
To: gentoo-commits@g.o
From: "Zac Medico (zmedico)" <zmedico@g.o>
Subject: portage r11327 - in main/trunk: bin pym/_emerge pym/portage
Date: Mon, 04 Aug 2008 17:54:14 +0000
Author: zmedico
Date: 2008-08-04 17:54:12 +0000 (Mon, 04 Aug 2008)
New Revision: 11327

Modified:
   main/trunk/bin/ebuild
   main/trunk/bin/ebuild.sh
   main/trunk/bin/isolated-functions.sh
   main/trunk/pym/_emerge/__init__.py
   main/trunk/pym/portage/__init__.py
   main/trunk/pym/portage/const.py
Log:
Bug #233735 - Add support for src_configure and default_* functions with
new EAPI=2_pre2. Thanks to Arfrever Frehtes Taifersar Arahesis for the
initial patch which I've made a few adjustments to.


Modified: main/trunk/bin/ebuild
===================================================================
--- main/trunk/bin/ebuild	2008-08-04 15:46:24 UTC (rev 11326)
+++ main/trunk/bin/ebuild	2008-08-04 17:54:12 UTC (rev 11327)
@@ -182,7 +182,7 @@
 	tmpsettings.backup_changes("EBUILD_SKIP_MANIFEST")
 	portage._doebuild_manifest_exempt_depend += 1
 
-build_dir_phases = set(["setup", "unpack", "compile",
+build_dir_phases = set(["setup", "unpack", "configure", "compile",
 	"test", "install", "package", "rpm"])
 
 def stale_env_warning():

Modified: main/trunk/bin/ebuild.sh
===================================================================
--- main/trunk/bin/ebuild.sh	2008-08-04 15:46:24 UTC (rev 11326)
+++ main/trunk/bin/ebuild.sh	2008-08-04 17:54:12 UTC (rev 11327)
@@ -583,7 +583,7 @@
 	fi
 }
 
-pkg_nofetch() {
+_default_pkg_nofetch() {
 	[ -z "${SRC_URI}" ] && return
 
 	echo "!!! The following are listed in SRC_URI for ${PN}:"
@@ -593,22 +593,25 @@
 	done
 }
 
-src_unpack() {
+_default_src_unpack() {
 	[[ -n ${A} ]] && unpack ${A}
 }
 
-src_compile() {
+_default_src_configure() {
 	if [ "${EAPI:-0}" == 0 ] ; then
 		[ -x ./configure ] && econf
 	elif [ -x "${ECONF_SOURCE:-.}/configure" ] ; then
 		econf
 	fi
+}
+
+_default_src_compile() {
 	if [ -f Makefile ] || [ -f GNUmakefile ] || [ -f makefile ]; then
 		emake || die "emake failed"
 	fi
 }
 
-src_test() {
+_default_src_test() {
 	if emake -j1 check -n &> /dev/null; then
 		vecho ">>> Test phase [check]: ${CATEGORY}/${PF}"
 		if ! emake -j1 check; then
@@ -626,6 +629,25 @@
 	fi
 }
 
+pkg_nofetch() {
+	_default_pkg_nofetch
+}
+
+src_unpack() {
+	_default_src_unpack
+}
+
+src_compile() {
+	hasq "$EAPI" 0 1 2_pre1 && \
+		_default_src_configure
+
+	_default_src_compile
+}
+
+src_test() {
+	_default_src_test
+}
+
 ebuild_phase() {
 	[ "$(type -t ${1})" == "function" ] && qa_call ${1}
 }
@@ -822,6 +844,12 @@
 	trap SIGINT SIGQUIT
 }
 
+abort_configure() {
+	abort_handler src_configure $1
+	rm -f "$PORTAGE_BUILDDIR/.configured"
+	exit 1
+}
+
 abort_compile() {
 	abort_handler "src_compile" $1
 	rm -f "${PORTAGE_BUILDDIR}/.compiled"
@@ -840,72 +868,45 @@
 	exit 1
 }
 
-dyn_compile() {
-	trap "abort_compile" SIGINT SIGQUIT
+dyn_configure() {
+	hasq "$EAPI" 0 1 2_pre1 && return 0
 
-	[ "$(type -t pre_src_compile)" == "function" ] && qa_call pre_src_compile
+	if [[ $PORTAGE_BUILDDIR/.configured -nt $WORKDIR ]] ; then
+		vecho ">>> It appears that '$PF' is already configured; skipping."
+		vecho ">>> Remove '$PORTAGE_BUILDDIR/.configured' to force configuration."
+		return 0
+	fi
 
-	[ "${CFLAGS-unset}"      != "unset" ] && export CFLAGS
-	[ "${CXXFLAGS-unset}"    != "unset" ] && export CXXFLAGS
-	[ "${LIBCFLAGS-unset}"   != "unset" ] && export LIBCFLAGS
-	[ "${LIBCXXFLAGS-unset}" != "unset" ] && export LIBCXXFLAGS
-	[ "${LDFLAGS-unset}"     != "unset" ] && export LDFLAGS
-	[ "${ASFLAGS-unset}"     != "unset" ] && export ASFLAGS
+	trap abort_configure SIGINT SIGQUIT
 
-	[ "${CCACHE_DIR-unset}"  != "unset" ] && export CCACHE_DIR
-	[ "${CCACHE_SIZE-unset}" != "unset" ] && export CCACHE_SIZE
+	[[ $(type -t pre_src_configure) = function ]] && \
+		qa_call pre_src_configure
 
-	[ "${DISTCC_DIR-unset}"  == "unset" ] && export DISTCC_DIR="${PORTAGE_TMPDIR}/.distcc"
-	[ ! -z "${DISTCC_DIR}" ] && addwrite "${DISTCC_DIR}"
+	vecho ">>> Configuring source in $srcdir ..."
+	ebuild_phase src_configure
+	vecho ">>> Source configured."
+	#|| abort_configure "fail"
+	cd "$PORTAGE_BUILDDIR"
+	touch .configured
+	[[ $(type -t post_src_configure) = function ]] && \
+		qa_call post_src_configure
 
-	LIBDIR_VAR="LIBDIR_${ABI}"
-	if [ -z "${PKG_CONFIG_PATH}" -a -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then
-		export PKG_CONFIG_PATH="/usr/${!LIBDIR_VAR}/pkgconfig"
-	fi
-	unset LIBDIR_VAR
+	trap SIGINT SIGQUIT
+}
 
-	if hasq noauto $FEATURES && [ ! -f ${PORTAGE_BUILDDIR}/.unpacked ]; then
-		echo
-		echo "!!! We apparently haven't unpacked... This is probably not what you"
-		echo "!!! want to be doing... You are using FEATURES=noauto so I'll assume"
-		echo "!!! that you know what you are doing... You have 5 seconds to abort..."
-		echo
+dyn_compile() {
 
-		local x
-		for x in 1 2 3 4 5 6 7 8; do
-			echo -ne "\a"
-			LC_ALL=C sleep 0.25
-		done
-
-		sleep 3
+	if [[ $PORTAGE_BUILDDIR/.compiled -nt $WORKDIR ]] ; then
+		vecho ">>> It appears that '${PF}' is already compiled; skipping."
+		vecho ">>> Remove '$PORTAGE_BUILDDIR/.compiled' to force compilation."
+		return 0
 	fi
 
-	local srcdir=${PORTAGE_BUILDDIR}
-	cd "${PORTAGE_BUILDDIR}"
-	if [ ! -e "build-info" ]; then
-		mkdir build-info
-	fi
-	cp "${EBUILD}" "build-info/${PF}.ebuild"
+	trap abort_compile SIGINT SIGQUIT
 
-	if [[ ${PORTAGE_BUILDDIR}/.compiled -nt ${WORKDIR} ]] ; then
-		vecho ">>> It appears that '${PF}' is already compiled; skipping."
-		vecho ">>> Remove '${PORTAGE_BUILDDIR}/.compiled' to force compilation."
-		trap SIGINT SIGQUIT
-		[ "$(type -t post_src_compile)" == "function" ] && qa_call post_src_compile
-		return
-	fi
-	if [ -d "${S}" ]; then
-		srcdir=${S}
-	else
-		srcdir=${WORKDIR}
-	fi
-	cd "${srcdir}"
-	#our custom version of libtool uses $S and $D to fix
-	#invalid paths in .la files
-	export S D
-	#some packages use an alternative to $S to build in, cause
-	#our libtool to create problematic .la files
-	export PWORKDIR="$WORKDIR"
+	[[ $(type -t pre_src_compile) = function ]] && \
+		qa_call pre_src_compile
+
 	vecho ">>> Compiling source in ${srcdir} ..."
 	ebuild_phase src_compile
 	vecho ">>> Source compiled."
@@ -1059,8 +1060,9 @@
 	echo "  digest      : create a manifest file for the package"
 	echo "  manifest    : create a manifest file for the package"
 	echo "  unpack      : unpack/patch sources (auto-fetch if needed)"
-	echo "  compile     : compile sources (auto-fetch/unpack if needed)"
-	echo "  test        : test package (auto-fetch/unpack/compile if needed)"
+	echo "  configure   : configure sources (auto-fetch/unpack if needed)"
+	echo "  compile     : compile sources (auto-fetch/unpack/configure if needed)"
+	echo "  test        : test package (auto-fetch/unpack/configure/compile if needed)"
 	echo "  preinst     : execute pre-install instructions"
 	echo "  postinst    : execute post-install instructions"
 	echo "  install     : install the package to the temporary install directory"
@@ -1350,13 +1352,39 @@
 	PATH="${stripped_path}"
 }
 
+# @FUNCTION: source_all_bashrcs
+# @DESCRIPTION:
+# Source a relevant bashrc files and perform other miscellaneous
+# environment initialization when appropriate:
+#
+#  * If EAPI is set, define default_* functions provided by the current EAPI.
+#
 source_all_bashrcs() {
 	[ -n "$EBUILD_PHASE" ] || return
+	local x
+	local default_phases="pkg_nofetch src_unpack src_configure
+		src_compile src_test"
+
+	if [[ -n $EAPI ]] && ! hasq "$EAPI" 0 1 2_pre1 ; then
+		for x in $default_phases ; do
+			eval "default_$x() { _default_$x \"\$@\" ; }"
+		done
+
+		[[ $(type -t src_configure) = function ]] || \
+			src_configure() { _default_src_configure "$@" ; }
+
+	else
+		for x in $default_phases ; do
+			eval "default_$x() {
+				die \"default_$x() is not supported with EAPI='$EAPI'\"
+			}"
+		done
+	fi
+
 	local OCC="${CC}" OCXX="${CXX}"
 	# source the existing profile.bashrc's.
 	save_IFS
 	IFS=$'\n'
-	local x
 	for x in ${PROFILE_PATHS}; do
 		# Must unset it so that it doesn't mess up assumptions in the RCs.
 		unset IFS
@@ -1717,6 +1745,10 @@
 		debug-print "RDEPEND: not set... Setting to: ${DEPEND}"
 	fi
 
+	# Set default EAPI if necessary, so that most
+	# code can simply assume that it's defined.
+	[[ -n $EAPI ]] || EAPI=0
+
 	# add in dependency info from eclasses
 	IUSE="${IUSE} ${E_IUSE}"
 	DEPEND="${DEPEND} ${E_DEPEND}"
@@ -1756,7 +1788,11 @@
 	declare -r ${READONLY_EBUILD_METADATA} ${READONLY_PORTAGE_VARS}
 fi
 
-if [ -n "${EBUILD_SH_ARGS}" ] ; then
+ebuild_main() {
+	local f x
+	local export_vars="ASFLAGS CCACHE_DIR CCACHE_SIZE
+		CFLAGS CXXFLAGS LDFLAGS LIBCFLAGS LIBCXXFLAGS"
+
 	case ${EBUILD_SH_ARGS} in
 	nofetch)
 		ebuild_phase_with_hooks pkg_nofetch
@@ -1786,12 +1822,71 @@
 			)
 		fi
 		;;
-	unpack|compile|test|clean|install)
-		if [ "${SANDBOX_DISABLED="0"}" == "0" ]; then
+	unpack|configure|compile|test|clean|install)
+		if [[ ${SANDBOX_DISABLED:-0} = 0 ]] ; then
 			export SANDBOX_ON="1"
 		else
 			export SANDBOX_ON="0"
 		fi
+
+		case "$EBUILD_SH_ARGS" in
+		configure|compile)
+
+			for x in $export_vars ; do
+				[[ ${!x-unset} != unset ]] && export $x
+			done
+
+			hasq distcc $FEATURES && [[ -n $DISTCC_DIR ]] && \
+				[[ ${SANDBOX_WRITE/$DISTCC_DIR} = $SANDBOX_WRITE ]] && \
+				addwrite "$DISTCC_DIR"
+
+			x=LIBDIR_$ABI
+			[ -z "$PKG_CONFIG_PATH" -a -n "$ABI" -a -n "${!x}" ] && \
+				export PKG_CONFIG_PATH=/usr/${!x}/pkgconfig
+
+			if hasq noauto $FEATURES && \
+				[[ ! -f $PORTAGE_BUILDDIR/.unpacked ]] ; then
+				echo
+				echo "!!! We apparently haven't unpacked..." \
+					"This is probably not what you"
+				echo "!!! want to be doing... You are using" \
+					"FEATURES=noauto so I'll assume"
+				echo "!!! that you know what you are doing..." \
+					"You have 5 seconds to abort..."
+				echo
+
+				local x
+				for x in 1 2 3 4 5 6 7 8; do
+					echo -ne "\a"
+					LC_ALL=C sleep 0.25
+				done
+
+				sleep 3
+			fi
+
+			cd "$PORTAGE_BUILDDIR"
+			if [ ! -d build-info ] ; then
+				mkdir build-info
+				cp "$EBUILD" "build-info/$PF.ebuild"
+			fi
+
+			local srcdir
+			if [[ -d $S ]] ; then
+				srcdir=$S
+			else
+				srcdir=$WORKDIR
+			fi
+			cd "$srcdir"
+			#our custom version of libtool uses $S and $D to fix
+			#invalid paths in .la files
+			export S D
+			#some packages use an alternative to $S to build in, cause
+			#our libtool to create problematic .la files
+			export PWORKDIR=$WORKDIR
+
+			;;
+		esac
+
 		if [ "${PORTAGE_DEBUG}" != "1" ] || [ "${-/x/}" != "$-" ]; then
 			dyn_${EBUILD_SH_ARGS}
 		else
@@ -1857,8 +1952,10 @@
 	esac
 	[ -n "${EBUILD_EXIT_STATUS_FILE}" ] && \
 		touch "${EBUILD_EXIT_STATUS_FILE}" &>/dev/null
-fi
+}
 
+[[ -n $EBUILD_SH_ARGS ]] && ebuild_main
+
 # Save the env only for relevant phases.
 if [ -n "${EBUILD_SH_ARGS}" ] && \
 	! hasq ${EBUILD_SH_ARGS} clean depend help info nofetch ; then

Modified: main/trunk/bin/isolated-functions.sh
===================================================================
--- main/trunk/bin/isolated-functions.sh	2008-08-04 15:46:24 UTC (rev 11326)
+++ main/trunk/bin/isolated-functions.sh	2008-08-04 17:54:12 UTC (rev 11327)
@@ -499,13 +499,16 @@
 			best_version use_with use_enable register_die_hook check_KV \
 			keepdir unpack strip_duplicate_slashes econf einstall \
 			dyn_setup dyn_unpack dyn_clean into insinto exeinto docinto \
-			insopts diropts exeopts libopts abort_handler abort_compile \
-			abort_test abort_install dyn_compile dyn_test dyn_install \
+			insopts diropts exeopts libopts \
+			abort_handler abort_configure abort_compile \
+			abort_test abort_install dyn_configure \
+			dyn_compile dyn_test dyn_install \
 			dyn_preinst dyn_help debug-print debug-print-function \
 			debug-print-section inherit EXPORT_FUNCTIONS newdepend newrdepend \
 			newpdepend do_newdepend remove_path_entry \
 			save_ebuild_env filter_readonly_variables preprocess_ebuild_env \
-			source_all_bashrcs ebuild_phase ebuild_phase_with_hooks \
+			source_all_bashrcs ebuild_main \
+			ebuild_phase ebuild_phase_with_hooks \
 			${QA_INTERCEPTORS}
 
 		# portage config variables and variables set directly by portage

Modified: main/trunk/pym/_emerge/__init__.py
===================================================================
--- main/trunk/pym/_emerge/__init__.py	2008-08-04 15:46:24 UTC (rev 11326)
+++ main/trunk/pym/_emerge/__init__.py	2008-08-04 17:54:12 UTC (rev 11327)
@@ -2587,7 +2587,7 @@
 
 	__slots__ = ("pkg", "scheduler", "settings") + ("_tree",)
 
-	_phases = ("compile", "test", "install")
+	_phases = ("configure", "compile", "test", "install")
 
 	_live_eclasses = frozenset([
 		"cvs",

Modified: main/trunk/pym/portage/__init__.py
===================================================================
--- main/trunk/pym/portage/__init__.py	2008-08-04 15:46:24 UTC (rev 11326)
+++ main/trunk/pym/portage/__init__.py	2008-08-04 17:54:12 UTC (rev 11327)
@@ -4544,8 +4544,10 @@
 
 def eapi_is_supported(eapi):
 	eapi = str(eapi).strip()
-	if eapi == "2_pre1":
+
+	if eapi in ("2_pre2", "2_pre1"):
 		return True
+
 	try:
 		eapi = int(eapi)
 	except ValueError:
@@ -5042,7 +5044,8 @@
 	actionmap_deps={
 	"setup":  [],
 	"unpack": ["setup"],
-	"compile":["unpack"],
+	"configure": ["unpack"],
+	"compile":["configure"],
 	"test":   ["compile"],
 	"install":["test"],
 	"rpm":    ["install"],
@@ -5063,7 +5066,8 @@
 	validcommands = ["help","clean","prerm","postrm","cleanrm","preinst","postinst",
 	                "config", "info", "setup", "depend",
 	                "fetch", "fetchall", "digest",
-	                "unpack","compile","test","install","rpm","qmerge","merge",
+	                "unpack", "configure", "compile", "test",
+	                "install", "rpm", "qmerge", "merge",
 	                "package","unmerge", "manifest"]
 
 	if mydo not in validcommands:
@@ -5617,13 +5621,14 @@
 
 		# args are for the to spawn function
 		actionmap = {
-"setup":  {"cmd":ebuild_sh, "args":{"droppriv":0,        "free":1,         "sesandbox":0,         "fakeroot":0}},
-"unpack": {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":0,         "sesandbox":sesandbox, "fakeroot":0}},
-"compile":{"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}},
-"test":   {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}},
-"install":{"cmd":ebuild_sh, "args":{"droppriv":0,        "free":0,         "sesandbox":sesandbox, "fakeroot":fakeroot}},
-"rpm":    {"cmd":misc_sh,   "args":{"droppriv":0,        "free":0,         "sesandbox":0,         "fakeroot":fakeroot}},
-"package":{"cmd":misc_sh,   "args":{"droppriv":0,        "free":0,         "sesandbox":0,         "fakeroot":fakeroot}},
+"setup":    {"cmd":ebuild_sh, "args":{"droppriv":0,        "free":1,         "sesandbox":0,         "fakeroot":0}},
+"unpack":   {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":0,         "sesandbox":sesandbox, "fakeroot":0}},
+"configure":{"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}},
+"compile":  {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}},
+"test":     {"cmd":ebuild_sh, "args":{"droppriv":droppriv, "free":nosandbox, "sesandbox":sesandbox, "fakeroot":0}},
+"install":  {"cmd":ebuild_sh, "args":{"droppriv":0,        "free":0,         "sesandbox":sesandbox, "fakeroot":fakeroot}},
+"rpm":      {"cmd":misc_sh,   "args":{"droppriv":0,        "free":0,         "sesandbox":0,         "fakeroot":fakeroot}},
+"package":  {"cmd":misc_sh,   "args":{"droppriv":0,        "free":0,         "sesandbox":0,         "fakeroot":fakeroot}},
 		}
 
 		# merge the deps in so we have again a 'full' actionmap

Modified: main/trunk/pym/portage/const.py
===================================================================
--- main/trunk/pym/portage/const.py	2008-08-04 15:46:24 UTC (rev 11326)
+++ main/trunk/pym/portage/const.py	2008-08-04 17:54:12 UTC (rev 11327)
@@ -55,7 +55,8 @@
 	"ACCEPT_KEYWORDS", "ACCEPT_LICENSE",
 	"CONFIG_PROTECT_MASK", "CONFIG_PROTECT",
 	"PRELINK_PATH", "PRELINK_PATH_MASK", "PROFILE_ONLY_VARIABLES"]
-EBUILD_PHASES           = ["setup", "unpack", "compile", "test", "install",
+EBUILD_PHASES           = ["setup", "unpack", "configure",
+                          "compile", "test", "install",
                           "package", "preinst", "postinst","prerm", "postrm",
                           "other"]
 



Navigation:
Lists: gentoo-commits: < Prev By Thread Next > < Prev By Date Next >
Previous by thread:
gentoo-x86 commit in dev-util/re2c: re2c-0.12.0.ebuild ChangeLog re2c-0.13.2.ebuild re2c-0.13.5.ebuild
Next by thread:
gentoo-x86 commit in app-misc/tmux: tmux-0.4a.ebuild metadata.xml ChangeLog
Previous by date:
gentoo-x86 commit in dev-util/re2c: re2c-0.12.0.ebuild ChangeLog re2c-0.13.2.ebuild re2c-0.13.5.ebuild
Next by date:
gentoo-x86 commit in app-misc/tmux: tmux-0.4a.ebuild metadata.xml ChangeLog


Updated Mar 12, 2011

Summary: Archive of the gentoo-commits mailing list.

Donate to support our development efforts.

Copyright 2001-2013 Gentoo Foundation, Inc. Questions, Comments? Contact us.