From bbfa4a5d625d9ef267a81c046605b9aee9c0eebb Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 19 Feb 2010 10:14:15 +0000 Subject: [PATCH] Merged from trunk -r15350:15360 |15351 |Evaluate conditional USE deps for *DEPEND atoms saved in vdb entries. | |zmedico| | |15352 |Bug #304981 - Truncate the build log after successful fetch, instead of removing it, so as| |zmedico|not to interfere with tail -f. | |15353 |Prevent CHOST vdb entries from being created for virtual packages. | |zmedico| | |15354 |Make sure that config._accept_chost() accepts empty CHOST. | |zmedico| | |15355 |Use config.environ() instead of config.items() when spawning FETCHCOMMAND. | |zmedico| | |15356 |Add a 'trees' parameter to portdbapi.cp_all(). Thanks to Brian Dolbec (dol-sen) for this | |zmedico|patch. | |15357 |Add a BUILD_TIME vdb entry containing the integer number of seconds since the unix Epoch. | |zmedico|This will be useful for creating package sets that involve comparison of installed | | |packages to binary packages, especially for binhost users. See discussion here: | | |http://archives.gentoo.org/gentoo-portage-dev/msg_d068a8deefd179cc23808bc23f3de200.xml | |15358 |Cache BUILD_TIME in vdb_metadata.pickle. | |zmedico| | |15359 |Cache BUILD_TIME in Package.metadata. | |zmedico| | |15360 |Cache BUILD_TIME in $PKGDIR/Packages and inside bindbapi. | |zmedico| | svn path=/main/branches/prefix/; revision=15385 --- pym/_emerge/EbuildBuildDir.py | 7 ++++--- pym/_emerge/Package.py | 2 +- pym/portage/__init__.py | 26 +++++++++++++++++++++++--- pym/portage/dbapi/bintree.py | 15 +++++++++++++-- pym/portage/dbapi/porttree.py | 15 ++++++++++++--- pym/portage/dbapi/vartree.py | 9 ++++++++- 6 files changed, 61 insertions(+), 13 deletions(-) diff --git a/pym/_emerge/EbuildBuildDir.py b/pym/_emerge/EbuildBuildDir.py index d9e0fbb7b..b6fad9c14 100644 --- a/pym/_emerge/EbuildBuildDir.py +++ b/pym/_emerge/EbuildBuildDir.py @@ -64,10 +64,11 @@ class EbuildBuildDir(SlotObject): def clean_log(self): """Discard existing log.""" settings = self.settings - - for x in ('.logid', 'temp/build.log'): + log_file = settings.get('PORTAGE_LOG_FILE') + if log_file is not None and os.path.isfile(log_file): + # Truncate rather than unlink, so tail -f still works. try: - os.unlink(os.path.join(settings["PORTAGE_BUILDDIR"], x)) + open(log_file, 'wb') except OSError: pass diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index f9844ce45..df8232feb 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -28,7 +28,7 @@ class Package(Task): ("_use",) metadata_keys = [ - "CHOST", "COUNTER", "DEPEND", "EAPI", + "BUILD_TIME", "CHOST", "COUNTER", "DEPEND", "EAPI", "INHERITED", "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROVIDE", "RDEPEND", "repository", "PROPERTIES", "RESTRICT", "SLOT", "USE", "_mtime_", diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 6f5ec6424..5d4ffc967 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -3264,8 +3264,9 @@ class config(object): (" ".join(accept_chost), e), noiselevel=-1) self._accept_chost_re = re.compile("^$") - return self._accept_chost_re.match( - metadata.get('CHOST', '')) is not None + pkg_chost = metadata.get('CHOST', '') + return not pkg_chost or \ + self._accept_chost_re.match(pkg_chost) is not None def setinst(self,mycpv,mydbapi): """This updates the preferences for old-style virtuals, @@ -4264,7 +4265,7 @@ def _spawn_fetch(settings, args, **kwargs): if args[0] != BASH_BINARY: args = [BASH_BINARY, "-c", "exec \"$@\"", args[0]] + args - rval = spawn_func(args, env=dict(iter(settings.items())), **kwargs) + rval = spawn_func(args, env=settings.environ(), **kwargs) return rval @@ -5883,6 +5884,9 @@ def _post_src_install_chost_fix(settings): CHOST variable, so revert it to the initial setting. """ + if settings.get('CATEGORY') == 'virtual': + return + chost = settings.get('CHOST') if chost: write_atomic(os.path.join(settings['PORTAGE_BUILDDIR'], @@ -5890,6 +5894,7 @@ def _post_src_install_chost_fix(settings): _vdb_use_conditional_keys = ('DEPEND', 'LICENSE', 'PDEPEND', 'PROPERTIES', 'PROVIDE', 'RDEPEND', 'RESTRICT',) +_vdb_use_conditional_atoms = frozenset(['DEPEND', 'PDEPEND', 'RDEPEND']) def _post_src_install_uid_fix(mysettings, out=None): """ @@ -6001,6 +6006,11 @@ def _post_src_install_uid_fix(mysettings, out=None): 'w', encoding=_encodings['repo.content'], errors='strict').write(str(size) + '\n') + codecs.open(_unicode_encode(os.path.join(build_info_dir, + 'BUILD_TIME'), encoding=_encodings['fs'], errors='strict'), + 'w', encoding=_encodings['repo.content'], + errors='strict').write(str(int(time.time())) + '\n') + use = frozenset(mysettings['PORTAGE_USE'].split()) for k in _vdb_use_conditional_keys: v = mysettings.configdict['pkg'].get(k) @@ -6012,6 +6022,16 @@ def _post_src_install_uid_fix(mysettings, out=None): v = dep.paren_enclose(v) if not v: continue + if v in _vdb_use_conditional_atoms: + v_split = [] + for x in v.split(): + try: + x = dep.Atom(x) + except exception.InvalidAtom: + v_split.append(x) + else: + v_split.append(str(x.evaluate_conditionals(use))) + v = ' '.join(v_split) codecs.open(_unicode_encode(os.path.join(build_info_dir, k), encoding=_encodings['fs'], errors='strict'), mode='w', encoding=_encodings['repo.content'], diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index 41936d813..283981a47 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -50,7 +50,7 @@ class bindbapi(fakedbapi): self.cpdict={} # Selectively cache metadata in order to optimize dep matching. self._aux_cache_keys = set( - ["CHOST", "DEPEND", "EAPI", "IUSE", "KEYWORDS", + ["BUILD_TIME", "CHOST", "DEPEND", "EAPI", "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository", "RESTRICT", "SLOT", "USE", "EPREFIX"]) @@ -189,7 +189,7 @@ class binarytree(object): self._pkgindex_keys = self.dbapi._aux_cache_keys.copy() self._pkgindex_keys.update(["CPV", "MTIME", "SIZE"]) self._pkgindex_aux_keys = \ - ["CHOST", "DEPEND", "DESCRIPTION", "EAPI", + ["BUILD_TIME", "CHOST", "DEPEND", "DESCRIPTION", "EAPI", "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository", "SLOT", "USE", "EPREFIX"] @@ -203,6 +203,7 @@ class binarytree(object): "CHOST", "CONFIG_PROTECT", "CONFIG_PROTECT_MASK", "FEATURES", "GENTOO_MIRRORS", "INSTALL_MASK", "SYNC", "USE", "EPREFIX"]) self._pkgindex_default_pkg_data = { + "BUILD_TIME" : "", "DEPEND" : "", "EAPI" : "0", "IUSE" : "", @@ -1052,6 +1053,16 @@ class binarytree(object): writemsg("%s: %s\n" % (k, str(e)), noiselevel=-1) raise + if k in portage._vdb_use_conditional_atoms: + v_split = [] + for x in deps.split(): + try: + x = portage.dep.Atom(x) + except portage.exception.InvalidAtom: + v_split.append(x) + else: + v_split.append(str(x.evaluate_conditionals(raw_use))) + deps = ' '.join(v_split) metadata[k] = deps def exists_specific(self, cpv): diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index 5a845118d..6012cd414 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -901,13 +901,22 @@ class portdbapi(dbapi): else: return 0 - def cp_all(self, categories=None): - "returns a list of all keys in our tree" + def cp_all(self, categories=None, trees=None): + """ + This returns a list of all keys in our tree or trees + @param categories: optional list of categories to search or + defaults to self.settings.categories + @param trees: optional list of trees to search the categories in or + defaults to self.porttrees + @rtype list of [cat/pkg,...] + """ d = {} if categories is None: categories = self.settings.categories + if trees is None: + trees = self.porttrees for x in categories: - for oroot in self.porttrees: + for oroot in trees: for y in listdir(oroot+"/"+x, EmptyOnError=1, ignorecvs=1, dirsonly=1): if not self._pkg_dir_name_re.match(y) or \ y == "CVS": diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 25f92d402..e054db587 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -1816,7 +1816,7 @@ class vardbapi(dbapi): vartree = db[root]["vartree"] self.vartree = vartree self._aux_cache_keys = set( - ["CHOST", "COUNTER", "DEPEND", "DESCRIPTION", + ["BUILD_TIME", "CHOST", "COUNTER", "DEPEND", "DESCRIPTION", "EAPI", "HOMEPAGE", "IUSE", "KEYWORDS", "LICENSE", "PDEPEND", "PROPERTIES", "PROVIDE", "RDEPEND", "repository", "RESTRICT" , "SLOT", "USE"]) @@ -4450,6 +4450,13 @@ class dblink(object): slot = '' for var_name in ('CHOST', 'SLOT'): + if var_name == 'CHOST' and self.cat == 'virtual': + try: + os.unlink(os.path.join(inforoot, var_name)) + except OSError: + pass + continue + try: val = codecs.open(_unicode_encode( os.path.join(inforoot, var_name), -- 2.26.2