From 3352e5f3b4cd63c9147e238c5ec36a649ee37dd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Metin?= Date: Wed, 29 Jun 2005 17:54:13 +0000 Subject: [PATCH] =?UTF-8?q?Path=20=C3=A7ak=C4=B1=C5=9Fmas=C4=B1=20sorununu?= =?UTF-8?q?=20=C3=A7=C3=B6zd=C3=BCk.=20=C3=87a=C4=9Flar,=20tekrar=20test?= =?UTF-8?q?=20edebilir=20misin=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pisi/build.py | 35 ++++++++++++++--------------------- pisi/util.py | 13 ++++++++++++- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/pisi/build.py b/pisi/build.py index 3adcc1c8..fccb6e44 100644 --- a/pisi/build.py +++ b/pisi/build.py @@ -39,20 +39,18 @@ def getFileType(path, pinfoList): ftype = pinfo.fileType return ftype -def checkPathCollutions(spath, spkg, pkgList): - # check collution with other packages - - # FIXME: BU ŞU ANDA İSTEDİĞİM GİBİ ÇALIŞMIYOR. EVE GİDİNCE - # DÜZELTECEĞİM VE BELGELEYECEĞİM. +def checkPathCollision(package, pkgList): + """This function will check for collision of paths in a package with + the paths of packages in pkgList. The return value will be the + list containing the paths that collide.""" collutions = [] - for package in pkgList: - if package is spkg: - continue - - for path in package.paths: - if path.pathname.startswith(spath): - collutions.append(path.pathname) - + for pinfo in package.paths: + for pkg in pkgList: + if pkg is package: + continue + for path in pkg.paths: + if path.pathname.startswith(pinfo.pathname): + collutions.append(path.pathname) return collutions @@ -205,16 +203,11 @@ class PisiBuild: generated files by the build system.""" files = Files() install_dir = self.ctx.pkg_install_dir() + collisions = checkPathCollision(package, + self.spec.packages) for pinfo in package.paths: - collutions = checkPathCollutions(pinfo.pathname, - package, - self.spec.packages) - # don't add collutions to files.xml - if pinfo.pathname in collutions: - continue - path = install_dir + pinfo.pathname - for fpath, fhash in util.get_file_hashes(path): + for fpath, fhash in util.get_file_hashes(path, collisions, install_dir): frpath = util.removepathprefix(install_dir, fpath) # relative path ftype = getFileType(frpath, package.paths) try: # broken links can cause problem diff --git a/pisi/util.py b/pisi/util.py index 5b211508..796126f9 100644 --- a/pisi/util.py +++ b/pisi/util.py @@ -149,8 +149,19 @@ def copy_file(src,dest): # fd.write(l) shutil.copyfile(src, dest) -def get_file_hashes(top): +def get_file_hashes(top, excludePrefixes=None, removePrefix=None): + """Generator function iterates over a toplevel path and gives the + (filePath, sha1Hash) tuple for all files. If excludePrefixes list + is given function will exclude the filePaths matching those + prefixes. The removePrefix string parameter will be used to remove + prefix from filePath while matching excludes, if given.""" for root, dirs, files in os.walk(top, topdown=False): + # check if root matches an exclude, and continue + if excludePrefixes and removePrefix: + p = remove_prefix(removePrefix, root) + if [e for e in excludePrefixes if p.startswith(e)]: + continue + for file in files: f = os.path.join(root, file) yield (f, sha1_file(f))