Make ebuild(1) detect ebuild/eclass changes and automatically source the
authorZac Medico <zmedico@gentoo.org>
Mon, 23 Mar 2009 00:44:23 +0000 (00:44 -0000)
committerZac Medico <zmedico@gentoo.org>
Mon, 23 Mar 2009 00:44:23 +0000 (00:44 -0000)
ebuild atain in this case (even though $T/environment may already exist).
This should help avoid confusion by ensuring that the latest changes to
the ebuild/eclasses are reflected in the environment.

svn path=/main/trunk/; revision=13148

bin/ebuild
bin/ebuild.sh

index a03f0ec6efd881f1d0fa2cd32d7aeddaaac77d2f..bdf6b9503b09951bdf5ffc470310c5c4d948165f 100755 (executable)
@@ -195,13 +195,20 @@ if opts.skip_manifest:
        tmpsettings.backup_changes("EBUILD_SKIP_MANIFEST")
        portage._doebuild_manifest_exempt_depend += 1
 
+# If the current metadata is invalid then force the ebuild to be
+# sourced again even if $T/environment already exists.
+ebuild_changed = False
+metadata, st, emtime = \
+       portage.portdb._pull_valid_cache(cpv, ebuild, ebuild_portdir)
+if metadata is None:
+       ebuild_changed = True
+
 build_dir_phases = set(["setup", "unpack", "prepare", "configure", "compile",
        "test", "install", "package", "rpm"])
 
 def stale_env_warning():
        if "clean" not in pargs and \
                "noauto" not in tmpsettings.features and \
-               tmpsettings.get("PORTAGE_QUIET") != "1" and \
                build_dir_phases.intersection(pargs):
                portage.doebuild_environment(ebuild, "setup", portage.root,
                        tmpsettings, debug, 1, portage.portdb)
@@ -215,6 +222,10 @@ def stale_env_warning():
                        for x in msg:
                                portage.writemsg(">>> %s\n" % x)
 
+                       if ebuild_changed:
+                               open(os.path.join(tmpsettings['PORTAGE_BUILDDIR'],
+                                       '.ebuild_changed'), 'w')
+
 from portage.exception import PermissionDenied, \
        PortagePackageException, UnsupportedAPIException
 checked_for_stale_env = False
index d426e15a9d793fb0cc4157c2e43407b1a562cbff..f548a8f05c37a3fc94a82295808f42cd32807bbe 100755 (executable)
@@ -714,7 +714,7 @@ dyn_clean() {
        fi
 
        if [[ $EMERGE_FROM = binary ]] || ! hasq keepwork $FEATURES; then
-               rm -f "$PORTAGE_BUILDDIR"/.{exit_status,logid,unpacked,prepared} \
+               rm -f "$PORTAGE_BUILDDIR"/.{ebuild_changed,exit_status,logid,unpacked,prepared} \
                        "$PORTAGE_BUILDDIR"/.{configured,compiled,tested,packaged}
 
                rm -rf "${PORTAGE_BUILDDIR}/build-info"
@@ -1865,7 +1865,7 @@ fi
 if ! hasq "$EBUILD_PHASE" clean cleanrm && \
        (
                hasq ${EBUILD_PHASE} depend || \
-               [ ! -f "${T}"/environment ] || \
+               [[ ! -f $T/environment || -f $PORTAGE_BUILDDIR/.ebuild_changed ]] || \
                hasq noauto ${FEATURES}
        ) ; then
        # The bashrcs get an opportunity here to set aliases that will be expanded
@@ -1881,6 +1881,8 @@ if ! hasq "$EBUILD_PHASE" clean cleanrm && \
 
        if [ "${EBUILD_PHASE}" != "depend" ] ; then
                RESTRICT=${PORTAGE_RESTRICT}
+               [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \
+                       rm "$PORTAGE_BUILDDIR/.ebuild_changed"
        fi
 
        # This next line is not the same as export RDEPEND=${RDEPEND:-${DEPEND}}