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"]
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(
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 = []
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.
import sys
import copy
import errno
+ import logging
import os
import re
import shutil
"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",
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",
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
noiselevel=-1)
time.sleep(5)
+def _prepare_workdir(mysettings):
workdir_mode = 0700
try:
mode = mysettings["PORTAGE_WORKDIR_MODE"]