From e034b36a61c6ec5656e2abd8175cae140acb4eec Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Sun, 13 Sep 2009 18:56:52 +0000 Subject: [PATCH] Merged from trunk -r14200:14209 | 14201 | Use _unicode_decode() on the string returned from | | zmedico | time.strftime(), in order to avoid a potential | | | UnicodeDecodeError later. Thanks to Markus Duft | | | for reporting. | | 14202 | Inside Scheduler._check_manifests(), display all broken | | zmedico | manifests instead of returning after the first one. Thanks | | | to Vlastimil Babka for the suggestion. | | 14203 | Add a vardbapi._pkgs_changed attribute to use instead of | | zmedico | PORTAGE_COUNTER_HASH for emerge to check whether any | | | packages have been added/removed. This is an optimization, | | | since vardbapi._counter_hash() can be somewhat slow on | | | embedded systems. Thanks to Marat Radchenko | | | for reporting. | | 14204 | Add ACCEPT_LICENSE and ACCEPT_PROPERTIES to the Packages | | zmedico | file header. | | 14205 | Document ACCEPT_LICENSE and package.license. | | zmedico | | | 14206 | Document ACCEPT_PROPERTIES and package.properties. | | zmedico | | | 14207 | Remove unused vardbapi._counter_hash() method. | | zmedico | | | 14208 | In display_news_notification(), use the exising vartree | | zmedico | instance to populate settings.treeVirtuals, to avoid having | | | a temporary one instantiated. Thanks to Marat Radchenko | | | for reporting. | | 14209 | Handle AttributeError instead of using getattr. Thanks to | | zmedico | Marat Radchenko for reporting. | svn path=/main/branches/prefix/; revision=14243 --- man/emerge.1 | 16 ++++++++++++++++ man/make.conf.5 | 11 +++++++++++ man/portage.5 | 20 ++++++++++++++++++++ pym/_emerge/Scheduler.py | 6 +++++- pym/_emerge/Task.py | 6 +++--- pym/_emerge/actions.py | 6 ++++++ pym/_emerge/main.py | 15 ++++++--------- pym/portage/__init__.py | 6 +++--- pym/portage/dbapi/bintree.py | 4 +++- pym/portage/dbapi/vartree.py | 25 ++++++------------------- pym/portage/elog/mod_mail_summary.py | 7 ++++++- pym/portage/elog/mod_save.py | 5 ++++- pym/portage/glsa.py | 3 ++- 13 files changed, 91 insertions(+), 39 deletions(-) diff --git a/man/emerge.1 b/man/emerge.1 index acc2dc8d3..683af7e38 100644 --- a/man/emerge.1 +++ b/man/emerge.1 @@ -652,6 +652,22 @@ variable to allow or disallow the emerging of a package masked by versions of packages, you should update your \fI/etc/portage/package.keywords\fR file to list the packages you want the \'testing\' version. See \fBportage\fR(5) for more information. +.TP +.BR LICENSE +The \fBLICENSE\fR variable in an \fBebuild\fR file can be used to mask +packages based on licensing restrictions. \fBemerge\fR examines the +\fBACCEPT_LICENSE\fR environment variable to allow or disallow the emerging +of a package masked by \fBLICENSE\fR. See \fBmake.conf\fR(5) for information +about \fBACCEPT_LICENSE\fR, and see \fBportage\fR(5) for information about +\fI/etc/portage/package.license\fR. +.TP +.BR PROPERTIES +The \fBPROPERTIES\fR variable in an \fBebuild\fR file can be used to mask +packages based on properties restrictions. \fBemerge\fR examines the +\fBACCEPT_PROPERTIES\fR environment variable to allow or disallow the emerging +of a package masked by \fBPROPERTIES\fR. See \fBmake.conf\fR(5) for information +about \fBACCEPT_PROPERTIES\fR, and see \fBportage\fR(5) for information about +\fI/etc/portage/package.properties\fR. .SH "CONFIGURATION FILES" Portage has a special feature called "config file protection". The purpose of this feature is to prevent new package installs from clobbering existing diff --git a/man/make.conf.5 b/man/make.conf.5 index 229e50b3f..be4b1ab9d 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -36,6 +36,17 @@ set this to '~ppc'. This is an incremental variable. Only define a .br Defaults to the value of $ARCH. .TP +\fBACCEPT_LICENSE\fR = \fI[space delimited list of licenses or groups]\fR +This variable is used to mask packages based on licensing restrictions. +.br +Defaults to the value of * -@EULA. +.TP +\fBACCEPT_PROPERTIES\fR = \fI[space delimited list of properties]\fR +This variable is used to mask packages based on PROPERTIES restrictions. +See \fBebuild\fR(5) for more information about PROPERTIES. +.br +Defaults to the value of *. +.TP .B CBUILD This variable is passed by the \fIebuild scripts\fR to the \fIconfigure\fR as \fI\-\-build=${CBUILD}\fR only if it is defined. Do not set this yourself diff --git a/man/portage.5 b/man/portage.5 index 9ce5b5552..36805f815 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -51,7 +51,9 @@ color.map mirrors modules package.keywords +package.license package.mask +package.properties package.unmask package.use repos.conf @@ -512,6 +514,15 @@ package.keywords like this: games-fps/quake3-demo x86 +.TP +.BR package.license +This will allow ACCEPT_LICENSE to be augmented for a single package. + +.I Format: +.nf +\- comment lines begin with # (no inline comments) +\- one DEPEND atom per line followed by additional licenses or groups +.fi .TP .BR package.mask A list of package atoms to mask. Useful if specific versions of packages do @@ -532,6 +543,15 @@ versions earlier than 1.0.4496. No problem! >=media\-video/nvidia\-glx\-1.0.4496 .fi .TP +.BR package.properties +This will allow ACCEPT_PROPERTIES to be augmented for a single package. + +.I Format: +.nf +\- comment lines begin with # (no inline comments) +\- one DEPEND atom per line followed by additional properties +.fi +.TP .BR package.unmask Just like package.mask above, except here you list packages you want to unmask. Useful for overriding the global package.mask file (see diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 6a44d0e2f..06074c932 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -607,6 +607,8 @@ class Scheduler(PollScheduler): quiet_settings[myroot] = quiet_config del quiet_config + failures = 0 + for x in self._mergelist: if not isinstance(x, Package) or \ x.type_name != "ebuild": @@ -624,8 +626,10 @@ class Scheduler(PollScheduler): quiet_config = quiet_settings[root_config.root] quiet_config["O"] = os.path.dirname(portdb.findname(x.cpv)) if not portage.digestcheck([], quiet_config, strict=True): - return 1 + failures |= 1 + if failures: + return 1 return os.EX_OK def _add_prefetchers(self): diff --git a/pym/_emerge/Task.py b/pym/_emerge/Task.py index d218ba360..0cd545500 100644 --- a/pym/_emerge/Task.py +++ b/pym/_emerge/Task.py @@ -7,10 +7,10 @@ class Task(SlotObject): __slots__ = ("_hash_key", "_hash_value") def _get_hash_key(self): - hash_key = getattr(self, "_hash_key", None) - if hash_key is None: + try: + return self._hash_key + except AttributeError: raise NotImplementedError(self) - return hash_key def __eq__(self, other): return self._get_hash_key() == other diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 1fc509114..10d657719 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -2674,6 +2674,12 @@ def display_news_notification(root_config, myopts): newsReaderDisplay = False update = "--pretend" not in myopts + if not settings.treeVirtuals: + # Populate these using our existing vartree, to avoid + # having a temporary one instantiated. + settings.treeVirtuals = portage.util.map_dictlist_vals( + portage.getCPFromCPV, trees["vartree"].get_all_provides()) + for repo in portdb.getRepositories(): unreadItems = checkUpdatedNewsItems( portdb, vardb, NEWS_PATH, UNREAD_PATH, repo, update=update) diff --git a/pym/_emerge/main.py b/pym/_emerge/main.py index 19f076c41..25726265c 100644 --- a/pym/_emerge/main.py +++ b/pym/_emerge/main.py @@ -9,6 +9,8 @@ import textwrap import platform import portage from portage import os +from portage import _encodings +from portage import _unicode_decode import _emerge.help import portage.xpak, commands, errno, re, time from portage.output import colorize, xtermTitle, xtermTitleReset @@ -313,9 +315,7 @@ def post_emerge(root_config, myopts, mtimedb, retval): _flush_elog_mod_echo() - counter_hash = settings.get("PORTAGE_COUNTER_HASH") - if "--pretend" in myopts or (counter_hash is not None and \ - counter_hash == vardbapi._counter_hash()): + if not vardbapi._pkgs_changed: display_news_notification(root_config, myopts) # If vdb state has not changed then there's nothing else to do. sys.exit(retval) @@ -1074,11 +1074,6 @@ def emerge_main(): mysettings = trees[myroot]["vartree"].settings mysettings.unlock() adjust_config(myopts, mysettings) - if '--pretend' not in myopts and myaction in \ - (None, 'clean', 'depclean', 'prune', 'unmerge'): - mysettings["PORTAGE_COUNTER_HASH"] = \ - trees[myroot]["vartree"].dbapi._counter_hash() - mysettings.backup_changes("PORTAGE_COUNTER_HASH") mysettings.lock() del myroot, mysettings @@ -1298,7 +1293,9 @@ def emerge_main(): if not "--pretend" in myopts: emergelog(xterm_titles, "Started emerge on: "+\ - time.strftime("%b %d, %Y %H:%M:%S", time.localtime())) + _unicode_decode( + time.strftime("%b %d, %Y %H:%M:%S", time.localtime()), + encoding=_encodings['content'], errors='replace')) myelogstr="" if myopts: myelogstr=" ".join(myopts) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index d69ef042d..274af0573 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -1445,7 +1445,6 @@ class config(object): "GENTOO_MIRRORS", "NOCONFMEM", "O", "PORTAGE_BACKGROUND", "PORTAGE_BINHOST_CHUNKSIZE", "PORTAGE_CALLER", - "PORTAGE_COUNTER_HASH", "PORTAGE_ELOG_CLASSES", "PORTAGE_ELOG_MAILFROM", "PORTAGE_ELOG_MAILSUBJECT", "PORTAGE_ELOG_MAILURI", "PORTAGE_ELOG_SYSTEM", @@ -6292,8 +6291,9 @@ def _prepare_workdir(mysettings): logid_path = os.path.join(mysettings["PORTAGE_BUILDDIR"], ".logid") if not os.path.exists(logid_path): open(_unicode_encode(logid_path), 'w') - logid_time = time.strftime("%Y%m%d-%H%M%S", - time.gmtime(os.stat(logid_path).st_mtime)) + logid_time = _unicode_decode(time.strftime("%Y%m%d-%H%M%S", + time.gmtime(os.stat(logid_path).st_mtime)), + encoding=_encodings['content'], errors='replace') mysettings["PORTAGE_LOG_FILE"] = os.path.join( mysettings["PORT_LOGDIR"], "%s:%s:%s.log" % \ (mysettings["CATEGORY"], mysettings["PF"], logid_time)) diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 8fbe0c977..57fc62794 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -188,7 +188,9 @@ class binarytree(object): self._pkgindex_use_evaluated_keys = \ ("LICENSE", "RDEPEND", "DEPEND", "PDEPEND", "PROPERTIES", "PROVIDE") - self._pkgindex_header_keys = set(["ACCEPT_KEYWORDS", "CBUILD", + self._pkgindex_header_keys = set([ + "ACCEPT_KEYWORDS", "ACCEPT_LICENSE", + "ACCEPT_PROPERTIES", "CBUILD", "CHOST", "CONFIG_PROTECT", "CONFIG_PROTECT_MASK", "FEATURES", "GENTOO_MIRRORS", "INSTALL_MASK", "SYNC", "USE", "EPREFIX"]) self._pkgindex_default_pkg_data = { diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 91262c200..42b51e337 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1498,6 +1498,10 @@ class vardbapi(dbapi): self.root = _unicode_decode(root, encoding=_encodings['content'], errors='strict') + # Used by emerge to check whether any packages + # have been added or removed. + self._pkgs_changed = False + #cache for category directory mtimes self.mtdircache = {} @@ -1565,25 +1569,6 @@ class vardbapi(dbapi): level=logging.ERROR, noiselevel=-1) return 0 - def _counter_hash(self): - try: - from hashlib import md5 as new_hash - except ImportError: - from md5 import new as new_hash - h = new_hash() - aux_keys = ["COUNTER"] - cpv_list = self.cpv_all() - cpv_list.sort() - for cpv in cpv_list: - try: - counter, = self.aux_get(cpv, aux_keys) - except KeyError: - continue - h.update(_unicode_encode(counter, - encoding=_encodings['repo.content'], - errors='backslashreplace')) - return h.hexdigest() - def cpv_inject(self, mycpv): "injects a real package into our on-disk database; assumes mycpv is valid and doesn't already exist" os.makedirs(self.getpath(mycpv)) @@ -1757,9 +1742,11 @@ class vardbapi(dbapi): self._aux_cache_obj = None def _add(self, pkg_dblink): + self._pkgs_changed = True self._clear_pkg_cache(pkg_dblink) def _remove(self, pkg_dblink): + self._pkgs_changed = True self._clear_pkg_cache(pkg_dblink) def _clear_pkg_cache(self, pkg_dblink): diff --git a/pym/portage/elog/mod_mail_summary.py b/pym/portage/elog/mod_mail_summary.py index adffd4640..e642dc044 100644 --- a/pym/portage/elog/mod_mail_summary.py +++ b/pym/portage/elog/mod_mail_summary.py @@ -8,6 +8,8 @@ from portage.exception import PortageException from portage.localization import _ from portage.util import writemsg from portage import os +from portage import _encodings +from portage import _unicode_decode import socket import time @@ -15,8 +17,11 @@ import time _items = {} def process(mysettings, key, logentries, fulltext): global _items + time_str = _unicode_decode( + time.strftime("%Y%m%d-%H%M%S %Z", time.localtime(time.time())), + encoding=_encodings['content'], errors='replace') header = _(">>> Messages generated for package %(pkg)s by process %(pid)d on %(time)s:\n\n") % \ - {"pkg": key, "pid": os.getpid(), "time": time.strftime("%Y%m%d-%H%M%S %Z", time.localtime(time.time()))} + {"pkg": key, "pid": os.getpid(), "time": time_str} config_root = mysettings["PORTAGE_CONFIGROOT"] mysettings, items = _items.setdefault(config_root, (mysettings, {})) items[key] = header + fulltext diff --git a/pym/portage/elog/mod_save.py b/pym/portage/elog/mod_save.py index ca76e23be..fedccbeeb 100644 --- a/pym/portage/elog/mod_save.py +++ b/pym/portage/elog/mod_save.py @@ -7,6 +7,7 @@ import codecs import time from portage import os from portage import _encodings +from portage import _unicode_decode from portage import _unicode_encode from portage.data import portage_uid, portage_gid from portage.util import ensure_dirs @@ -21,7 +22,9 @@ def process(mysettings, key, logentries, fulltext): elogdir = os.path.join(EPREFIX, "var", "log", "portage", "elog") ensure_dirs(elogdir, uid=portage_uid, gid=portage_gid, mode=02770) - elogfilename = elogdir+"/"+path+":"+time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time()))+".log" + elogfilename = os.path.join(elogdir, path + ":" + _unicode_decode( + time.strftime("%Y%m%d-%H%M%S", time.gmtime(time.time())), + encoding=_encodings['content'], errors='replace') + ".log") elogfile = codecs.open(_unicode_encode(elogfilename, encoding=_encodings['fs'], errors='strict'), mode='w', encoding=_encodings['content'], errors='backslashreplace') diff --git a/pym/portage/glsa.py b/pym/portage/glsa.py index 6dc73ac67..95c3c813c 100644 --- a/pym/portage/glsa.py +++ b/pym/portage/glsa.py @@ -404,7 +404,8 @@ def format_date(datestr): return datestr # TODO We could format to local date format '%x' here? - return d.strftime("%B %d, %Y") + return _unicode_decode(d.strftime("%B %d, %Y"), + encoding=_encodings['content'], errors='replace') # simple Exception classes to catch specific errors class GlsaTypeException(Exception): -- 2.26.2