* pisi/operations/build.py (Builder.file_actions): Use python magic

module instead of spawning file process to improve performance.
This commit is contained in:
Ozan Çağlayan
2009-09-16 12:42:39 +00:00
parent 909d05ba8b
commit db91cf9029
2 changed files with 14 additions and 3 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
2009-09-16 Ozan Çağlayan <ozan@pardus.org.tr>
* 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 <ozan@pardus.org.tr>
* pisi/specfile.py (read_translations): Fix matching of translations
+11 -2
View File
@@ -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 ;)"""