From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1NlRut-00023E-8p for garchives@archives.gentoo.org; Sat, 27 Feb 2010 19:01:32 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B089FE07D4; Sat, 27 Feb 2010 19:01:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 41E7CE07D4 for ; Sat, 27 Feb 2010 19:01:28 +0000 (UTC) Received: from stork.gentoo.org (stork.gentoo.org [64.127.104.133]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTP id BCF2C1B40FE for ; Sat, 27 Feb 2010 19:01:27 +0000 (UTC) Received: from grobian by stork.gentoo.org with local (Exim 4.69) (envelope-from ) id 1NlRup-0008Hz-AY for gentoo-commits@lists.gentoo.org; Sat, 27 Feb 2010 19:01:27 +0000 To: gentoo-commits@lists.gentoo.org From: "Fabian Groffen (grobian)" Subject: [gentoo-commits] portage r15480 - in main/branches/prefix/pym/portage: . dbapi package/ebuild util X-VCS-Repository: portage X-VCS-Revision: 15480 X-VCS-Files: main/branches/prefix/pym/portage/util/listdir.py main/branches/prefix/pym/portage/__init__.py main/branches/prefix/pym/portage/dbapi/bintree.py main/branches/prefix/pym/portage/dbapi/porttree.py main/branches/prefix/pym/portage/dbapi/vartree.py main/branches/prefix/pym/portage/package/ebuild/doebuild.py main/branches/prefix/pym/portage/util/digraph.py X-VCS-Directories: . dbapi package/ebuild util X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen Content-Type: text/plain; charset=UTF-8 Message-Id: Sender: Fabian Groffen Date: Sat, 27 Feb 2010 19:01:27 +0000 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 8734f229-df95-4983-9e1f-f9d5453458f0 X-Archives-Hash: 865c928703ad206248882ee78f8609ec Author: grobian Date: 2010-02-27 19:01:26 +0000 (Sat, 27 Feb 2010) New Revision: 15480 Added: main/branches/prefix/pym/portage/util/listdir.py Modified: main/branches/prefix/pym/portage/__init__.py main/branches/prefix/pym/portage/dbapi/bintree.py main/branches/prefix/pym/portage/dbapi/porttree.py main/branches/prefix/pym/portage/dbapi/vartree.py main/branches/prefix/pym/portage/package/ebuild/doebuild.py main/branches/prefix/pym/portage/util/digraph.py Log: Merged from trunk -r15449:15451 | 15450 | Move cacheddir and listdir to portage.util.listdir. = | | zmedico | = | =20 | 15451 | Fix broken references to = | | zmedico | portage._doebuild_manifest_exempt_depend. = | Modified: main/branches/prefix/pym/portage/__init__.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/__init__.py 2010-02-27 18:53:28 UTC = (rev 15479) +++ main/branches/prefix/pym/portage/__init__.py 2010-02-27 19:01:26 UTC = (rev 15480) @@ -122,6 +122,7 @@ 'stack_lists,unique_array,varexpand,writedict,writemsg,' + \ 'writemsg_stdout,write_atomic', 'portage.util.digraph:digraph', + 'portage.util.listdir:cacheddir,listdir', 'portage.versions', 'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,' + \ 'cpv_getkey@getCPFromCPV,endversion_keys,' + \ @@ -534,145 +535,6 @@ mylink=3Dmydir+"/"+mylink return os.path.normpath(mylink) =20 -dircache =3D {} -cacheHit=3D0 -cacheMiss=3D0 -cacheStale=3D0 -def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, fol= lowSymlinks=3DTrue): - global cacheHit,cacheMiss,cacheStale - mypath =3D normalize_path(my_original_path) - if mypath in dircache: - cacheHit +=3D 1 - cached_mtime, list, ftype =3D dircache[mypath] - else: - cacheMiss +=3D 1 - cached_mtime, list, ftype =3D -1, [], [] - try: - pathstat =3D os.stat(mypath) - if stat.S_ISDIR(pathstat[stat.ST_MODE]): - mtime =3D pathstat.st_mtime - else: - raise portage.exception.DirectoryNotFound(mypath) - except EnvironmentError as e: - if e.errno =3D=3D portage.exception.PermissionDenied.errno: - raise portage.exception.PermissionDenied(mypath) - del e - return [], [] - except portage.exception.PortageException: - return [], [] - # Python retuns mtime in seconds, so if it was changed in the last few = seconds, it could be invalid - if mtime !=3D cached_mtime or time.time() - mtime < 4: - if mypath in dircache: - cacheStale +=3D 1 - try: - list =3D os.listdir(mypath) - except EnvironmentError as e: - if e.errno !=3D errno.EACCES: - raise - del e - raise portage.exception.PermissionDenied(mypath) - ftype =3D [] - for x in list: - try: - if followSymlinks: - pathstat =3D os.stat(mypath+"/"+x) - else: - pathstat =3D os.lstat(mypath+"/"+x) - - if stat.S_ISREG(pathstat[stat.ST_MODE]): - ftype.append(0) - elif stat.S_ISDIR(pathstat[stat.ST_MODE]): - ftype.append(1) - elif stat.S_ISLNK(pathstat[stat.ST_MODE]): - ftype.append(2) - else: - ftype.append(3) - except (IOError, OSError): - ftype.append(3) - dircache[mypath] =3D mtime, list, ftype - - ret_list =3D [] - ret_ftype =3D [] - for x in range(0, len(list)): - if list[x] in ignorelist: - pass - elif ignorecvs: - if list[x][:2] !=3D ".#": - ret_list.append(list[x]) - ret_ftype.append(ftype[x]) - else: - ret_list.append(list[x]) - ret_ftype.append(ftype[x]) - - writemsg("cacheddirStats: H:%d/M:%d/S:%d\n" % (cacheHit, cacheMiss, cac= heStale),10) - return ret_list, ret_ftype - -_ignorecvs_dirs =3D ('CVS', 'SCCS', '.svn', '.git') - -def listdir(mypath, recursive=3DFalse, filesonly=3DFalse, ignorecvs=3DFa= lse, ignorelist=3D[], followSymlinks=3DTrue, - EmptyOnError=3DFalse, dirsonly=3DFalse): - """ - Portage-specific implementation of os.listdir - - @param mypath: Path whose contents you wish to list - @type mypath: String - @param recursive: Recursively scan directories contained within mypath - @type recursive: Boolean - @param filesonly; Only return files, not more directories - @type filesonly: Boolean - @param ignorecvs: Ignore CVS directories ('CVS','SCCS','.svn','.git') - @type ignorecvs: Boolean - @param ignorelist: List of filenames/directories to exclude - @type ignorelist: List - @param followSymlinks: Follow Symlink'd files and directories - @type followSymlinks: Boolean - @param EmptyOnError: Return [] if an error occurs (deprecated, always T= rue) - @type EmptyOnError: Boolean - @param dirsonly: Only return directories. - @type dirsonly: Boolean - @rtype: List - @returns: A list of files and directories (or just files or just direct= ories) or an empty list. - """ - - list, ftype =3D cacheddir(mypath, ignorecvs, ignorelist, EmptyOnError, = followSymlinks) - - if list is None: - list=3D[] - if ftype is None: - ftype=3D[] - - if not (filesonly or dirsonly or recursive): - return list - - if recursive: - x=3D0 - while x> 8 - return retval - -=3D=3D=3D=3D=3D=3D=3D ->>>>>>> .merge-right.r15449 def digestgen(myarchives=3DNone, mysettings=3DNone, overwrite=3DNone, manifestonly=3DNone, myportdb=3DNone): """ Modified: main/branches/prefix/pym/portage/dbapi/bintree.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/dbapi/bintree.py 2010-02-27 18:53:28= UTC (rev 15479) +++ main/branches/prefix/pym/portage/dbapi/bintree.py 2010-02-27 19:01:26= UTC (rev 15480) @@ -13,6 +13,7 @@ 'portage.package.ebuild.doebuild:_vdb_use_conditional_atoms', 'portage.update:update_dbentries', 'portage.util:ensure_dirs,normalize_path,writemsg,writemsg_stdout', + 'portage.util.listdir:listdir', 'portage.versions:best,catpkgsplit,catsplit', ) =20 @@ -23,7 +24,7 @@ from portage.const import EAPI from portage.localization import _ =20 -from portage import dep_expand, listdir, _movefile +from portage import dep_expand, _movefile from portage import os from portage import _encodings from portage import _unicode_decode Modified: main/branches/prefix/pym/portage/dbapi/porttree.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/dbapi/porttree.py 2010-02-27 18:53:2= 8 UTC (rev 15479) +++ main/branches/prefix/pym/portage/dbapi/porttree.py 2010-02-27 19:01:2= 6 UTC (rev 15480) @@ -11,9 +11,11 @@ import portage portage.proxy.lazyimport.lazyimport(globals(), 'portage.checksum', - 'portage.dep:dep_getkey,match_from_list,paren_reduce,use_reduce', + 'portage.dep:dep_getkey,flatten,match_from_list,paren_reduce,use_reduce= ', 'portage.env.loaders:KeyValuePairFileLoader', + 'portage.package.ebuild.doebuild:doebuild', 'portage.util:ensure_dirs,writemsg,writemsg_level', + 'portage.util.listdir:listdir', 'portage.versions:best,catpkgsplit,_pkgsplit@pkgsplit,ver_regexp', ) =20 @@ -27,8 +29,8 @@ from portage.localization import _ from portage.manifest import Manifest =20 -from portage import eclass_cache, auxdbkeys, doebuild, flatten, \ - listdir, dep_expand, eapi_is_supported, dep_check, \ +from portage import eclass_cache, auxdbkeys, \ + dep_expand, eapi_is_supported, dep_check, \ _eapi_is_deprecated from portage import os from portage import _encodings Modified: main/branches/prefix/pym/portage/dbapi/vartree.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/dbapi/vartree.py 2010-02-27 18:53:28= UTC (rev 15479) +++ main/branches/prefix/pym/portage/dbapi/vartree.py 2010-02-27 19:01:26= UTC (rev 15480) @@ -12,7 +12,7 @@ import portage portage.proxy.lazyimport.lazyimport(globals(), 'portage.checksum:_perform_md5_merge@perform_md5', - 'portage.dep:dep_getkey,isjustname,match_from_list,' + \ + 'portage.dep:dep_getkey,isjustname,flatten,match_from_list,' + \ 'use_reduce,paren_reduce,_slot_re', 'portage.elog:elog_process', 'portage.locks:lockdir,unlockdir', @@ -24,7 +24,10 @@ 'portage.util:apply_secpass_permissions,ConfigProtect,ensure_dirs,' + \ 'writemsg,writemsg_level,write_atomic,atomic_ofstream,writedict,' + \ 'grabfile,grabdict,normalize_path,new_protect_filename,getlibpaths', - 'portage.versions:best,catpkgsplit,catsplit,pkgcmp,_pkgsplit@pkgsplit', + 'portage.util.digraph:digraph', + 'portage.util.listdir:dircache,listdir', + 'portage.versions:best,catpkgsplit,catsplit,cpv_getkey,pkgcmp,' + \ + '_pkgsplit@pkgsplit', ) =20 from portage.const import CACHE_PATH, CONFIG_MEMORY_FILE, \ @@ -36,9 +39,8 @@ FileNotFound, PermissionDenied, UnsupportedAPIException from portage.localization import _ =20 -from portage import listdir, dep_expand, digraph, flatten, \ - env_update, \ - abssymlink, movefile, _movefile, bsd_chflags, cpv_getkey +from portage import dep_expand, env_update, \ + abssymlink, movefile, _movefile, bsd_chflags =20 # This is a special version of the os module, wrapped for unicode suppor= t. from portage import os @@ -2077,7 +2079,6 @@ self.mtdircache.pop(pkg_dblink.cat, None) self.matchcache.pop(pkg_dblink.cat, None) self.cpcache.pop(pkg_dblink.mysplit[0], None) - from portage import dircache dircache.pop(pkg_dblink.dbcatdir, None) =20 def match(self, origdep, use_cache=3D1): Modified: main/branches/prefix/pym/portage/package/ebuild/doebuild.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/package/ebuild/doebuild.py 2010-02-2= 7 18:53:28 UTC (rev 15479) +++ main/branches/prefix/pym/portage/package/ebuild/doebuild.py 2010-02-2= 7 19:01:26 UTC (rev 15480) @@ -280,7 +280,7 @@ if os.path.exists(exit_status_file): os.unlink(exit_status_file) =20 -_doebuild_manifest_exempt_depend =3D 0 + _doebuild_manifest_cache =3D None _doebuild_broken_ebuilds =3D set() _doebuild_broken_manifests =3D set() @@ -401,16 +401,13 @@ noiselevel=3D-1) return 1 =20 - global _doebuild_manifest_exempt_depend - if "strict" in features and \ "digest" not in features and \ tree =3D=3D "porttree" and \ mydo not in ("digest", "manifest", "help") and \ - not _doebuild_manifest_exempt_depend: + not portage._doebuild_manifest_exempt_depend: # Always verify the ebuild checksums before executing it. - global _doebuild_manifest_cache, _doebuild_broken_ebuilds, \ - _doebuild_broken_ebuilds + global _doebuild_manifest_cache, _doebuild_broken_ebuilds =20 if myebuild in _doebuild_broken_ebuilds: return 1 @@ -508,7 +505,7 @@ if mydo in ("digest", "manifest", "help"): # Temporarily exempt the depend phase from manifest checks, in case # aux_get calls trigger cache generation. - _doebuild_manifest_exempt_depend +=3D 1 + portage._doebuild_manifest_exempt_depend +=3D 1 =20 # If we don't need much space and we don't need a constant location, # we can temporarily override PORTAGE_TMPDIR with a random temp dir @@ -1023,7 +1020,7 @@ if mydo in ("digest", "manifest", "help"): # If necessary, depend phase has been triggered by aux_get calls # and the exemption is no longer needed. - _doebuild_manifest_exempt_depend -=3D 1 + portage._doebuild_manifest_exempt_depend -=3D 1 =20 def _validate_deps(mysettings, myroot, mydo, mydbapi): =20 Modified: main/branches/prefix/pym/portage/util/digraph.py =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/util/digraph.py 2010-02-27 18:53:28 = UTC (rev 15479) +++ main/branches/prefix/pym/portage/util/digraph.py 2010-02-27 19:01:26 = UTC (rev 15480) @@ -2,6 +2,8 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ =20 +__all__ =3D ['digraph'] + from portage.util import writemsg =20 class digraph(object): Copied: main/branches/prefix/pym/portage/util/listdir.py (from rev 15451,= main/trunk/pym/portage/util/listdir.py) =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- main/branches/prefix/pym/portage/util/listdir.py = (rev 0) +++ main/branches/prefix/pym/portage/util/listdir.py 2010-02-27 19:01:26 = UTC (rev 15480) @@ -0,0 +1,153 @@ +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Id$ + +__all__ =3D ['cacheddir', 'listdir'] + +import errno +import stat +import time + +from portage import os +from portage.exception import DirectoryNotFound, PermissionDenied, Porta= geException +from portage.util import normalize_path, writemsg + +dircache =3D {} +cacheHit =3D 0 +cacheMiss =3D 0 +cacheStale =3D 0 + +def cacheddir(my_original_path, ignorecvs, ignorelist, EmptyOnError, fol= lowSymlinks=3DTrue): + global cacheHit,cacheMiss,cacheStale + mypath =3D normalize_path(my_original_path) + if mypath in dircache: + cacheHit +=3D 1 + cached_mtime, list, ftype =3D dircache[mypath] + else: + cacheMiss +=3D 1 + cached_mtime, list, ftype =3D -1, [], [] + try: + pathstat =3D os.stat(mypath) + if stat.S_ISDIR(pathstat[stat.ST_MODE]): + mtime =3D pathstat.st_mtime + else: + raise DirectoryNotFound(mypath) + except EnvironmentError as e: + if e.errno =3D=3D PermissionDenied.errno: + raise PermissionDenied(mypath) + del e + return [], [] + except PortageException: + return [], [] + # Python retuns mtime in seconds, so if it was changed in the last few = seconds, it could be invalid + if mtime !=3D cached_mtime or time.time() - mtime < 4: + if mypath in dircache: + cacheStale +=3D 1 + try: + list =3D os.listdir(mypath) + except EnvironmentError as e: + if e.errno !=3D errno.EACCES: + raise + del e + raise PermissionDenied(mypath) + ftype =3D [] + for x in list: + try: + if followSymlinks: + pathstat =3D os.stat(mypath+"/"+x) + else: + pathstat =3D os.lstat(mypath+"/"+x) + + if stat.S_ISREG(pathstat[stat.ST_MODE]): + ftype.append(0) + elif stat.S_ISDIR(pathstat[stat.ST_MODE]): + ftype.append(1) + elif stat.S_ISLNK(pathstat[stat.ST_MODE]): + ftype.append(2) + else: + ftype.append(3) + except (IOError, OSError): + ftype.append(3) + dircache[mypath] =3D mtime, list, ftype + + ret_list =3D [] + ret_ftype =3D [] + for x in range(0, len(list)): + if list[x] in ignorelist: + pass + elif ignorecvs: + if list[x][:2] !=3D ".#": + ret_list.append(list[x]) + ret_ftype.append(ftype[x]) + else: + ret_list.append(list[x]) + ret_ftype.append(ftype[x]) + + writemsg("cacheddirStats: H:%d/M:%d/S:%d\n" % (cacheHit, cacheMiss, cac= heStale),10) + return ret_list, ret_ftype + +_ignorecvs_dirs =3D ('CVS', 'SCCS', '.svn', '.git') + +def listdir(mypath, recursive=3DFalse, filesonly=3DFalse, ignorecvs=3DFa= lse, ignorelist=3D[], followSymlinks=3DTrue, + EmptyOnError=3DFalse, dirsonly=3DFalse): + """ + Portage-specific implementation of os.listdir + + @param mypath: Path whose contents you wish to list + @type mypath: String + @param recursive: Recursively scan directories contained within mypath + @type recursive: Boolean + @param filesonly; Only return files, not more directories + @type filesonly: Boolean + @param ignorecvs: Ignore CVS directories ('CVS','SCCS','.svn','.git') + @type ignorecvs: Boolean + @param ignorelist: List of filenames/directories to exclude + @type ignorelist: List + @param followSymlinks: Follow Symlink'd files and directories + @type followSymlinks: Boolean + @param EmptyOnError: Return [] if an error occurs (deprecated, always T= rue) + @type EmptyOnError: Boolean + @param dirsonly: Only return directories. + @type dirsonly: Boolean + @rtype: List + @returns: A list of files and directories (or just files or just direct= ories) or an empty list. + """ + + list, ftype =3D cacheddir(mypath, ignorecvs, ignorelist, EmptyOnError, = followSymlinks) + + if list is None: + list=3D[] + if ftype is None: + ftype=3D[] + + if not (filesonly or dirsonly or recursive): + return list + + if recursive: + x=3D0 + while x