prepare_build_dirs: warn for logdir permission
authorZac Medico <zmedico@gentoo.org>
Mon, 11 Jul 2011 15:22:11 +0000 (08:22 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 11 Jul 2011 15:22:11 +0000 (08:22 -0700)
If there is insufficient permission to use PORT_LOGDIR or the required
subdirectory, warn instead of raising an exception. Also, fall back to
using $T/build.log as a last resort.

pym/portage/package/ebuild/prepare_build_dirs.py

index 259bedf80ba8e4560b21cfcb42b70bc9ecd03f19..5153190654c68f627efa8139a8b901bc53ae9895 100644 (file)
@@ -300,6 +300,7 @@ def _prepare_workdir(mysettings):
        if 'compress-build-logs' in mysettings.features:
                compress_log_ext = '.gz'
 
+       logdir_subdir_ok = False
        if "PORT_LOGDIR" in mysettings and \
                os.access(mysettings["PORT_LOGDIR"], os.W_OK):
                logid_path = os.path.join(mysettings["PORTAGE_BUILDDIR"], ".logid")
@@ -320,9 +321,19 @@ def _prepare_workdir(mysettings):
                                (mysettings["CATEGORY"], mysettings["PF"], logid_time,
                                compress_log_ext))
 
-               ensure_dirs(os.path.dirname(mysettings["PORTAGE_LOG_FILE"]))
+               log_subdir = os.path.dirname(mysettings["PORTAGE_LOG_FILE"])
+               try:
+                       ensure_dirs(log_subdir)
+               except PortageException as e:
+                       writemsg(_unicode_decode("!!! %s\n") % (e,), noiselevel=-1)
+               else:
+                       if os.access(log_subdir, os.W_OK):
+                               logdir_subdir_ok = True
+                       else:
+                               writemsg(_unicode_decode("!!! %s: %s\n") %
+                                       (_("Permission Denied"), log_subdir), noiselevel=-1)
 
-       else:
+       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