summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-08-04 17:54:12 +0000
committerZac Medico <zmedico@gentoo.org>2008-08-04 17:54:12 +0000
commitd964e92c4da5d7b515e298454a22d54b37ff57b9 (patch)
treef8117e44c460a5d51b2094dc3d3a529b22b99de3 /bin
parentccd5ad2d8f7867a2f28615bd2ab403c440ff2743 (diff)
downloadportage-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
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ebuild2
-rwxr-xr-xbin/ebuild.sh231
-rwxr-xr-xbin/isolated-functions.sh9
3 files changed, 171 insertions, 71 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