From: Fabian Groffen Date: Mon, 6 Jul 2009 18:38:26 +0000 (-0000) Subject: Merged from trunk -r13784:13794 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=27e9de2dc5f247d89e857658f300971863d7a819;p=portage.git Merged from trunk -r13784:13794 | 13785 | Assume utf_8 encoding when reading raw ebuild metadata. | | zmedico | | | 13786 | Make dblink.setfile() write environment.bz2 in binary mode. | | zmedico | | | 13787 | Remove set operator support since the current implementation | | zmedico | does not meet user expectations, as mentioned in bug | | | #253802, comment #5: Package set operators currently operate | | | on atoms, but what users really need is for them to operate | | | on the packages themselves. This will allow one set to add | | | or subtract packages from another even though the sets to | | | not use the exact same atoms to refer to the given packages. | | | I imagine the way this should be done is to create a mapping | | | of atom -> package for each set, perform the intersection | | | using the packages, and then map the package intersection | | | back into a set of atoms. | | 13788 | Bug #276264 - Note that eclass-overrides may make it | | zmedico | necessary to set | | | PORTAGE_RSYNC_EXTRA_OPTS="--exclude=/metadata/cache" in | | | make.conf. | | 13789 | Make sure avoid_update always returns existing_node if | | zmedico | available. | | 13790 | Fix broken reference to possible_upgrades inside | | zmedico | dep_zapdeps(). | | 13791 | Assume utf_8 encoding in alls reads/writes (unicode handling | | zmedico | required for py3k). | | 13792 | Hardcode utf_8 encoding inside _setitem(). | | zmedico | | | 13793 | Always exit unsuccessfully if there are any failures. | | zmedico | | | 13794 | Use PackageSet.findAtomForPackage() when matching the | | zmedico | existing node against the atom inside | | | _select_pkg_highest_available_imp(), for PROVIDE support. | svn path=/main/branches/prefix/; revision=13797 --- diff --git a/man/portage.5 b/man/portage.5 index 6f64af6bd..3a7043995 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -556,7 +556,12 @@ performed by these tools are inherently \fBnot\fR \fIsite\-specific\fR. \fBWARNING:\fR Use of \fBrepos.conf\fR is generally not recommended since resulting changes in eclass inheritance (especially due to \fBeclass\-overrides\fR) may trigger -performance issues under some circumstances (see \fBbug #124041\fR). +performance issues under some circumstances (see \fBbug #124041\fR). When +using \fBeclass\-overrides\fR, due to bug #276264, you must ensure that +your portage tree does not contain a metadata/cache/. For example, you +should set PORTAGE_RSYNC_EXTRA_OPTS="\-\-exclude=/metadata/cache" in +make.conf in order to exclude the metadata/cache/ directory during +\fBemerge\fR(1) \-\-sync operations. .I Example: .nf diff --git a/pym/_emerge/EbuildMetadataPhase.py b/pym/_emerge/EbuildMetadataPhase.py index 46db6a0f3..5d9401a07 100644 --- a/pym/_emerge/EbuildMetadataPhase.py +++ b/pym/_emerge/EbuildMetadataPhase.py @@ -123,7 +123,9 @@ class EbuildMetadataPhase(SubProcess): def _set_returncode(self, wait_retval): SubProcess._set_returncode(self, wait_retval) if self.returncode == os.EX_OK: - metadata_lines = "".join(self._raw_metadata).splitlines() + metadata_lines = u''.join(unicode(chunk, + encoding='utf_8', errors='replace') + for chunk in self._raw_metadata).splitlines() if len(portage.auxdbkeys) != len(metadata_lines): # Don't trust bash's returncode if the # number of lines is incorrect. diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 9b329a335..cb5db078b 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -926,7 +926,9 @@ class Scheduler(PollScheduler): noiselevel=-1) writemsg(prefix + "\n", noiselevel=-1) - return rval + if self._failed_pkgs_all: + return 1 + return os.EX_OK def _elog_listener(self, mysettings, key, logentries, fulltext): errors = portage.elog.filter_loglevels(logentries, ["ERROR"]) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 96a0967c5..47ddc4907 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -2002,6 +2002,7 @@ class depgraph(object): if not isinstance(atom, portage.dep.Atom): atom = portage.dep.Atom(atom) atom_cp = atom.cp + atom_set = InternalPackageSet(initial_atoms=(atom,)) existing_node = None myeb = None usepkgonly = "--usepkgonly" in self._frozen_config.myopts @@ -2137,7 +2138,9 @@ class depgraph(object): e_pkg = self._dynamic_config._slot_pkg_map[root].get(pkg.slot_atom) if not e_pkg: break - if portage.dep.match_from_list(atom, [e_pkg]): + # Use PackageSet.findAtomForPackage() + # for PROVIDE support. + if atom_set.findAtomForPackage(e_pkg): if highest_version and \ e_pkg.cp == atom_cp and \ e_pkg < highest_version and \ @@ -2225,6 +2228,8 @@ class depgraph(object): if len(matched_packages) > 1: if avoid_update: + if existing_node is not None: + return existing_node, existing_node for pkg in matched_packages: if pkg.installed: return pkg, existing_node diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index c71f67b74..19b9cf524 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -671,11 +671,6 @@ def expand_set_arguments(myfiles, myaction, root_config): ARG_START = "{" ARG_END = "}" - # WARNING: all operators must be of equal length - IS_OPERATOR = "/@" - DIFF_OPERATOR = "-@" - UNION_OPERATOR = "+@" - for i in range(0, len(myfiles)): if myfiles[i].startswith(SETPREFIX): start = 0 @@ -740,44 +735,7 @@ def expand_set_arguments(myfiles, myaction, root_config): unmerge_actions = ("unmerge", "prune", "clean", "depclean") for a in myfiles: - if a.startswith(SETPREFIX): - # support simple set operations (intersection, difference and union) - # on the commandline. Expressions are evaluated strictly left-to-right - if IS_OPERATOR in a or DIFF_OPERATOR in a or UNION_OPERATOR in a: - expression = a[len(SETPREFIX):] - expr_sets = [] - expr_ops = [] - while IS_OPERATOR in expression or DIFF_OPERATOR in expression or UNION_OPERATOR in expression: - is_pos = expression.rfind(IS_OPERATOR) - diff_pos = expression.rfind(DIFF_OPERATOR) - union_pos = expression.rfind(UNION_OPERATOR) - op_pos = max(is_pos, diff_pos, union_pos) - s1 = expression[:op_pos] - s2 = expression[op_pos+len(IS_OPERATOR):] - op = expression[op_pos:op_pos+len(IS_OPERATOR)] - if not s2 in sets: - display_missing_pkg_set(root_config, s2) - return (None, 1) - expr_sets.insert(0, s2) - expr_ops.insert(0, op) - expression = s1 - if not expression in sets: - display_missing_pkg_set(root_config, expression) - return (None, 1) - expr_sets.insert(0, expression) - result = set(setconfig.getSetAtoms(expression)) - for i in range(0, len(expr_ops)): - s2 = setconfig.getSetAtoms(expr_sets[i+1]) - if expr_ops[i] == IS_OPERATOR: - result.intersection_update(s2) - elif expr_ops[i] == DIFF_OPERATOR: - result.difference_update(s2) - elif expr_ops[i] == UNION_OPERATOR: - result.update(s2) - else: - raise NotImplementedError("unknown set operator %s" % expr_ops[i]) - newargs.extend(result) - else: + if a.startswith(SETPREFIX): s = a[len(SETPREFIX):] if s not in sets: display_missing_pkg_set(root_config, s) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 762c3c1aa..dc47cb13a 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -6095,7 +6095,8 @@ def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, if not mybytes[-1]: break os.close(pr) - mybytes = "".join(mybytes) + mybytes = u''.join(unicode(chunk, + encoding='utf_8', errors='replace') for chunk in mybytes) global auxdbkeys for k, v in izip(auxdbkeys, mybytes.splitlines()): dbkey[k] = v @@ -7188,7 +7189,7 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0, trees=None): else: preferred_any_slot.append(this_choice) elif graph_db is None: - possible_upgrades.append(this_choice) + preferred_non_installed.append(this_choice) else: all_in_graph = True for slot_atom in versions: diff --git a/pym/portage/cache/flat_hash.py b/pym/portage/cache/flat_hash.py index ac1b7f190..71ddf6023 100644 --- a/pym/portage/cache/flat_hash.py +++ b/pym/portage/cache/flat_hash.py @@ -3,6 +3,7 @@ # License: GPL2 # $Id$ +import codecs from portage.cache import fs_template from portage.cache import cache_errors import errno, os, stat @@ -26,7 +27,7 @@ class database(fs_template.FsBased): def _getitem(self, cpv): fp = os.path.join(self.location, cpv) try: - myf = open(fp, "r") + myf = codecs.open(fp, mode='r', encoding='utf_8', errors='replace') try: d = self._parse_data(myf, cpv) if '_mtime_' not in d: @@ -54,12 +55,14 @@ class database(fs_template.FsBased): s = cpv.rfind("/") fp = os.path.join(self.location,cpv[:s],".update.%i.%s" % (os.getpid(), cpv[s+1:])) try: - myf = open(fp, 'w') + myf = codecs.open(fp, mode='w', + encoding='utf_8', errors='replace') except (IOError, OSError), e: if errno.ENOENT == e.errno: try: self._ensure_dirs(cpv) - myf=open(fp,"w") + myf = codecs.open(fp, mode='w', + encoding='utf_8', errors='replace') except (OSError, IOError),e: raise cache_errors.CacheCorruption(cpv, e) else: diff --git a/pym/portage/cache/metadata.py b/pym/portage/cache/metadata.py index e988451f4..724dce3cc 100644 --- a/pym/portage/cache/metadata.py +++ b/pym/portage/cache/metadata.py @@ -78,13 +78,12 @@ class database(flat_hash.database): new_content = [] for k in self.auxdbkey_order: - new_content.append(unicode(values.get(k, ''), errors='replace')) + new_content.append(values.get(k, u'')) new_content.append(u'\n') for i in xrange(magic_line_count - len(self.auxdbkey_order)): new_content.append(u'\n') new_content = u''.join(new_content) - new_content = new_content.encode( - sys.getdefaultencoding(), 'backslashreplace') + new_content = new_content.encode('utf_8', 'replace') new_fp = os.path.join(self.location, cpv) try: diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 76d2b5d8a..62fcd9b44 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -4549,7 +4549,10 @@ class dblink(object): return mydata def setfile(self,fname,data): - write_atomic(os.path.join(self.dbdir, fname), data) + mode = 'w' + if fname == 'environment.bz2' or not isinstance(data, basestring): + mode = 'wb' + write_atomic(os.path.join(self.dbdir, fname), data, mode=mode) def getelements(self,ename): if not os.path.exists(self.dbdir+"/"+ename):