From f22acc4fdac3598e9e46ad7927f98aa95b41a380 Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Wed, 18 Nov 2009 21:17:00 +0000 Subject: [PATCH] Merged from trunk -r14813:14819 | 14814 | Bug #292664 - Show ACCEPT_LICENSE in emerge --info. | | zmedico | | | 14815 | Inside iter_owners, only cache a maximum of 25 dblink | | zmedico | instances, in order to avoid potentially running out of | | | memory. | | 14816 | Add setup phases to the tail of the merge queue instead of | | zmedico | the front, since otherwise when merging binary packages we | | | sometimes tend to get a large number of setup phases | | | flooding the queue and preventing queued installs from | | | running. | | 14817 | Implement dblink.__hash__ and __eq__, so that `portageq | | zmedico | owners` correctly groups search results. Also, increase | | | iter_owners dblink cache size from 25 to 100 instances. | | 14818 | Bug #292910 - Don't mix print() and writemsg_stdout(), in | | zmedico | order to avoid buffering issues. | | 14819 | Bug #292820 - Make the Package constructor handle invalid | | zmedico | SLOT values. | svn path=/main/branches/prefix/; revision=14847 --- bin/repoman | 1 + man/repoman.1 | 2 ++ pym/_emerge/Package.py | 6 ++++-- pym/_emerge/Scheduler.py | 2 +- pym/_emerge/actions.py | 3 ++- pym/_emerge/search.py | 28 ++++++++++++++++------------ pym/portage/dbapi/vartree.py | 14 ++++++++++++++ 7 files changed, 40 insertions(+), 16 deletions(-) diff --git a/bin/repoman b/bin/repoman index 18a37df7b..8033a7679 100755 --- a/bin/repoman +++ b/bin/repoman @@ -281,6 +281,7 @@ qahelp={ "EAPI.definition":"EAPI is defined after an inherit call (must be defined before)", "EAPI.incompatible":"Ebuilds that use features that are only available with a different EAPI", "EAPI.unsupported":"Ebuilds that have an unsupported EAPI version (you must upgrade portage)", + "SLOT.invalid":"Ebuilds that have an invalid SLOT variable value", "SLOT.missing":"Ebuilds that have a missing or empty SLOT variable", "HOMEPAGE.missing":"Ebuilds that have a missing or empty HOMEPAGE variable", "DEPEND.bad":"User-visible ebuilds with bad DEPEND settings (matched against *visible* ebuilds)", diff --git a/man/repoman.1 b/man/repoman.1 index 4ca110fab..5fab376b6 100644 --- a/man/repoman.1 +++ b/man/repoman.1 @@ -206,6 +206,8 @@ Syntax error in PROPERTIES (usually an extra/missing space/parenthesis) .TP .B RESTRICT.syntax Syntax error in RESTRICT (usually an extra/missing space/parenthesis) +.B SLOT.invalid +Ebuilds that have an invalid SLOT variable value .TP .B SLOT.missing Ebuilds that have a missing or empty SLOT variable diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index e07c8fc4b..be678185d 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -8,7 +8,7 @@ from itertools import chain import portage from portage.cache.mappings import slot_dict_class from portage.dep import paren_reduce, use_reduce, \ - paren_normalize, paren_enclose + paren_normalize, paren_enclose, _slot_re from _emerge.Task import Task if sys.hexversion >= 0x3000000: @@ -41,7 +41,9 @@ class Package(Task): self.metadata['CHOST'] = self.root_config.settings.get('CHOST', '') self.cp = portage.cpv_getkey(self.cpv) slot = self.slot - if not slot: + if _slot_re.match(slot) is None: + self._invalid_metadata('SLOT.invalid', + "SLOT: invalid value: '%s'" % slot) # Avoid an InvalidAtom exception when creating slot_atom. # This package instance will be masked due to empty SLOT. slot = '0' diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 1f37a5f0c..dcd2e47c7 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -436,7 +436,7 @@ class Scheduler(PollScheduler): Schedule a setup phase on the merge queue, in order to serialize unsandboxed access to the live filesystem. """ - self._task_queues.merge.addFront(setup_phase) + self._task_queues.merge.add(setup_phase) self._schedule() def _schedule_unpack(self, unpack_phase): diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 0e3a043d6..6aa247c09 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -1269,7 +1269,8 @@ def action_info(settings, trees, myopts, myfiles): myvars = ['GENTOO_MIRRORS', 'CONFIG_PROTECT', 'CONFIG_PROTECT_MASK', 'PORTDIR', 'DISTDIR', 'PKGDIR', 'PORTAGE_TMPDIR', 'PORTDIR_OVERLAY', 'USE', 'CHOST', 'CFLAGS', 'CXXFLAGS', - 'ACCEPT_KEYWORDS', 'SYNC', 'FEATURES', 'EMERGE_DEFAULT_OPTS'] + 'ACCEPT_KEYWORDS', 'ACCEPT_LICENSE', 'SYNC', 'FEATURES', + 'EMERGE_DEFAULT_OPTS'] myvars.extend(portage.util.grabfile(settings["PORTDIR"]+"/profiles/info_vars")) diff --git a/pym/_emerge/search.py b/pym/_emerge/search.py index f0611f28a..e5ad91da2 100644 --- a/pym/_emerge/search.py +++ b/pym/_emerge/search.py @@ -262,9 +262,11 @@ class search(object): def output(self): """Outputs the results of the search.""" - print("\b\b \n[ Results for search key : "+white(self.searchkey)+" ]") - print("[ Applications found : "+white(str(self.mlen))+" ]") - print(" ") + msg = [] + msg.append("\b\b \n[ Results for search key : " + \ + bold(self.searchkey) + " ]\n") + msg.append("[ Applications found : " + \ + bold(str(self.mlen)) + " ]\n\n") vardb = self.vartree.dbapi for mtype in self.matches: for match,masked in self.matches[mtype]: @@ -282,7 +284,6 @@ class search(object): full_package = match match = portage.cpv_getkey(match) elif mtype == "set": - msg = [] msg.append(green("*") + " " + bold(match) + "\n") if self.verbose: msg.append(" " + darkgreen("Description:") + \ @@ -295,12 +296,13 @@ class search(object): desc, homepage, license = self.portdb.aux_get( full_package, ["DESCRIPTION","HOMEPAGE","LICENSE"]) except KeyError: - print("emerge: search: aux_get() failed, skipping") + msg.append("emerge: search: aux_get() failed, skipping\n") continue if masked: - print(green("*")+" "+white(match)+" "+red("[ Masked ]")) + msg.append(green("*") + " " + \ + white(match) + " " + red("[ Masked ]") + "\n") else: - print(green("*")+" "+white(match)) + msg.append(green("*") + " " + bold(match) + "\n") myversion = self.getVersion(full_package, search.VERSION_RELEASE) mysum = [0,0] @@ -349,12 +351,14 @@ class search(object): file_size_str = mystr + " kB" if self.verbose: - msg = [] if available: - print(" ", darkgreen("Latest version available:"),myversion) - print(" ", self.getInstallationStatus(mycat+'/'+mypkg)) + msg.append(" %s %s\n" % \ + (darkgreen("Latest version available:"), + myversion)) + msg.append(" %s\n" % \ + self.getInstallationStatus(mycat+'/'+mypkg)) if myebuild: - print(" %s %s" % \ + msg.append(" %s %s\n" % \ (darkgreen("Size of files:"), file_size_str)) msg.append(" " + darkgreen("Homepage:") + \ " " + homepage + "\n") @@ -362,7 +366,7 @@ class search(object): + " " + desc + "\n") msg.append(" " + darkgreen("License:") + \ " " + license + "\n\n") - writemsg_stdout(''.join(msg), noiselevel=-1) + writemsg_stdout(''.join(msg), noiselevel=-1) # # private interface # diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index c42a85ac3..a2a40c540 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -49,6 +49,7 @@ from portage import _unicode_encode from portage.cache.mappings import slot_dict_class import codecs +from collections import deque import re, shutil, stat, errno, copy, subprocess import logging import os as _os @@ -2582,12 +2583,17 @@ class vardbapi(dbapi): base_names = self._vardb._aux_cache["owners"]["base_names"] dblink_cache = {} + dblink_fifo = deque() def dblink(cpv): x = dblink_cache.get(cpv) if x is None: + if len(dblink_fifo) >= 100: + # Ensure that we don't run out of memory. + del dblink_cache[dblink_fifo.popleft().mycpv] x = self._vardb._dblink(cpv) dblink_cache[cpv] = x + dblink_fifo.append(x) return x for path in path_iter: @@ -2876,6 +2882,14 @@ class dblink(object): self._contents_basenames = None self._linkmap_broken = False self._md5_merge_map = {} + self._hash_key = (self.myroot, self.mycpv) + + def __hash__(self): + return hash(self._hash_key) + + def __eq__(self, other): + return isinstance(other, dblink) and \ + self._hash_key == other._hash_key def lockdb(self): if self._lock_vdb: -- 2.26.2