summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/_emerge/__init__.py41
-rw-r--r--pym/portage/__init__.py52
2 files changed, 67 insertions, 26 deletions
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 2bb1d4428..d9d762860 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -8870,6 +8870,21 @@ class Scheduler(PollScheduler):
for k in self._binpkg_opts.__slots__:
setattr(self._binpkg_opts, k, "--" + k.replace("_", "-") in myopts)
+ self.curval = 0
+ self._logger = self._emerge_log_class()
+ self._task_queues = self._task_queues_class()
+ for k in self._task_queues.allowed_keys:
+ setattr(self._task_queues, k,
+ SequentialTaskQueue())
+ self._status_display = JobStatusDisplay()
+ self._max_load = myopts.get("--load-average")
+ max_jobs = myopts.get("--jobs")
+ if max_jobs is None:
+ max_jobs = 1
+ self._set_max_jobs(max_jobs)
+ background = self._background_mode()
+ self._background = background
+
# The root where the currently running
# portage instance is installed.
self._running_root = trees["/"]["root_config"]
@@ -8880,12 +8895,18 @@ class Scheduler(PollScheduler):
self._config_pool = {}
self._blocker_db = {}
for root in trees:
+ root_config = trees[root]["root_config"]
+ if background:
+ root_config.settings.unlock()
+ root_config.settings["PORTAGE_BACKGROUND"] = "1"
+ root_config.settings.backup_changes("PORTAGE_BACKGROUND")
+ root_config.settings.lock()
+
self.pkgsettings[root] = portage.config(
clone=trees[root]["vartree"].settings)
self._config_pool[root] = []
self._blocker_db[root] = BlockerDB(trees[root]["root_config"])
- self.curval = 0
- self._logger = self._emerge_log_class()
+
fetch_iface = self._fetch_iface_class(log_file=self._fetch_log,
schedule=self._schedule_fetch)
self._sched_iface = self._iface_class(
@@ -8899,17 +8920,10 @@ class Scheduler(PollScheduler):
scheduleYield=self._schedule_yield,
unregister=self._unregister)
- self._task_queues = self._task_queues_class()
- for k in self._task_queues.allowed_keys:
- setattr(self._task_queues, k,
- SequentialTaskQueue())
-
self._prefetchers = weakref.WeakValueDictionary()
self._pkg_queue = []
self._completed_tasks = set()
- self._status_display = JobStatusDisplay()
-
self._failed_pkgs = []
self._failed_pkgs_all = []
self._failed_pkgs_die_msgs = []
@@ -8921,15 +8935,6 @@ class Scheduler(PollScheduler):
curval=0, maxval=merge_count)
self._status_display.maxval = self._pkg_count.maxval
- max_jobs = myopts.get("--jobs")
- if max_jobs is None:
- max_jobs = 1
- self._set_max_jobs(max_jobs)
- background = self._background_mode()
- self._background = background
-
- self._max_load = myopts.get("--load-average")
-
# The load average takes some time to respond when new
# jobs are added, so we need to limit the rate of adding
# new jobs.
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 49baf361a..bbfdd7d10 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -14,6 +14,7 @@ try:
import sys
import copy
import errno
+ import logging
import os
import re
import shutil
@@ -990,6 +991,7 @@ class config(object):
"EMERGE_WARNING_DELAY", "FETCHCOMMAND", "FETCHCOMMAND_FTP",
"FETCHCOMMAND_HTTP", "FETCHCOMMAND_SFTP",
"GENTOO_MIRRORS", "NOCONFMEM", "O",
+ "PORTAGE_BACKGROUND",
"PORTAGE_BINHOST_CHUNKSIZE", "PORTAGE_CALLER",
"PORTAGE_ECLASS_WARNING_ENABLE", "PORTAGE_ELOG_CLASSES",
"PORTAGE_ELOG_MAILFROM", "PORTAGE_ELOG_MAILSUBJECT",
@@ -4806,6 +4808,37 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
writemsg("File Not Found: '%s'\n" % str(e), noiselevel=-1)
return 1
+ _prepare_workdir(mysettings)
+ _prepare_features_dirs(mysettings)
+
+def _adjust_perms_msg(settings, msg):
+
+ def write(msg):
+ writemsg(msg, noiselevel=-1)
+
+ background = settings.get("PORTAGE_BACKGROUND") == "1"
+ log_path = settings.get("PORTAGE_LOG_FILE")
+ log_file = None
+
+ if background and log_path is not None:
+ try:
+ log_file = open(log_path, 'a')
+ except IOError:
+ def write(msg):
+ pass
+ else:
+ def write(msg):
+ log_file.write(msg)
+ log_file.flush()
+
+ try:
+ write(msg)
+ finally:
+ if log_file is not None:
+ log_file.close()
+
+def _prepare_features_dirs(mysettings):
+
features_dirs = {
"ccache":{
"basedir_var":"CCACHE_DIR",
@@ -4864,16 +4897,18 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
not dirmode == (stat.S_IMODE(subdir_st.st_mode) & dirmode))):
droppriv_fix = True
break
+
if droppriv_fix:
- writemsg(colorize("WARN", " * ") + \
- "Adjusting permissions " + \
- "for FEATURES=userpriv: '%s'\n" % mydir,
- noiselevel=-1)
+ _adjust_perms_msg(mysettings,
+ colorize("WARN", " * ") + \
+ "Adjusting permissions " + \
+ "for FEATURES=userpriv: '%s'\n" % mydir)
elif modified:
- writemsg(colorize("WARN", " * ") + \
- "Adjusting permissions " + \
- "for FEATURES=%s: '%s'\n" % (myfeature, mydir),
- noiselevel=-1)
+ _adjust_perms_msg(mysettings,
+ colorize("WARN", " * ") + \
+ "Adjusting permissions " + \
+ "for FEATURES=%s: '%s'\n" % (myfeature, mydir))
+
if modified or kwargs["always_recurse"] or droppriv_fix:
def onerror(e):
raise # The feature is disabled if a single error
@@ -4893,6 +4928,7 @@ def prepare_build_dirs(myroot, mysettings, cleanup):
noiselevel=-1)
time.sleep(5)
+def _prepare_workdir(mysettings):
workdir_mode = 0700
try:
mode = mysettings["PORTAGE_WORKDIR_MODE"]