From cbd3ea6cad4d7ef8103ddbb71245c1ea47fa49ed Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Wed, 29 Aug 2012 09:26:38 -0700 Subject: [PATCH] EAPI 5: EBUILD_PHASE_FUNC variable See bug #390765 and the PMS patch: http://git.overlays.gentoo.org/gitweb/?p=proj/pms.git;a=commit;h=76ddca560da42fd968c53a2a0c38a6ac840a7ad4 --- bin/phase-functions.sh | 2 +- pym/portage/eapi.py | 7 ++++++- .../package/ebuild/_config/special_env_vars.py | 5 +++-- pym/portage/package/ebuild/config.py | 7 +++++++ pym/portage/package/ebuild/doebuild.py | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh index 352019967..c23be74d3 100644 --- a/bin/phase-functions.sh +++ b/bin/phase-functions.sh @@ -11,7 +11,7 @@ PORTAGE_READONLY_METADATA="DEFINED_PHASES DEPEND DESCRIPTION EAPI HOMEPAGE INHERITED IUSE REQUIRED_USE KEYWORDS LICENSE PDEPEND PROVIDE RDEPEND REPOSITORY RESTRICT SLOT SRC_URI" -PORTAGE_READONLY_VARS="D EBUILD EBUILD_PHASE \ +PORTAGE_READONLY_VARS="D EBUILD EBUILD_PHASE EBUILD_PHASE_FUNC \ EBUILD_SH_ARGS ECLASSDIR EMERGE_FROM FILESDIR MERGE_TYPE \ PM_EBUILD_HOOK_DIR \ PORTAGE_ACTUAL_DISTDIR PORTAGE_ARCHLIST PORTAGE_BASHRC \ diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py index 00ce2a512..1d8da39fe 100644 --- a/pym/portage/eapi.py +++ b/pym/portage/eapi.py @@ -44,6 +44,9 @@ def eapi_exports_merge_type(eapi): def eapi_exports_replace_vars(eapi): return eapi not in ("0", "1", "2", "3") +def eapi_exports_EBUILD_PHASE_FUNC(eapi): + return eapi not in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi") + def eapi_exports_REPOSITORY(eapi): return eapi in ("4-python",) @@ -75,7 +78,8 @@ def eapi_allows_dots_in_use_flags(eapi): return eapi in ("4-python",) _eapi_attrs = collections.namedtuple('_eapi_attrs', - 'dots_in_PN dots_in_use_flags iuse_defaults iuse_effective ' + 'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC ' + 'iuse_defaults iuse_effective ' 'repo_deps required_use required_use_at_most_one_of slot_abi slot_deps ' 'src_uri_arrows strong_blocks use_deps use_dep_defaults') @@ -100,6 +104,7 @@ def _get_eapi_attrs(eapi): eapi_attrs = _eapi_attrs( dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)), dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)), + exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)), iuse_defaults = (eapi is None or eapi_has_iuse_defaults(eapi)), iuse_effective = (eapi is not None and eapi_has_iuse_effective(eapi)), repo_deps = (eapi is None or eapi_has_repo_deps(eapi)), diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py index 2505ce391..4d425375f 100644 --- a/pym/portage/package/ebuild/_config/special_env_vars.py +++ b/pym/portage/package/ebuild/_config/special_env_vars.py @@ -13,7 +13,8 @@ import re # configuration files. env_blacklist = frozenset(( "A", "AA", "CATEGORY", "DEPEND", "DESCRIPTION", "EAPI", - "EBUILD_FORCE_TEST", "EBUILD_PHASE", "EBUILD_SKIP_MANIFEST", + "EBUILD_FORCE_TEST", "EBUILD_PHASE", + "EBUILD_PHASE_FUNC", "EBUILD_SKIP_MANIFEST", "ED", "EMERGE_FROM", "EPREFIX", "EROOT", "GREP_OPTIONS", "HOMEPAGE", "INHERITED", "IUSE", "IUSE_EFFECTIVE", "KEYWORDS", "LICENSE", "MERGE_TYPE", @@ -39,7 +40,7 @@ environ_whitelist += [ "ACCEPT_LICENSE", "BASH_ENV", "BUILD_PREFIX", "COLUMNS", "D", "DISTDIR", "DOC_SYMLINKS_DIR", "EAPI", "EBUILD", "EBUILD_FORCE_TEST", - "EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "ED", + "EBUILD_PHASE", "EBUILD_PHASE_FUNC", "ECLASSDIR", "ECLASS_DEPTH", "ED", "EMERGE_FROM", "EPREFIX", "EROOT", "FEATURES", "FILESDIR", "HOME", "MERGE_TYPE", "NOCOLOR", "PATH", "PKGDIR", diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index 6a9ed08b8..e87138203 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -19,6 +19,7 @@ from _emerge.Package import Package import portage portage.proxy.lazyimport.lazyimport(globals(), 'portage.data:portage_gid', + 'portage.package.ebuild.doebuild:_phase_func_map', ) from portage import bsd_chflags, \ load_mod, os, selinux, _unicode_decode @@ -2402,6 +2403,7 @@ class config(object): environ_filter = self._environ_filter eapi = self.get('EAPI') + eapi_attrs = _get_eapi_attrs(eapi) phase = self.get('EBUILD_PHASE') filter_calling_env = False if self.mycpv is not None and \ @@ -2483,6 +2485,11 @@ class config(object): not eapi_exports_replace_vars(eapi): mydict.pop("REPLACED_BY_VERSION", None) + if phase is not None and eapi_attrs.exports_EBUILD_PHASE_FUNC: + phase_func = _phase_func_map.get(phase) + if phase_func is not None: + mydict["EBUILD_PHASE_FUNC"] = phase_func + return mydict def thirdpartymirrors(self): diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py index 3ba8ebd6f..5856f69ce 100644 --- a/pym/portage/package/ebuild/doebuild.py +++ b/pym/portage/package/ebuild/doebuild.py @@ -75,6 +75,24 @@ _unsandboxed_phases = frozenset([ "prerm", "setup" ]) +_phase_func_map = { + "config": "pkg_config", + "setup": "pkg_setup", + "nofetch": "pkg_nofetch", + "unpack": "src_unpack", + "prepare": "src_prepare", + "configure": "src_configure", + "compile": "src_compile", + "test": "src_test", + "install": "src_install", + "preinst": "pkg_preinst", + "postinst": "pkg_postinst", + "prerm": "pkg_prerm", + "postrm": "pkg_postrm", + "info": "pkg_info", + "pretend": "pkg_pretend", +} + def _doebuild_spawn(phase, settings, actionmap=None, **kwargs): """ All proper ebuild phases which execute ebuild.sh are spawned -- 2.26.2