# Jeremy Wohl's dispatch-conf script and the portage chkcontents script.
#
-import os, sys
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
-import portage
+from portage import os
import dispatch_conf
FIND_EXTANT_CONTENTS = "find %s -name CONTENTS"
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os,sys,errno
-
+import sys, errno
# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
+from os import environ as ose
+from os import path as osp
+if ose.__contains__("PORTAGE_PYTHONPATH"):
+ sys.path.insert(0, ose["PORTAGE_PYTHONPATH"])
else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
-import portage.locks
+ sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp. realpath(__file__))), "pym"))
+import portage
from portage.const import EPREFIX
+from portage import os
if not sys.argv[1:] or "--help" in sys.argv or "-h" in sys.argv:
import portage
from stat import *
from random import *
-import atexit, commands, os, re, shutil, stat, sys
+import atexit, commands, re, shutil, stat, sys
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
-import portage
-
-from portage import dispatch_conf, const
+from portage import os
+from portage import dispatch_conf
from portage.process import find_binary
FIND_EXTANT_CONFIGS = "find '%s' %s -name '._cfg????_%s' ! -name '.*~' ! -iname '.*.bak' -print"
import optparse
import os
+# for an explanation on this logic, see pym/_emerge/__init__.py
+from os import environ as ose
+from os import path as osp
+if ose.__contains__("PORTAGE_PYTHONPATH"):
+ sys.path.insert(0, ose["PORTAGE_PYTHONPATH"])
+else:
+ sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp. realpath(__file__))), "pym"))
+
description = "See the ebuild(1) man page for more info"
usage = "Usage: ebuild <ebuild file> <command> [command] ..."
parser = optparse.OptionParser(description=description, usage=usage)
os.environ["PORTAGE_CALLER"]="ebuild"
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
-import portage
+from portage import os
if not opts.ignore_default_opts:
default_opts = portage.settings.get("EBUILD_DEFAULT_OPTS", "").split()
import logging
import optparse
-import os
try:
import portage
sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym"))
import portage
+from portage import os
from _emerge.MetadataRegen import MetadataRegen
from portage.cache.cache_errors import CacheError, StatCollision
from portage.util import writemsg_level
#!@PORTAGE_PYTHON@ -O
# vim: noet :
-import os
import re
import signal
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-import portage.const, portage.exception, portage.output
+from portage import os
class WorldHandler(object):
pdb.set_trace()
signal.signal(signal.SIGUSR1, debug_signal)
-<<<<<<< .working
# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
+from os import environ as ose
+from os import path as osp
+if ose.__contains__("PORTAGE_PYTHONPATH"):
+ sys.path.insert(0, ose["PORTAGE_PYTHONPATH"])
else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
+ sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp. realpath(__file__))), "pym"))
from _emerge.main import emerge_main
if __name__ == "__main__":
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os, sys, errno
+import sys, errno
def usage(status):
print "Usage: env-update [--no-ldconfig]"
import os,sys
os.environ["PORTAGE_CALLER"]="fixpackages"
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
-import portage
-
+from portage import os
mysettings = portage.settings
mytrees = portage.db
mtimedb = portage.mtimedb
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
import sys
# for an explanation on this logic, see pym/_emerge/__init__.py
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
from portage.output import *
from optparse import OptionGroup, OptionParser
${QA_INTERCEPTORS}
# portage config variables and variables set directly by portage
- unset ACCEPT_LICENSE BAD BRACKET BUILD_PREFIX COLS \
+ unset ACCEPT_LICENSE ACCEPT_PROPERTIES BAD BRACKET BUILD_PREFIX COLS \
DISTCC_DIR DISTDIR DOC_SYMLINKS_DIR \
EBUILD_EXIT_STATUS_FILE EBUILD_FORCE_TEST EBUILD_MASTER_PID \
ECLASSDIR ECLASS_DEPTH ENDCOL FAKEROOTKEY \
import portage
del pym_path
+from portage import os
from portage.util import writemsg, writemsg_stdout
#-----------------------------------------------------------------------------
args = sys.argv[2:]
if args and not isinstance(args[0], unicode):
for i in xrange(len(args)):
- args[i] = unicode(args[i], encoding='utf_8', errors='replace')
+ args[i] = portage._unicode_decode(args[i])
try:
if uses_root:
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import errno, signal, sys, os
+import errno, signal, sys
from itertools import izip
# for an explanation on this logic, see pym/_emerge/__init__.py
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+
def quickpkg_main(options, args, eout):
from portage import catsplit, dep_expand, flatten, isvalidatom, xpak
from portage.dep import use_reduce, paren_reduce
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import sys, os
-import portage.exception
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
-import portage
-
+# for an explanation on this logic, see pym/_emerge/__init__.py
+from os import environ as ose
+from os import path as osp
+if ose.__contains__("PORTAGE_PYTHONPATH"):
+ sys.path.insert(0, ose["PORTAGE_PYTHONPATH"])
+else:
+ sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp. realpath(__file__))), "pym"))
+import portage
+from portage import os
+import portage.exception
import re, portage.const
__candidatematcher__ = re.compile("^[0-9]+: \\*\\*\\* emerge ")
import formatter
import logging
import optparse
-import os
import re
import signal
import stat
import portage
portage._disable_legacy_globals()
+from portage import os
from repoman.checks import run_checks
from repoman import utilities
from _emerge.EbuildMerge import EbuildMerge
from _emerge.EbuildBuildDir import EbuildBuildDir
from portage.util import writemsg
-# for an explanation on this logic, see pym/_emerge/__init__.py
+import portage
+from portage import os
import codecs
-import os
import sys
if os.environ.__contains__("PORTAGE_PYTHONPATH"):
sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
from portage.output import colorize
+<<<<<<< .working
from portage.const import EPREFIX
+=======
+
+>>>>>>> .merge-right.r13998
class Binpkg(CompositeTask):
__slots__ = ("find_blockers",
from _emerge.SpawnProcess import SpawnProcess
import urlparse
import sys
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+
class BinpkgFetcher(SpawnProcess):
__slots__ = ("pkg", "pretend",
from _emerge.BinpkgFetcher import BinpkgFetcher
from _emerge.CompositeTask import CompositeTask
from _emerge.BinpkgVerifier import BinpkgVerifier
-import os
+from portage import os
+
class BinpkgPrefetcher(CompositeTask):
__slots__ = ("pkg",) + \
from _emerge.AsynchronousTask import AsynchronousTask
from portage.util import writemsg
import sys
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import codecs
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+import codecs
+
class BinpkgVerifier(AsynchronousTask):
__slots__ = ("logfile", "pkg",)
from portage.util import writemsg
from portage.data import secpass
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+
try:
import cPickle as pickle
except ImportError:
import pickle
-import os
+
class BlockerCache(portage.cache.mappings.MutableMapping):
"""This caches blockers of installed packages so that dep_check does not
have to be done for every single installed package on every invocation of
# Distributed under the terms of the GNU General Public License v2
# $Id$
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage import digraph
from portage.sets.base import InternalPackageSet
# $Id$
from _emerge.AsynchronousTask import AsynchronousTask
-import os
+from portage import os
+
class CompositeTask(AsynchronousTask):
__slots__ = ("scheduler",) + ("_current_task",)
# $Id$
from _emerge.EbuildProcess import EbuildProcess
-import os
+from portage import os
+
class EbuildBinpkg(EbuildProcess):
"""
This assumes that src_install() has successfully completed.
from _emerge.EbuildFetchonly import EbuildFetchonly
from _emerge.EbuildBuildDir import EbuildBuildDir
from portage.util import writemsg
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import codecs
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
from portage.output import colorize
from portage.const import EPREFIX
class EbuildBuild(CompositeTask):
# $Id$
from _emerge.SlotObject import SlotObject
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+import sys
import errno
+
class EbuildBuildDir(SlotObject):
__slots__ = ("dir_path", "pkg", "settings",
from _emerge.EbuildPhase import EbuildPhase
from _emerge.TaskSequence import TaskSequence
from _emerge.CompositeTask import CompositeTask
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+
class EbuildExecuter(CompositeTask):
__slots__ = ("pkg", "scheduler", "settings") + ("_tree",)
# for an explanation on this logic, see pym/_emerge/__init__.py
import os
import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
import codecs
-import os
from portage.elog.messages import eerror
+
class EbuildFetcher(SpawnProcess):
__slots__ = ("config_pool", "fetchonly", "fetchall", "pkg", "prefetch") + \
from _emerge.SlotObject import SlotObject
import shutil
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
from portage.elog.messages import eerror
+
class EbuildFetchonly(SlotObject):
__slots__ = ("fetch_all", "pkg", "pretend", "settings")
# $Id$
from _emerge.SlotObject import SlotObject
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+
class EbuildMerge(SlotObject):
__slots__ = ("find_blockers", "logger", "ldpath_mtimes",
from _emerge.PollConstants import PollConstants
import sys
from portage.cache.mappings import slot_dict_class
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
from itertools import izip
import fcntl
import codecs
+
class EbuildMetadataPhase(SubProcess):
"""
from _emerge.EbuildProcess import EbuildProcess
from _emerge.CompositeTask import CompositeTask
from portage.util import writemsg
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import codecs
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+import codecs
+
class EbuildPhase(CompositeTask):
__slots__ = ("background", "pkg", "phase",
# $Id$
from _emerge.SpawnProcess import SpawnProcess
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+
class EbuildProcess(SpawnProcess):
__slots__ = ("phase", "pkg", "settings", "tree")
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
from itertools import izip
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from _emerge.Package import Package
from _emerge.PackageVirtualDbapi import PackageVirtualDbapi
# $Id$
import formatter
-import os
import sys
import time
except ImportError:
from StringIO import StringIO
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage.output import xtermTitle
from _emerge.getloadavg import getloadavg
def _write(self, s):
if sys.hexversion < 0x3000000 and isinstance(s, unicode):
# avoid potential UnicodeEncodeError
- s = s.encode('utf_8', 'replace')
+ s = portage._unicode_encode(s)
self.out.write(s)
self.out.flush()
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
-
+from portage import os
from portage.output import colorize
from _emerge.Binpkg import Binpkg
# Distributed under the terms of the GNU General Public License v2
# $Id$
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from _emerge.EbuildMetadataPhase import EbuildMetadataPhase
from _emerge.PollScheduler import PollScheduler
# $Id$
from _emerge.SpawnProcess import SpawnProcess
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
+
class MiscFunctionsProcess(SpawnProcess):
"""
Spawns misc-functions.sh with an existing ebuild environment.
import re
from itertools import chain
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
from portage.cache.mappings import slot_dict_class
from portage.dep import paren_reduce, use_reduce, \
paren_normalize, paren_enclose
# $Id$
from _emerge.DependencyArg import DependencyArg
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+
class PackageArg(DependencyArg):
def __init__(self, package=None, **kwargs):
DependencyArg.__init__(self, **kwargs)
self.package = package
self.atom = portage.dep.Atom("=" + package.cpv)
self.set = (self.atom, )
-
import codecs
import logging
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from _emerge.AsynchronousTask import AsynchronousTask
from _emerge.unmerge import unmerge
from _emerge.UninstallFailure import UninstallFailure
# Distributed under the terms of the GNU General Public License v2
# $Id$
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+
class PackageVirtualDbapi(portage.dbapi):
"""
A dbapi-like interface class that represents the state of the installed
# Distributed under the terms of the GNU General Public License v2
# $Id$
+from portage import os
from _emerge.AbstractPollTask import AbstractPollTask
from _emerge.PollConstants import PollConstants
import sys
-import os
import fcntl
import array
+
class PipeReader(AbstractPollTask):
"""
# $Id$
from portage.output import teal
-import os
+from portage import os
+
class RepoDisplay(object):
def __init__(self, roots):
self._shown_repos = {}
import codecs
import logging
-import os
import sys
import textwrap
import time
import weakref
from itertools import izip
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage.cache.mappings import slot_dict_class
from portage.elog.messages import eerror
from portage.output import colorize, create_color_func, darkgreen, red
def _append_to_log_path(self, log_path, msg):
- if not isinstance(msg, unicode):
- msg = unicode(msg, encoding='utf_8', errors='replace')
-
- f = codecs.open(log_path, mode='a',
+ f = codecs.open(portage._unicode_encode(log_path), mode='a',
encoding='utf_8', errors='replace')
try:
- f.write(msg)
+ f.write(portage._unicode_decode(msg))
finally:
f.close()
background = self._background
if background and log_path is not None:
- log_file = codecs.open(log_path, mode='a',
+ log_file = codecs.open(portage._unicode_encode(log_path), mode='a',
encoding='utf_8', errors='replace')
out = log_file
log_path = self._locate_failure_log(failed_pkg)
if log_path is not None:
try:
- log_file = codecs.open(log_path, mode='r',
- encoding='utf_8', errors='replace')
+ log_file = codecs.open(portage._unicode_encode(log_path),
+ mode='r', encoding='utf_8', errors='replace')
except IOError:
pass
from _emerge.PollConstants import PollConstants
import sys
from portage.cache.mappings import slot_dict_class
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
import fcntl
import errno
import array
+
class SpawnProcess(SubProcess):
"""
# Distributed under the terms of the GNU General Public License v2
# $Id$
+from portage import os
from _emerge.AbstractPollTask import AbstractPollTask
import signal
-import os
import errno
+
class SubProcess(AbstractPollTask):
__slots__ = ("pid",) + \
# Distributed under the terms of the GNU General Public License v2
# $Id$
+from portage import os
from _emerge.CompositeTask import CompositeTask
from _emerge.AsynchronousTask import AsynchronousTask
-import os
from collections import deque
+
class TaskSequence(CompositeTask):
"""
A collection of tasks that executes sequentially. Each task
# Distributed under the terms of the GNU General Public License v2
# $Id$
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+
class UninstallFailure(portage.exception.PortageException):
"""
An instance of this class is raised by unmerge() when
import commands
import errno
import logging
-import os
import platform
import pwd
import re
import time
from itertools import chain, izip
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage import digraph
from portage.cache.cache_errors import CacheError
from portage.const import NEWS_LIB_PATH, EPREFIX
# $Id$
import codecs
-import os
import re
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
+from portage import os
def calc_changelog(ebuildpath,current,next):
if ebuildpath == None or not os.path.exists(ebuildpath):
next = next[:-3]
changelogpath = os.path.join(os.path.split(ebuildpath)[0],'ChangeLog')
try:
- changelog = codecs.open(changelogpath, mode='r',
- encoding='utf_8', errors='replace').read()
+ changelog = codecs.open(portage._unicode_encode(changelogpath),
+ mode='r', encoding='utf_8', errors='replace').read()
except SystemExit, e:
raise # Needed else can't exit
except:
# $Id$
import gc
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
def clear_caches(trees):
# Distributed under the terms of the GNU General Public License v2
# $Id$
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
def create_world_atom(pkg, args_set, root_config):
# $Id$
import gc
-import os
import re
import sys
import textwrap
from itertools import chain, izip
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage import digraph
from portage.output import bold, blue, colorize, create_color_func, darkblue, \
darkgreen, green, nc_len, red, teal, turquoise, yellow
# $Id$
import codecs
-import os
import sys
import time
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage.data import secpass
from portage.output import xtermTitle
from portage.const import EPREFIX
-
+
_emerge_log_dir = EPREFIX + '/var/log'
def emergelog(xterm_titles, mystr, short_msg=None):
- if not isinstance(mystr, unicode):
- mystr = unicode(mystr, encoding='utf_8', errors='replace')
+ mystr = portage._unicode_decode(mystr)
- if short_msg is not None and not isinstance(short_msg, unicode):
- short_msg = unicode(short_msg, encoding='utf_8', errors='replace')
+ if short_msg is not None:
+ short_msg = portage._unicode_decode(short_msg)
if xterm_titles and short_msg:
if "HOSTNAME" in os.environ:
xtermTitle(short_msg)
try:
file_path = os.path.join(_emerge_log_dir, 'emerge.log')
- mylogfile = codecs.open(file_path, mode='a',
+ mylogfile = codecs.open(portage._unicode_encode(file_path), mode='a',
encoding='utf_8', errors='replace')
portage.util.apply_secpass_permissions(file_path,
uid=portage.portage_uid, gid=portage.portage_gid,
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
+from portage import os
getloadavg = getattr(os, "getloadavg", None)
if getloadavg is None:
# $Id$
import re
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
def is_valid_package_atom(x):
import signal
import sys
import textwrap
-import os
import platform
-
-# Portage module path logic (Prefix way)
-# In principle we don't want to be dependant on the environment
-# (PYTHONPATH) and/or python hardcoded default search path.
-# (PYTHONPATH). Since Gentoo patches Python to include Portage's python
-# modules in the default search path, any Gentoo python interpreter is
-# an enemy for Portage once it is not installed in the path hardcoded
-# during Python compilation. This is the case when bootstrapping
-# Prefix Portage on a Gentoo Linux system, or when bootstrapping Prefix
-# Portage using another Prefix instance on the same system. For this
-# reason we ignore the entire search path, and allow a backdoor for
-# developers via the PORTAGE_PYTHONPATH variable.
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
import _emerge.help
import portage.xpak, commands, errno, re, time
from portage.output import colorize, xtermTitle, xtermTitleReset
if myargs and not isinstance(myargs[0], unicode):
for i in xrange(len(myargs)):
- myargs[i] = unicode(myargs[i], encoding='utf_8', errors='replace')
+ myargs[i] = portage._unicode_decode(myargs[i])
myfiles += myargs
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
import re
from itertools import izip
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage.output import bold, bold as white, darkgreen, green, red
from portage.util import writemsg_stdout
# $Id$
import logging
-import os
import textwrap
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage.util import writemsg_level
def show_invalid_depstring_notice(parent_node, depstring, error_msg):
# $Id$
import logging
-import os
import sys
import textwrap
from itertools import izip
-
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
-
+from portage import os
from portage.output import bold, colorize, darkgreen, green
from portage.sets import SETPREFIX
from portage.util import cmp_sort_key
# Distributed under the terms of the GNU General Public License v2
# $Id$
-# for an explanation on this logic, see pym/_emerge/__init__.py
-import os
-import sys
-if os.environ.__contains__("PORTAGE_PYTHONPATH"):
- sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"])
-else:
- sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym"))
import portage
def visible(pkgsettings, pkg):
try:
if pkgsettings._getMissingLicenses(pkg.cpv, pkg.metadata):
return False
+ if pkgsettings._getMissingProperties(pkg.cpv, pkg.metadata):
+ return False
except portage.exception.InvalidDependString:
return False
return True
# ESTALE may not be defined on some systems, such as interix.
errno.ESTALE = -1
import logging
- import os
import re
- import shutil
import time
import types
try:
from itertools import chain, izip
import platform
import warnings
+
+ # Temporarily delete these imports, to ensure that only the
+ # wrapped versions are imported by portage internals.
+ import os
+ del os
+ import shutil
+ del shutil
+
except ImportError, e:
sys.stderr.write("\n\n")
sys.stderr.write("!!! Failed to complete python imports. These are internal modules for\n")
sys.stderr.write(" "+str(e)+"\n\n")
raise
-
-try:
- import portage._selinux as selinux
-except OSError, e:
- writemsg("!!! SELinux not loaded: %s\n" % str(e), noiselevel=-1)
- del e
-except ImportError:
- pass
-
-# ===========================================================================
-# END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END
-# ===========================================================================
-
def _unicode_encode(s):
if isinstance(s, unicode):
s = s.encode('utf_8', 'replace')
def _unicode_module_wrapper(mod):
return mod
+import os
+os = _unicode_module_wrapper(os)
+import shutil
+shutil = _unicode_module_wrapper(shutil)
+
+try:
+ import portage._selinux as selinux
+except OSError, e:
+ writemsg("!!! SELinux not loaded: %s\n" % str(e), noiselevel=-1)
+ del e
+except ImportError:
+ pass
+
+# ===========================================================================
+# END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END OF IMPORTS -- END
+# ===========================================================================
+
def _shell_quote(s):
"""
Quote a string in double-quotes and use backslashes to
raise portage.exception.PermissionDenied(mypath)
ftype = []
for x in list:
- if not isinstance(x, unicode):
- x = unicode(x, encoding='utf_8', errors='replace')
try:
if followSymlinks:
pathstat = os.stat(mypath+"/"+x)
# environment in order to prevent sandbox from sourcing /etc/profile
# in it's bashrc (causing major leakage).
_environ_whitelist += [
- "ACCEPT_LICENSE", "BASH_ENV", "BUILD_PREFIX", "D",
+ "ACCEPT_LICENSE", "ACCEPT_PROPERTIES", "BASH_ENV", "BUILD_PREFIX", "D",
"DISTDIR", "DOC_SYMLINKS_DIR", "EBUILD",
"EBUILD_EXIT_STATUS_FILE", "EBUILD_FORCE_TEST",
"EBUILD_PHASE", "ECLASSDIR", "ECLASS_DEPTH", "EMERGE_FROM",
self._accept_license = None
self._accept_license_str = None
self._license_groups = {}
+ self._accept_properties = None
self.virtuals = {}
self.virts_p = {}
self._accept_license = copy.deepcopy(clone._accept_license)
self._plicensedict = copy.deepcopy(clone._plicensedict)
self._license_groups = copy.deepcopy(clone._license_groups)
+ self._accept_properties = copy.deepcopy(clone._accept_properties)
+ self._ppropertiesdict = copy.deepcopy(clone._ppropertiesdict)
else:
def check_var_directory(varname, var):
env = os.environ
# Avoid potential UnicodeDecodeError exceptions later.
- env_unicode = {}
- for k, v in env.iteritems():
- if not isinstance(k, unicode):
- k = unicode(k, encoding='utf_8', errors='replace')
- if not isinstance(v, unicode):
- v = unicode(v, encoding='utf_8', errors='replace')
- env_unicode[k] = v
+ env_unicode = dict((_unicode_decode(k), _unicode_decode(v))
+ for k, v in env.iteritems())
self.backupenv = env_unicode
self.pusedict = {}
self.pkeywordsdict = {}
self._plicensedict = {}
+ self._ppropertiesdict = {}
self.punmaskdict = {}
abs_user_config = os.path.join(config_root, USER_CONFIG_PATH)
self._plicensedict[cp] = cp_dict
cp_dict[k] = self.expandLicenseTokens(v)
+ #package.properties
+ propdict = grabdict_package(os.path.join(
+ abs_user_config, "package.properties"), recursive=1)
+ for k, v in propdict.iteritems():
+ cp = dep_getkey(k)
+ cp_dict = self._ppropertiesdict.get(cp)
+ if not cp_dict:
+ cp_dict = {}
+ self._ppropertiesdict[cp] = cp_dict
+ cp_dict[k] = v
+
self._local_repo_configs = {}
self._local_repo_conf_path = \
os.path.join(abs_user_config, 'repos.conf')
if use is None:
use = frozenset(settings['PORTAGE_USE'].split())
values['ACCEPT_LICENSE'] = self._accept_license(use, settings)
+ values['ACCEPT_PROPERTIES'] = self._accept_properties(use, settings)
values['PORTAGE_RESTRICT'] = self._restrict(use, settings)
return values
licenses = acceptable_licenses
return ' '.join(sorted(licenses))
+ def _accept_properties(self, use, settings):
+ """
+ Generated a pruned version of ACCEPT_PROPERTIES, by intersection with
+ PROPERTIES.
+ Please, look at self._accept_license() to know why it is required.
+ """
+ try:
+ properties = set(flatten(
+ dep.use_reduce(dep.paren_reduce(
+ settings['PROPERTIES']),
+ uselist=use)))
+ except exception.InvalidDependString:
+ properties = set()
+ properties.discard('||')
+ if settings._accept_properties:
+ acceptable_properties = set()
+ for x in settings._accept_properties:
+ if x == '*':
+ acceptable_properties.update(properties)
+ elif x == '-*':
+ acceptable_properties.clear()
+ elif x[1] == '-':
+ acceptable_properties.discard(x[1:])
+ elif x in properties:
+ acceptable_properties.add(x)
+
+ properties = acceptable_properties
+ return ' '.join(sorted(properties))
+
def _restrict(self, use, settings):
try:
restrict = set(flatten(
lazy_vars = self._lazy_vars(built_use, self)
env_configdict.addLazySingleton('ACCEPT_LICENSE',
lazy_vars.__getitem__, 'ACCEPT_LICENSE')
+ env_configdict.addLazySingleton('ACCEPT_PROPERTIES',
+ lazy_vars.__getitem__, 'ACCEPT_PROPERTIES')
env_configdict.addLazySingleton('PORTAGE_RESTRICT',
lazy_vars.__getitem__, 'PORTAGE_RESTRICT')
ret.append(element)
return ret
+ def _getMissingProperties(self, cpv, metadata):
+ """
+ Take a PROPERTIES string and return a list of any properties the user may
+ may need to accept for the given package. The returned list will not
+ contain any properties that have already been accepted. This method
+ can throw an InvalidDependString exception.
+
+ @param cpv: The package name (for package.properties support)
+ @type cpv: String
+ @param metadata: A dictionary of raw package metadata
+ @type metadata: dict
+ @rtype: List
+ @return: A list of properties that have not been accepted.
+ """
+ if not self._accept_properties:
+ return []
+ accept_properties = self._accept_properties
+ cpdict = self._ppropertiesdict.get(dep_getkey(cpv), None)
+ if cpdict:
+ accept_properties = list(self._accept_properties)
+ cpv_slot = "%s:%s" % (cpv, metadata["SLOT"])
+ for atom in match_to_list(cpv_slot, cpdict.keys()):
+ accept_properties.extend(cpdict[atom])
+
+ properties = set(flatten(dep.use_reduce(dep.paren_reduce(
+ metadata["PROPERTIES"]), matchall=1)))
+ properties.discard('||')
+
+ acceptable_properties = set()
+ for x in accept_properties:
+ if x == '*':
+ acceptable_properties.update(properties)
+ elif x == '-*':
+ acceptable_properties.clear()
+ elif x[:1] == '-':
+ acceptable_properties.discard(x[1:])
+ else:
+ acceptable_properties.add(x)
+
+ properties_str = metadata["PROPERTIES"]
+ if "?" in properties_str:
+ use = metadata["USE"].split()
+ else:
+ use = []
+
+ properties_struct = portage.dep.use_reduce(
+ portage.dep.paren_reduce(properties_str), uselist=use)
+ properties_struct = portage.dep.dep_opconvert(properties_struct)
+ return self._getMaskedProperties(properties_struct, acceptable_properties)
+
+ def _getMaskedProperties(self, properties_struct, acceptable_properties):
+ if not properties_struct:
+ return []
+ if properties_struct[0] == "||":
+ ret = []
+ for element in properties_struct[1:]:
+ if isinstance(element, list):
+ if element:
+ ret.append(self._getMaskedProperties(
+ element, acceptable_properties))
+ if not ret[-1]:
+ return []
+ else:
+ if element in acceptable_properties:
+ return[]
+ ret.append(element)
+ # Return all masked properties, since we don't know which combination
+ # (if any) the user will decide to unmask
+ return flatten(ret)
+
+ ret = []
+ for element in properties_struct:
+ if isinstance(element, list):
+ if element:
+ ret.extend(self._getMaskedProperties(element,
+ acceptable_properties))
+ else:
+ if element not in acceptable_properties:
+ ret.append(element)
+ return ret
+
def _accept_chost(self, cpv, metadata):
"""
@return True if pkg CHOST is accepted, False otherwise.
# repoman will accept any license
self._accept_license = ()
+ # ACCEPT_PROPERTIES works like ACCEPT_LICENSE, without groups
+ if self.local_config:
+ mysplit = []
+ for curdb in mydbs:
+ mysplit.extend(curdb.get('ACCEPT_PROPERTIES', '').split())
+ if mysplit:
+ self.configlist[-1]['ACCEPT_PROPERTIES'] = ' '.join(mysplit)
+ if tuple(mysplit) != self._accept_properties:
+ self._accept_properties = tuple(mysplit)
+ else:
+ # repoman will accept any property
+ self._accept_properties = ()
+
for mykey in myincrementals:
myflags=[]
raise ValueError("Invalid type being used as a value: '%s': '%s'" % (str(mykey),str(myvalue)))
# Avoid potential UnicodeDecodeError exceptions later.
- if not isinstance(mykey, unicode):
- mykey = unicode(mykey, encoding='utf_8', errors='replace')
- if not isinstance(myvalue, unicode):
- myvalue = unicode(myvalue, encoding='utf_8', errors='replace')
+ mykey = _unicode_decode(mykey)
+ myvalue = _unicode_decode(myvalue)
self.modifying()
self.modifiedkeys.append(mykey)
""" epatch will just grab all the patches out of a directory, so we have to
make sure there aren't any foreign files that it might grab."""
filesdir = os.path.join(pkgdir, "files")
- if isinstance(filesdir, unicode):
- # Avoid UnicodeDecodeError raised from
- # os.path.join when called by os.walk.
- filesdir = filesdir.encode('utf_8', 'replace')
for parent, dirs, files in os.walk(filesdir):
+ parent = _unicode_decode(parent)
for d in dirs:
if d.startswith(".") or d == "CVS":
dirs.remove(d)
for f in files:
+ f = _unicode_decode(f)
if f.startswith("."):
continue
f = os.path.join(parent, f)[len(filesdir) + 1:]
(_shell_quote(mysettings["D"]),))
destdir = mysettings["D"]
- if isinstance(destdir, unicode):
- # Avoid UnicodeDecodeError raised from
- # os.path.join when called by os.walk.
- destdir = destdir.encode('utf_8', 'replace')
size = 0
counted_inodes = set()
for parent, dirs, files in os.walk(destdir):
+ parent = _unicode_decode(parent)
for fname in chain(dirs, files):
+ fname = _unicode_decode(fname)
fpath = os.path.join(parent, fname)
mystat = os.lstat(fpath)
if stat.S_ISREG(mystat.st_mode) and \
mysettings,
fd_pipes=fd_pipes, returnpid=True, droppriv=droppriv)
os.close(pw) # belongs exclusively to the child process now
- maxbytes = 1024
- mybytes = []
- while True:
- mybytes.append(os.read(pr, maxbytes))
- if not mybytes[-1]:
- break
- os.close(pr)
- mybytes = u''.join(unicode(chunk,
- encoding='utf_8', errors='replace') for chunk in mybytes)
- global auxdbkeys
- for k, v in izip(auxdbkeys, mybytes.splitlines()):
+ f = os.fdopen(pr, 'rb')
+ for k, v in izip(auxdbkeys,
+ (_unicode_decode(line).rstrip('\n') for line in f)):
dbkey[k] = v
+ f.close()
retval = os.waitpid(mypids[0], 0)[1]
portage.process.spawned_pids.remove(mypids[0])
# If it got a signal, return the signal that was sent, but
eapi = metadata["EAPI"]
mygroups = settings._getKeywords(mycpv, metadata)
licenses = metadata["LICENSE"]
+ properties = metadata["PROPERTIES"]
slot = metadata["SLOT"]
if eapi.startswith("-"):
eapi = eapi[1:]
except portage.exception.InvalidDependString, e:
rValue.append("LICENSE: "+str(e))
+ try:
+ missing_properties = settings._getMissingProperties(mycpv, metadata)
+ if missing_properties:
+ allowed_tokens = set(["||", "(", ")"])
+ allowed_tokens.update(missing_properties)
+ properties_split = properties.split()
+ properties_split = [x for x in properties_split \
+ if x in allowed_tokens]
+ msg = properties_split[:]
+ msg.append("properties")
+ rValue.append(" ".join(msg))
+ except portage.exception.InvalidDependString, e:
+ rValue.append("PROPERTIES: "+srt(e))
+
# Only show KEYWORDS masks for installed packages
# if they're not masked for any other reason.
if kmask and (not installed or not rValue):
# Distributed under the terms of the GNU General Public License v2
# $Id$
-import os
+import portage
+from portage import os
+from portage import shutil
import selinux
-import shutil
from selinux import is_selinux_enabled, getfilecon, lgetfilecon
def copyfile(src, dest):
- if isinstance(src, unicode):
- src = src.encode('utf_8', 'replace')
- if isinstance(dest, unicode):
- dest = dest.encode('utf_8', 'replace')
+ src = portage._unicode_encode(src)
+ dest = portage._unicode_encode(dest)
(rc, ctx) = selinux.lgetfilecon(src)
if rc < 0:
raise OSError("copyfile: Failed getting context of \"%s\"." % src)
return ctx
def mkdir(target, refdir):
- if isinstance(target, unicode):
- target = target.encode('utf_8', 'replace')
- if isinstance(refdir, unicode):
- refdir = refdir.encode('utf_8', 'replace')
+ target = portage._unicode_encode(target)
+ refdir = portage._unicode_encode(refdir)
(rc, ctx) = selinux.getfilecon(refdir)
if rc < 0:
raise OSError(
setfscreatecon()
def rename(src, dest):
- if isinstance(src, unicode):
- src = src.encode('utf_8', 'replace')
- if isinstance(dest, unicode):
- dest = dest.encode('utf_8', 'replace')
+ src = portage._unicode_encode(src)
+ dest = portage._unicode_encode(dest)
(rc, ctx) = selinux.lgetfilecon(src)
if rc < 0:
raise OSError("rename: Failed getting context of \"%s\"." % src)
raise OSError("setexec: Failed setting exec() context \"%s\"." % ctx)
def setfscreate(ctx="\n"):
- if isinstance(ctx, unicode):
- ctx = ctx.encode('utf_8', 'replace')
+ ctx = portage._unicode_encode(ctx)
if selinux.setfscreatecon(ctx) < 0:
raise OSError(
"setfscreate: Failed setting fs create context \"%s\"." % ctx)
def spawn(selinux_type, spawn_func, mycommand, opt_name=None, **keywords):
+ selinux_type = portage._unicode_encode(selinux_type)
con = settype(selinux_type)
setexec(con)
try:
setexec()
def symlink(target, link, reflnk):
- if isinstance(target, unicode):
- target = target.encode('utf_8', 'replace')
- if isinstance(link, unicode):
- link = link.encode('utf_8', 'replace')
- if isinstance(reflnk, unicode):
- reflnk = reflnk.encode('utf_8', 'replace')
+ target = portage._unicode_encode(target)
+ link = portage._unicode_encode(link)
+ reflnk = portage._unicode_encode(reflnk)
(rc, ctx) = selinux.lgetfilecon(reflnk)
if rc < 0:
raise OSError(
continue
if local_config:
metadata["USE"] = ""
- if "?" in metadata["LICENSE"]:
+ if "?" in metadata["LICENSE"] or "?" in metadata["PROPERTIES"]:
self.doebuild_settings.setcpv(cpv, mydb=metadata)
metadata["USE"] = self.doebuild_settings.get("USE", "")
try:
if settings._getMissingLicenses(cpv, metadata):
continue
+ if settings._getMissingProperties(cpv, metadata):
+ continue
except InvalidDependString:
continue
if mydep.use:
if not accept_chost(mycpv, metadata):
continue
metadata["USE"] = ""
- if "?" in metadata["LICENSE"]:
+ if "?" in metadata["LICENSE"] or "?" in metadata["PROPERTIES"]:
self.doebuild_settings.setcpv(mycpv, mydb=metadata)
metadata['USE'] = self.doebuild_settings['PORTAGE_USE']
try:
if self.mysettings._getMissingLicenses(mycpv, metadata):
continue
+ if self.mysettings._getMissingProperties(mycpv, metadata):
+ continue
except InvalidDependString:
continue
newlist.append(mycpv)
from portage import listdir, dep_expand, digraph, flatten, key_expand, \
doebuild_environment, doebuild, env_update, prepare_build_dirs, \
- abssymlink, movefile, _movefile, bsd_chflags, cpv_getkey, \
- _unicode_module_wrapper
+ abssymlink, movefile, _movefile, bsd_chflags, cpv_getkey
+
+# This is a special version of the os module, wrapped for unicode support.
+from portage import os
from portage.cache.mappings import slot_dict_class
import codecs
-import os, re, shutil, stat, errno, copy, subprocess
+import re, shutil, stat, errno, copy, subprocess
import logging
import sys
from itertools import izip
-os = _unicode_module_wrapper(os)
-
try:
import cPickle as pickle
except ImportError:
raise CommandNotFound(args[0])
else:
for l in proc.stdout:
- if not isinstance(l, unicode):
- l = unicode(l, encoding='utf_8', errors='replace')
+ l = portage._unicode_decode(l)
l = l[3:].rstrip("\n")
if not l:
continue
now has a categories property that is generated from the
available packages.
"""
- self.root = root[:]
+ self.root = portage._unicode_decode(root)
#cache for category directory mtimes
self.mtdircache = {}
returnme = []
for x in dir_list:
- if not isinstance(x, unicode):
- x = unicode(x, encoding='utf_8', errors='replace')
if self._excluded_dirs.match(x) is not None:
continue
ps = pkgsplit(x)
else:
def listdir(p, **kwargs):
try:
- return [isinstance(x, unicode) and x or \
- unicode(x, encoding='utf_8', errors='replace') \
- for x in os.listdir(p) \
+ return [x for x in os.listdir(p) \
if os.path.isdir(os.path.join(p, x))]
except EnvironmentError, e:
if e.errno == PermissionDenied.errno:
cache_mtime, metadata = pkg_data
cache_valid = cache_mtime == mydir_mtime
if cache_valid:
+ # Migrate old metadata to unicode.
for k, v in metadata.iteritems():
- if not isinstance(v, unicode):
- # Migrate old metadata to unicode.
- metadata[k] = unicode(v,
- encoding='utf_8', errors='replace')
+ metadata[k] = portage._unicode_decode(v)
mydata.update(metadata)
pull_me.difference_update(mydata)
if not hasattr(pkg, "getcontents"):
pkg = self._dblink(pkg)
root = self.root
- if not isinstance(root, unicode):
- root = unicode(root, encoding='utf_8', errors='replace')
root_len = len(root) - 1
new_contents = pkg.getcontents().copy()
removed = 0
for filename in paths:
- if not isinstance(filename, unicode):
- filename = unicode(filename,
- encoding='utf_8', errors='replace')
+ filename = portage._unicode_decode(filename)
filename = normalize_path(filename)
if relative_paths:
relative_filename = filename
h = self._new_hash()
# Always use a constant utf_8 encoding here, since
# the "default" encoding can change.
- h.update(s.encode('utf_8', 'replace'))
+ h.update(portage._unicode_encode(s))
h = h.hexdigest()
h = h[-self._hex_chars:]
h = int(h, 16)
if the file is not owned by this package.
"""
- if not isinstance(filename, unicode):
- filename = unicode(filename,
- encoding='utf_8', errors='replace')
+ filename = portage._unicode_decode(filename)
- if not isinstance(destroot, unicode):
- destroot = unicode(destroot,
- encoding='utf_8', errors='replace')
+ destroot = portage._unicode_decode(destroot)
destfile = normalize_path(
os.path.join(destroot, filename.lstrip(os.path.sep)))
new_contents = self.getcontents().copy()
old_contents = self._installed_instance.getcontents()
for f in sorted(preserve_paths):
- if not isinstance(f, unicode):
- f = unicode(f, encoding='utf_8', errors='replace')
+ f = portage._unicode_decode(f)
f_abs = os.path.join(root, f.lstrip(os.sep))
contents_entry = old_contents.get(f_abs)
if contents_entry is None:
not existing; we will merge these symlinks at a later time.
"""
+ srcroot = portage._unicode_decode(srcroot)
+ destroot = portage._unicode_decode(destroot)
+ inforoot = portage._unicode_decode(inforoot)
+ myebuild = portage._unicode_decode(myebuild)
+
showMessage = self._display_merge
scheduler = self._scheduler
myfilelist = []
mylinklist = []
paths_with_newlines = []
-
- if isinstance(srcroot, unicode):
- # Avoid UnicodeDecodeError raised from
- # os.path.join when called by os.walk.
- srcroot = srcroot.encode('utf_8', 'replace')
-
srcroot_len = len(srcroot)
def onerror(e):
raise
for parent, dirs, files in os.walk(srcroot, onerror=onerror):
+ parent = portage._unicode_decode(parent)
for f in files:
+ f = portage._unicode_decode(f)
file_path = os.path.join(parent, f)
relative_path = file_path[srcroot_len:]
writemsg = self._display_merge
scheduler = self._scheduler
- from os.path import sep, join
+ sep = portage.os.sep
+ join = portage.os.path.join
srcroot = normalize_path(srcroot).rstrip(sep) + sep
destroot = normalize_path(destroot).rstrip(sep) + sep
mydest = join(destroot, offset, x)
# myrealdest is mydest without the $ROOT prefix (makes a difference if ROOT!="/")
myrealdest = join(sep, offset, x)
- if not isinstance(myrealdest, unicode):
- myrealdest = unicode(myrealdest,
- encoding='utf_8', errors='replace')
# stat file once, test using S_* macros many times (faster that way)
mystat = os.lstat(mysrc)
mymode = mystat[stat.ST_MODE]