diff options
author | Zac Medico <zmedico@gentoo.org> | 2008-08-04 17:54:12 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2008-08-04 17:54:12 +0000 |
commit | d964e92c4da5d7b515e298454a22d54b37ff57b9 (patch) | |
tree | f8117e44c460a5d51b2094dc3d3a529b22b99de3 | |
parent | ccd5ad2d8f7867a2f28615bd2ab403c440ff2743 (diff) | |
download | portage-d964e92c4da5d7b515e298454a22d54b37ff57b9.tar.gz portage-d964e92c4da5d7b515e298454a22d54b37ff57b9.tar.bz2 portage-d964e92c4da5d7b515e298454a22d54b37ff57b9.zip |
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.
svn path=/main/trunk/; revision=11327
-rwxr-xr-x | bin/ebuild | 2 | ||||
-rwxr-xr-x | bin/ebuild.sh | 231 | ||||
-rwxr-xr-x | bin/isolated-functions.sh | 9 | ||||
-rw-r--r-- | pym/_emerge/__init__.py | 2 | ||||
-rw-r--r-- | pym/portage/__init__.py | 25 | ||||
-rw-r--r-- | pym/portage/const.py | 3 |
6 files changed, 189 insertions, 83 deletions
diff --git a/bin/ebuild b/bin/ebuild index 6a9bf601b..6760787c4 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -182,7 +182,7 @@ if opts.skip_manifest: 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(): diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 7692c4e02..fe9adc02c 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -583,7 +583,7 @@ einstall() { fi } -pkg_nofetch() { +_default_pkg_nofetch() { [ -z "${SRC_URI}" ] && return echo "!!! The following are listed in SRC_URI for ${PN}:" @@ -593,22 +593,25 @@ pkg_nofetch() { 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 @@ src_test() { 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 @@ abort_handler() { 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 @@ abort_install() { exit 1 } -dyn_compile() { - trap "abort_compile" SIGINT SIGQUIT - - [ "$(type -t pre_src_compile)" == "function" ] && qa_call pre_src_compile +dyn_configure() { + hasq "$EAPI" 0 1 2_pre1 && return 0 - [ "${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 + 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 - [ "${CCACHE_DIR-unset}" != "unset" ] && export CCACHE_DIR - [ "${CCACHE_SIZE-unset}" != "unset" ] && export CCACHE_SIZE + trap abort_configure SIGINT SIGQUIT - [ "${DISTCC_DIR-unset}" == "unset" ] && export DISTCC_DIR="${PORTAGE_TMPDIR}/.distcc" - [ ! -z "${DISTCC_DIR}" ] && addwrite "${DISTCC_DIR}" + [[ $(type -t pre_src_configure) = function ]] && \ + qa_call pre_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 + 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 - 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 + trap SIGINT SIGQUIT +} - local x - for x in 1 2 3 4 5 6 7 8; do - echo -ne "\a" - LC_ALL=C sleep 0.25 - done +dyn_compile() { - 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 + + [[ $(type -t pre_src_compile) = function ]] && \ + qa_call pre_src_compile - 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" vecho ">>> Compiling source in ${srcdir} ..." ebuild_phase src_compile vecho ">>> Source compiled." @@ -1059,8 +1060,9 @@ dyn_help() { 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 @@ remove_path_entry() { 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 @@ if ! hasq ${EBUILD_PHASE} clean && \ 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 @@ if [ "${EBUILD_PHASE}" != "depend" ] ; then 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 @@ if [ -n "${EBUILD_SH_ARGS}" ] ; then ) 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,7 +1952,9 @@ if [ -n "${EBUILD_SH_ARGS}" ] ; then 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}" ] && \ diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 56381ce8a..abeb9d371 100755 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -499,13 +499,16 @@ save_ebuild_env() { 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 diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 1d86b0f14..b00dc5b30 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -2587,7 +2587,7 @@ class EbuildExecuter(CompositeTask): __slots__ = ("pkg", "scheduler", "settings") + ("_tree",) - _phases = ("compile", "test", "install") + _phases = ("configure", "compile", "test", "install") _live_eclasses = frozenset([ "cvs", diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index f7abfe6c1..95b8bd56f 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -4544,8 +4544,10 @@ def _spawn_misc_sh(mysettings, commands, **kwargs): 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 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, actionmap_deps={ "setup": [], "unpack": ["setup"], - "compile":["unpack"], + "configure": ["unpack"], + "compile":["configure"], "test": ["compile"], "install":["test"], "rpm": ["install"], @@ -5063,7 +5066,8 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, 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 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, # 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 diff --git a/pym/portage/const.py b/pym/portage/const.py index 26eddd596..19d858b11 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -55,7 +55,8 @@ INCREMENTALS = ["USE", "USE_EXPAND", "USE_EXPAND_HIDDEN", "FEATURES", "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"] |