Add ${T}/build.log symlink to PORT_LOGDIR.
authorZac Medico <zmedico@gentoo.org>
Sun, 22 Apr 2012 17:56:01 +0000 (10:56 -0700)
committerZac Medico <zmedico@gentoo.org>
Sun, 22 Apr 2012 17:56:01 +0000 (10:56 -0700)
This will fix bug #412865. This makes it easier on people who
`emerge foo`, do stuff, `emerge foo`, do stuff, etc... to have
the same path to the log in between runs.

bin/isolated-functions.sh
pym/portage/package/ebuild/prepare_build_dirs.py

index 98be41ec0dc48cd7187298dc2893e6110ccdb1ea..36304881f0368925acf77bc7995f64b2140ecd26 100644 (file)
@@ -216,8 +216,15 @@ die() {
                > "$PORTAGE_BUILDDIR/.die_hooks"
        fi
 
-       [[ -n ${PORTAGE_LOG_FILE} ]] \
-               && eerror "The complete build log is located at '${PORTAGE_LOG_FILE}'."
+       if [[ -n ${PORTAGE_LOG_FILE} ]] ; then
+               eerror "The complete build log is located at '${PORTAGE_LOG_FILE}'."
+               if [[ ${PORTAGE_LOG_FILE} != ${T}/* ]] ; then
+                       # Display path to symlink in ${T}, as requested in bug #412865.
+                       local log_ext=${PORTAGE_LOG_FILE##*/}
+                       log_ext=${log_ext#*.}
+                       eerror "For convenience, a symlink to the build log is located at '${T}/build.${log_ext}'."
+               fi
+       fi
        if [ -f "${T}/environment" ] ; then
                eerror "The ebuild environment file is located at '${T}/environment'."
        elif [ -d "${T}" ] ; then
index 50b14ec91e0ce8f64a64195acbb61c14119bdf33..b8fbdc5cf89295394933e661d19256b6b99337a2 100644 (file)
@@ -346,13 +346,31 @@ def _prepare_workdir(mysettings):
                                writemsg(_unicode_decode("!!! %s: %s\n") %
                                        (_("Permission Denied"), log_subdir), noiselevel=-1)
 
+       tmpdir_log_path = os.path.join(
+               mysettings["T"], "build.log%s" % compress_log_ext)
        if not logdir_subdir_ok:
                # NOTE: When sesandbox is enabled, the local SELinux security policies
                # may not allow output to be piped out of the sesandbox domain. The
                # current policy will allow it to work when a pty is available, but
                # not through a normal pipe. See bug #162404.
-               mysettings["PORTAGE_LOG_FILE"] = os.path.join(
-                       mysettings["T"], "build.log%s" % compress_log_ext)
+               mysettings["PORTAGE_LOG_FILE"] = tmpdir_log_path
+       else:
+               # Create a symlink from tmpdir_log_path to PORTAGE_LOG_FILE, as
+               # requested in bug #412865.
+               make_new_symlink = False
+               try:
+                       target = os.readlink(tmpdir_log_path)
+               except OSError:
+                       make_new_symlink = True
+               else:
+                       if target != mysettings["PORTAGE_LOG_FILE"]:
+                               make_new_symlink = True
+               if make_new_symlink:
+                       try:
+                               os.unlink(tmpdir_log_path)
+                       except OSError:
+                               pass
+                       os.symlink(mysettings["PORTAGE_LOG_FILE"], tmpdir_log_path)
 
 def _ensure_log_subdirs(logdir, subdir):
        """