Merged from trunk -r13988:13998
authorFabian Groffen <grobian@gentoo.org>
Fri, 14 Aug 2009 20:51:39 +0000 (20:51 -0000)
committerFabian Groffen <grobian@gentoo.org>
Fri, 14 Aug 2009 20:51:39 +0000 (20:51 -0000)
   | 13989   | Bug #280460 - Wrap portage.os with unicode encode/decode     |
   | zmedico | wrappers.                                                    |

   | 13990   | Fix unicode support for compatibility with the new wrapped   |
   | zmedico | os module, and use _unicode_decode() and _unicode_encode()   |
   |         | where appropriate.                                           |

   | 13991   | Fix breakage from previous commit.                           |
   | zmedico |                                                              |

   | 13992   | Avoid using the wrapped os.read(), in order to avoid         |
   | zmedico | differing behavior between python-2.x (with wrapper) and     |
   |         | py3k (without wrapper). This sort of mismatch only applies   |
   |         | to os functions that return raw bytes under py3k, rather     |
   |         | than unicode.                                                |

   | 13993   | Update imports to import portage.os (with unicode wrappers), |
   | zmedico | and use _unicode_encode() and _unicode_decode() where        |
   |         | appropriate.                                                 |

   | 13994   | Update imports to import portage.os (with unicode wrappers), |
   | zmedico | and use _unicode_encode() and _unicode_decode() where        |
   |         | appropriate.                                                 |

   | 13995   | Update imports to import portage.os (with unicode wrappers), |
   | zmedico | and use _unicode_encode() and _unicode_decode() where        |
   |         | appropriate.                                                 |

   | 13996   | Update imports to import portage.os and portage.shutil (with |
   | zmedico | unicode wrappers), and use _unicode_encode() where           |
   |         | appropriate.                                                 |

   | 13997   | Add ACCEPT_PROPERTIES variable which has default value * and |
   | volkmar | can be set in make.conf or /etc/portage/package.properties.  |
   |         | If ACCEPT_PROPERTIES doesn't match ebuild PROPERTIES, the    |
   |         | ebuild is masked.                                            |

   | 13998   | Temporarily delete the os and shutil imports, to ensure that |
   | zmedico | only the wrapped versions are imported by portage internals. |

svn path=/main/branches/prefix/; revision=14043

65 files changed:
bin/archive-conf
bin/clean_locks
bin/dispatch-conf
bin/ebuild
bin/egencache
bin/emaint
bin/emerge
bin/env-update
bin/fixpackages
bin/glsa-check
bin/isolated-functions.sh
bin/portageq
bin/quickpkg
bin/regenworld
bin/repoman
pym/_emerge/Binpkg.py
pym/_emerge/BinpkgFetcher.py
pym/_emerge/BinpkgPrefetcher.py
pym/_emerge/BinpkgVerifier.py
pym/_emerge/BlockerCache.py
pym/_emerge/BlockerDB.py
pym/_emerge/CompositeTask.py
pym/_emerge/EbuildBinpkg.py
pym/_emerge/EbuildBuild.py
pym/_emerge/EbuildBuildDir.py
pym/_emerge/EbuildExecuter.py
pym/_emerge/EbuildFetcher.py
pym/_emerge/EbuildFetchonly.py
pym/_emerge/EbuildMerge.py
pym/_emerge/EbuildMetadataPhase.py
pym/_emerge/EbuildPhase.py
pym/_emerge/EbuildProcess.py
pym/_emerge/FakeVartree.py
pym/_emerge/JobStatusDisplay.py
pym/_emerge/MergeListItem.py
pym/_emerge/MetadataRegen.py
pym/_emerge/MiscFunctionsProcess.py
pym/_emerge/Package.py
pym/_emerge/PackageArg.py
pym/_emerge/PackageUninstall.py
pym/_emerge/PackageVirtualDbapi.py
pym/_emerge/PipeReader.py
pym/_emerge/RepoDisplay.py
pym/_emerge/Scheduler.py
pym/_emerge/SpawnProcess.py
pym/_emerge/SubProcess.py
pym/_emerge/TaskSequence.py
pym/_emerge/UninstallFailure.py
pym/_emerge/actions.py
pym/_emerge/changelog.py
pym/_emerge/clear_caches.py
pym/_emerge/create_world_atom.py
pym/_emerge/depgraph.py
pym/_emerge/emergelog.py
pym/_emerge/getloadavg.py
pym/_emerge/is_valid_package_atom.py
pym/_emerge/main.py
pym/_emerge/search.py
pym/_emerge/show_invalid_depstring_notice.py
pym/_emerge/unmerge.py
pym/_emerge/visible.py
pym/portage/__init__.py
pym/portage/_selinux.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py

index 887af6de935705a4074a017eeb63a3448b4a32f6..429b22692e8c196a1f20d29680b4524122cea47a 100755 (executable)
 #  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"
index 26add5adf5239cd764f61fe301edbea1ab2a53f3..945bc2f64f59a865a9b892c1038f844955922717 100755 (executable)
@@ -3,18 +3,18 @@
 # 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
index 5d6e67e86a7a0b26f2f27b47ce6e07decfb94ff8..0fce21fceb669f27f1b5c93878c01b8c22e1fce5 100755 (executable)
@@ -17,18 +17,10 @@ if not hasattr(__builtins__, "set"):
 
 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"
index ca8984a951e5e7c4a125d9f82d781f3729c0dc74..7d536a6ab9c77eed4a602663908d3895fd109cdb 100755 (executable)
@@ -27,6 +27,14 @@ signal.signal(signal.SIGUSR1, debug_signal)
 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)
@@ -56,14 +64,7 @@ if "merge" in pargs:
 
 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()
index a848279f9126a7a93c51bb840e148b304b857056..223428e07862f3c99c437268bfa280b970fb314f 100755 (executable)
@@ -21,7 +21,6 @@ except KeyboardInterrupt:
 
 import logging
 import optparse
-import os
 
 try:
        import portage
@@ -30,6 +29,7 @@ except ImportError:
        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
index 2fbace95cbc83ab6856e90194071f23ca4cbba3d..e08698e8c3e4b504a07875d4ffb2e800dd128e5f 100755 (executable)
@@ -1,6 +1,5 @@
 #!@PORTAGE_PYTHON@ -O
 # vim: noet :
-import os
 import re
 import signal
 import sys
@@ -17,7 +16,7 @@ else:
        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):
 
index ae93e4f2a10ce23095054707d73eb1c7b3a04faf..e8553f5dbc2e19bcac408618278bc09f1a3996dd 100755 (executable)
@@ -26,14 +26,13 @@ def debug_signal(signum, frame):
        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__":
index 545367074b6a8ab0ff427c62c5cf0bff914212aa..428ca5b88c101667f063e603dc8c73961b256471 100755 (executable)
@@ -3,7 +3,7 @@
 # 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]"
index 381098081969afcf24d2470fc285e31ef6846faf..2fb62a2a19693481f3dfd73280a0b6726e1993c8 100755 (executable)
@@ -6,15 +6,7 @@
 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
index 45f3e95ffe7e3c345b4acbfb829caf99c83d0308..7e2d18997e1190252ebe62c8c940916b35ffe028 100755 (executable)
@@ -3,7 +3,6 @@
 # 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
@@ -15,6 +14,7 @@ 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 *
 
 from optparse import OptionGroup, OptionParser
index c3821d606c4414898c674314fdf9345f8efc0f2c..be89349e6ed67c9fe673dcea2bf1dfa77ddf0bd2 100755 (executable)
@@ -540,7 +540,7 @@ save_ebuild_env() {
                        ${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 \
index bdcdb4d68283b05257ba6a040b6b45afaa14c983..02ad3b196261cd3b2dbfc5bd3f60da15c3f3d268 100755 (executable)
@@ -45,6 +45,7 @@ except ImportError:
        import portage
 del pym_path
 
+from portage import os
 from portage.util import writemsg, writemsg_stdout
 
 #-----------------------------------------------------------------------------
@@ -613,7 +614,7 @@ def main():
        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:
index 01df287021825dfc1900dd2b9b0170659e652d93..ec2f874f451d87e1b683e3f28966948df4cc3934 100755 (executable)
@@ -3,7 +3,7 @@
 # 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
@@ -13,6 +13,8 @@ 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 quickpkg_main(options, args, eout):
        from portage import catsplit, dep_expand, flatten, isvalidatom, xpak
        from portage.dep import use_reduce, paren_reduce
index 2c251c25bd59616611e15d3c1411d85248373ab6..3d7d9b9ad285b26b4fef9af12f02c3d70394da90 100755 (executable)
@@ -3,18 +3,17 @@
 # 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 ")
index 186d38407eccec672756f585738949d77ae49ddf..7abcc80f10eec40dc05bb950ffa2d8272701d628 100755 (executable)
@@ -13,7 +13,6 @@ import errno
 import formatter
 import logging
 import optparse
-import os
 import re
 import signal
 import stat
@@ -44,6 +43,7 @@ else:
 import portage
 
 portage._disable_legacy_globals()
+from portage import os
 
 from repoman.checks import run_checks
 from repoman import utilities
index c538c4e09fb9ff7781fae1b45ff992a498b0fcac..74227e456b22cb6c402c42d02f89790f116950f9 100644 (file)
@@ -10,9 +10,9 @@ from _emerge.BinpkgVerifier import BinpkgVerifier
 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"])
@@ -20,7 +20,11 @@ else:
        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",
index 90320c017614cefd2b36fbec3d2ee8ea6153b08e..e72799a1de179a42bbfcd4961f692bfcad6a3265 100644 (file)
@@ -5,15 +5,9 @@
 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",
index a1e63fd32c8603b222da97012da149b028bd6ccd..4e637db03ba5594f446b8bfa4825e4b7e40bf9bc 100644 (file)
@@ -5,7 +5,8 @@
 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",) + \
index b4a4b8f423c42d0df90b5ffd9806998dcd7b3e8e..31599e2e2fd4ae305e4b185312d3999dbedf570f 100644 (file)
@@ -5,15 +5,10 @@
 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",)
 
index c13143bb2e620a83beb7ae83a3b223ab2db0a42c..7b797ebbd5936727e4d4113bd95a26b65380f645 100644 (file)
@@ -4,19 +4,14 @@
 
 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
index 56b606a749767b5a371a9980c4708dc5ce6a40db..436793c59cdc5aae39b52bfdb51da5ed8d6214ab 100644 (file)
@@ -2,15 +2,8 @@
 # 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
 
index 25de4dcf3cd0034361cce639a04f70666528b8c1..a9de7a1ab8c9247443f6e6d486be81b94c439ba1 100644 (file)
@@ -3,7 +3,8 @@
 # $Id$
 
 from _emerge.AsynchronousTask import AsynchronousTask
-import os
+from portage import os
+
 class CompositeTask(AsynchronousTask):
 
        __slots__ = ("scheduler",) + ("_current_task",)
index 4f5159d78895fc89d781220fe568824bdefbaa7a..8d742d6405a0a328e1161522027425a2365c7f0b 100644 (file)
@@ -3,7 +3,8 @@
 # $Id$
 
 from _emerge.EbuildProcess import EbuildProcess
-import os
+from portage import os
+
 class EbuildBinpkg(EbuildProcess):
        """
        This assumes that src_install() has successfully completed.
index 18c7c59f848c6380fb21d078bb74da0e4b9fe6e4..58bb7769d3d7d007aaa55cfce9c3d41721170d93 100644 (file)
@@ -11,15 +11,8 @@ from _emerge.EbuildMerge import EbuildMerge
 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):
index abef92e7bd0421762e78c1e6df978f499a2d563a..90bb14f14f96abb8b3bd9a68062a9c6246869cab 100644 (file)
@@ -3,15 +3,11 @@
 # $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",
index bf05dc3b66753cf06c858246f4e70842499c94e7..055a8fa4708c8142967796791566b476568c7981 100644 (file)
@@ -5,14 +5,9 @@
 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",)
index a292c6cdddfa3cd6fa5b503ce5ae64382137bf1c..d7cf571b25ee36ac9de59996df804c445fb22f07 100644 (file)
@@ -7,14 +7,11 @@ from _emerge.EbuildBuildDir import EbuildBuildDir
 # 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") + \
index 1b2f143454e7d8d9dbdc8ea904146eda1aa2b402..d65e2b2b12b94381ad051c6b8e1f9444c5376b27 100644 (file)
@@ -4,15 +4,10 @@
 
 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")
index b0776ed7611028096b582d313ee6fb7a2091c9a7..1ac03706e2cb00ca9f1bae3a8fcb562eb96b3f1e 100644 (file)
@@ -3,14 +3,9 @@
 # $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",
index 5d9401a07957b12295f6a2fac99b63de16495f74..a84d722bebf5e5902f0d89fad840f73b5f40f549 100644 (file)
@@ -6,17 +6,12 @@ from _emerge.SubProcess import SubProcess
 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):
 
        """
index 3df6248591c99a7470fd7b437aac6456ee786b3f..598dcf7e3faef3bbabcb0c4006083c3efa22f23a 100644 (file)
@@ -6,15 +6,10 @@ from _emerge.MiscFunctionsProcess import MiscFunctionsProcess
 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",
index d6d7a5d783a07f046affc1f8c4be06256fa4ed84..86a63282ffaa6c21ffbc8666a82f33cafcd81cfc 100644 (file)
@@ -3,14 +3,9 @@
 # $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")
index 2425f13034353c9949bee67b92a61d153b09f531..c4eec6d689b1d8eeafa267fb23760af3c4563959 100644 (file)
@@ -2,17 +2,9 @@
 # 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
 
index 507a5057c10bb0dec455207259663ff65f504008..6aa2d99b7083d2162f8dfaf2155904aa2ed73f0f 100644 (file)
@@ -3,7 +3,6 @@
 # $Id$
 
 import formatter
-import os
 import sys
 import time
 
@@ -12,15 +11,8 @@ try:
 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
@@ -78,7 +70,7 @@ class JobStatusDisplay(object):
        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()
 
index aab79da089964c6d76b43b65cfc6761fb07ef68e..7e4556ec2fc3aecbaf1aa6273f2cebd4232cee1f 100644 (file)
@@ -2,8 +2,7 @@
 # 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
index f3be52f8770abe7dd3392faf1c8c8720c7afba92..ee6eb997af0f8edf865be8e85a62533dbba67444 100644 (file)
@@ -2,15 +2,8 @@
 # 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
 
index 305bbab77a823790c272b94ba0eee1149e43a46e..3e2fff7ccc6df81d6b532759e9d9fcfd75df79b3 100644 (file)
@@ -3,14 +3,9 @@
 # $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.
index bdb014f8fec714f118c89ed21b10eff10b6c46f4..6371f5d0512c8756dd7ee495bf355b85cd308fea 100644 (file)
@@ -4,16 +4,7 @@
 
 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
index 29fbf44c5bdea13697892748a2d8d9b7cebd4288..f64430e1457c2b13f973732298b6977818285182 100644 (file)
@@ -3,18 +3,11 @@
 # $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, )
-
index d430a4709fedc750982ef2649ac1278966dade2a..ff1b5e189ef4a32558c4f8c7ff992b99be8fc9df 100644 (file)
@@ -4,15 +4,8 @@
 
 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
index 6049830c491b4acbad665e830a045f00c01cb34c..f041e1d8cb1bb5df8da3eeb27bff2bb95338b6cb 100644 (file)
@@ -2,14 +2,8 @@
 # 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
index d3cc18425df2d6ded35aceb516a469f71b1fd130..5b64306e792f299cf1264f90e656054668de7442 100644 (file)
@@ -2,12 +2,13 @@
 # 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):
 
        """
index 42056977036dabd808303e35695ee979d69723dd..a954aebfa9af64d13bb58b4c424be760e1fe712b 100644 (file)
@@ -3,7 +3,8 @@
 # $Id$
 
 from portage.output import teal
-import os
+from portage import os
+
 class RepoDisplay(object):
        def __init__(self, roots):
                self._shown_repos = {}
index e82ade8293df1f1e0e50609b4a90dca2fced56ee..cef4ee6ca05115769d5bb3c9b294926e367362ad 100644 (file)
@@ -4,22 +4,13 @@
 
 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
@@ -480,13 +471,10 @@ class Scheduler(PollScheduler):
 
        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()
 
@@ -498,7 +486,7 @@ class Scheduler(PollScheduler):
                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
 
@@ -874,8 +862,8 @@ class Scheduler(PollScheduler):
                        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
 
index 6d8a264053cd01c2a4648724cf066d5008d5158f..e6b3cc7a0633cccd2a1c1cc3492c2a1c97b7d0d0 100644 (file)
@@ -6,17 +6,12 @@ from _emerge.SubProcess import SubProcess
 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):
 
        """
index 37957c3941aca29cfe0ffe9ab24274cc84523852..6bd4562d42996a2cc0af74caa415e04e39cc6809 100644 (file)
@@ -2,10 +2,11 @@
 # 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",) + \
index 3d54d90acf20939d2224c7d5527a8509ce96927f..44eaa332c03f08356bbfc70b3eaf9f7683c8f3b1 100644 (file)
@@ -2,10 +2,11 @@
 # 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
index 8b7cdfa6620f54326f1043e6f97d50a1f2d8be9b..ceb5a58e2d5fe7f6bb13a1ebd638dd54f0782842 100644 (file)
@@ -2,15 +2,8 @@
 # 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
index d8a1f93c02c48820aac9aa2fcf87ca2d13539747..fe64d786ce1a96c6953cec314a1d41f3304566ea 100644 (file)
@@ -5,7 +5,6 @@
 import commands
 import errno
 import logging
-import os
 import platform
 import pwd
 import re
@@ -17,15 +16,8 @@ import textwrap
 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
index 8fb25e01e4bc64a994838926716e1deba34dde29..4adb8b25bafecb7c566651f89b472d0b96d19264 100644 (file)
@@ -3,17 +3,10 @@
 # $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):
@@ -26,8 +19,8 @@ def calc_changelog(ebuildpath,current,next):
                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:
index 41285587120caa1d50ef1c7d4ab3f98fe430186d..1fd667f36972149fe1a4b31d0f0dfdedb1cdaba7 100644 (file)
@@ -3,14 +3,6 @@
 # $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):
index dd4acd63d2cc36b0296b0de6142cb800896a9f03..30ade0acf4413fc11494b8e8b23b4613296359cd 100644 (file)
@@ -2,13 +2,6 @@
 # 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):
index 1af872562b106862ef6e33339dbb049e09647400..31c1848bc7f8c332bdf5be141138b87ade3fe1c7 100644 (file)
@@ -3,21 +3,13 @@
 # $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
index 5d22560619ed3457a8dbc0895ed4e0fef9330791..34601f77275b86a260d1146f5580ef196cb0ab4c 100644 (file)
@@ -3,31 +3,22 @@
 # $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:
@@ -35,7 +26,7 @@ def emergelog(xterm_titles, mystr, short_msg=None):
                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,
index 81265d5008649462b3049b8450d757bfade52b7b..d252e8c0aacfe999a5e829825578e7d146a16a9f 100644 (file)
@@ -2,7 +2,7 @@
 # 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:
index 2717a90807e46782a0a30409cc7a7dcd85c07f33..11920be30115af23e12232ff40ec8a19b2af32b4 100644 (file)
@@ -3,14 +3,6 @@
 # $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):
index 4565422be3bb4de4bb3bd48044e642dbd12000fd..5757cae87e8876f178d698aefb0cce66c9f074d9 100644 (file)
@@ -6,28 +6,9 @@ import logging
 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
@@ -763,7 +744,7 @@ def parse_opts(tmpcmdline, silent=False):
 
        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
 
index 4db6d9fe88d5ffba72e9bc381bfa63b72cf4d7f1..1f276b47e2767a1768da0b1c6b234c57762a2df3 100644 (file)
@@ -2,19 +2,10 @@
 # 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
 
index 9688f437ac82e85463af3c87c8ea80f7e50a420e..4d374fcd00d245354e1faac78b38ae18fae296ad 100644 (file)
@@ -3,18 +3,9 @@
 # $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):
index 5bdead580bb194ec9d411ab7893b61d37b1f0986..25c3e4e4f66d9be485c447e97e72e69d07d37b2b 100644 (file)
@@ -3,20 +3,11 @@
 # $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
index 87f5db640383c43919b058ed6d3c3f16baecaf70..4542e1c97bdca149939b4c132569d7a56c9bf852 100644 (file)
@@ -2,13 +2,6 @@
 # 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):
@@ -47,6 +40,8 @@ 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
index ad91ac6a6d045c95d058ca837f3246cdfcbf315a..4a666cab09622615d4116169076dcaba2ba87ad2 100644 (file)
@@ -19,9 +19,7 @@ try:
                # 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:
@@ -36,6 +34,14 @@ 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")
@@ -112,19 +118,6 @@ except ImportError, e:
        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')
@@ -189,6 +182,23 @@ if sys.hexversion >= 0x3000000:
        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
@@ -312,8 +322,6 @@ def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, followSymli
                        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)
@@ -1132,7 +1140,7 @@ class config(object):
        # 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",
@@ -1281,6 +1289,7 @@ class config(object):
                self._accept_license = None
                self._accept_license_str = None
                self._license_groups = {}
+               self._accept_properties = None
 
                self.virtuals = {}
                self.virts_p = {}
@@ -1367,6 +1376,8 @@ class config(object):
                        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):
@@ -1593,13 +1604,8 @@ class config(object):
                                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
 
@@ -1702,6 +1708,7 @@ class config(object):
                        self.pusedict = {}
                        self.pkeywordsdict = {}
                        self._plicensedict = {}
+                       self._ppropertiesdict = {}
                        self.punmaskdict = {}
                        abs_user_config = os.path.join(config_root, USER_CONFIG_PATH)
 
@@ -1766,6 +1773,17 @@ class config(object):
                                                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')
@@ -2167,6 +2185,7 @@ class config(object):
                        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
 
@@ -2200,6 +2219,35 @@ class config(object):
                                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(
@@ -2438,6 +2486,8 @@ class config(object):
                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')
 
@@ -2831,6 +2881,87 @@ class config(object):
                                        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.
@@ -2978,6 +3109,19 @@ class config(object):
                        # 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=[]
@@ -3280,10 +3424,8 @@ class config(object):
                        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)
@@ -4991,16 +5133,14 @@ def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
        """ 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:]
@@ -5254,16 +5394,14 @@ def _post_src_install_uid_fix(mysettings):
                        (_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 \
@@ -6204,18 +6342,11 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0,
                                        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
@@ -7752,6 +7883,7 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
        eapi = metadata["EAPI"]
        mygroups = settings._getKeywords(mycpv, metadata)
        licenses = metadata["LICENSE"]
+       properties = metadata["PROPERTIES"]
        slot = metadata["SLOT"]
        if eapi.startswith("-"):
                eapi = eapi[1:]
@@ -7828,6 +7960,20 @@ def getmaskingstatus(mycpv, settings=None, portdb=None):
        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):
index 1b5f530ceb458b3972527475c90d0a0f77729590..e3c35ec5d3185d99b03306fe4d4d6cfb5fd07cfe 100644 (file)
@@ -2,16 +2,15 @@
 # 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)
@@ -30,10 +29,8 @@ def getcontext():
        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(
@@ -47,10 +44,8 @@ def mkdir(target, refdir):
                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)
@@ -73,13 +68,13 @@ def setexec(ctx="\n"):
                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:
@@ -88,12 +83,9 @@ def spawn(selinux_type, spawn_func, mycommand, opt_name=None, **keywords):
                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(
index d9b85b18abdbc981abc62cf6c95f88caf238d7f6..7ee889a7cf18392a3f58a3923bd4ad26c1f6ecae 100644 (file)
@@ -999,12 +999,14 @@ class portdbapi(dbapi):
                                        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:
@@ -1110,12 +1112,14 @@ class portdbapi(dbapi):
                                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)
index 3ada2e1a5df4146c3a1d265192a3e644b998d330..46afe9bda3243668ce030d1093cbb9832d62b828 100644 (file)
@@ -34,19 +34,19 @@ from portage.localization import _
 
 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:
@@ -312,8 +312,7 @@ class LinkageMap(object):
                                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
@@ -1430,7 +1429,7 @@ class vardbapi(dbapi):
                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 = {}
@@ -1602,8 +1601,6 @@ class vardbapi(dbapi):
 
                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)
@@ -1635,9 +1632,7 @@ class vardbapi(dbapi):
                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:
@@ -1881,11 +1876,9 @@ class vardbapi(dbapi):
                        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)
@@ -2061,16 +2054,12 @@ class vardbapi(dbapi):
                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
@@ -2138,7 +2127,7 @@ class vardbapi(dbapi):
                        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)
@@ -3247,13 +3236,9 @@ class dblink(object):
                        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)))
@@ -3443,8 +3428,7 @@ class dblink(object):
                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:
@@ -3874,6 +3858,11 @@ class dblink(object):
                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
 
@@ -3961,17 +3950,13 @@ class dblink(object):
                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:]
 
@@ -4451,7 +4436,8 @@ class dblink(object):
                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
                
@@ -4474,9 +4460,6 @@ class dblink(object):
                        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]