diff --git a/ChangeLog b/ChangeLog index 28f54d3a..89c16ff8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2009-09-16 Ozan Çağlayan * pisi/archive.py (ArchiveBzip2): Implement ArchiveBzip2 to support - .bz2 archive files. + .bz2 archive files, + * pisi/operations/build.py (Builder.file_actions): Use python magic + module instead of spawning file process to improve performance. 2009-09-08 Ozan Çağlayan * pisi/specfile.py (read_translations): Fix matching of translations diff --git a/pisi/operations/build.py b/pisi/operations/build.py index f8b29d5f..11caf652 100644 --- a/pisi/operations/build.py +++ b/pisi/operations/build.py @@ -19,6 +19,7 @@ import glob import stat import pwd import grp +import locale import gettext __trans = gettext.translation('pisi', fallback=True) @@ -131,7 +132,6 @@ def strip_debug_action(filepath, fileinfo, install_dir, ag): for exclude in excludelist: if p.startswith(exclude): strip = False - ctx.ui.debug("%s [%s]" %(p, "NoStrip")) if strip: if pisi.util.strip_file(filepath, fileinfo, outputpath): @@ -838,13 +838,22 @@ class Builder: def file_actions(self): install_dir = self.pkg_install_dir() + + locale.setlocale(locale.LC_ALL, 'C') + import magic + ms = magic.open(magic.MAGIC_NONE) + ms.load() + for root, dirs, files in os.walk(install_dir): for fn in files: filepath = pisi.util.join_path(root, fn) - fileinfo = os.popen("file \"%s\"" % filepath).read() + fileinfo = ms.file(filepath) strip_debug_action(filepath, fileinfo, install_dir, self.actionGlobals) exclude_special_files(filepath, fileinfo, install_dir, self.actionGlobals) + ms.close() + locale.setlocale(locale.LC_ALL, '') + def build_packages(self): """Build each package defined in PSPEC file. After this process there will be .pisi files hanging around, AS INTENDED ;)"""