From 5e375aa9d387b2ef703dd35f60df1daad6a40237 Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Thu, 17 Apr 2008 21:02:39 +0200 Subject: pactest: Add quotes for directory with whitespaces Signed-off-by: Chantry Xavier Signed-off-by: Dan McGee --- pactest/pmtest.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pactest') diff --git a/pactest/pmtest.py b/pactest/pmtest.py index be36914b..cd532dcf 100755 --- a/pactest/pmtest.py +++ b/pactest/pmtest.py @@ -200,7 +200,7 @@ class pmtest: cmd.append("libtool gdb --args") if pacman["valgrind"]: cmd.append("valgrind --tool=memcheck --leak-check=full --show-reachable=yes") - cmd.append("%s --config=%s --root=%s --dbpath=%s --cachedir=%s" \ + cmd.append("\"%s\" --config=\"%s\" --root=\"%s\" --dbpath=\"%s\" --cachedir=\"%s\"" \ % (pacman["bin"], os.path.join(self.root, PACCONF), self.root, @@ -212,7 +212,7 @@ class pmtest: cmd.append("--debug=%s" % pacman["debug"]) cmd.append("%s" % self.args) if not pacman["gdb"] and not pacman["valgrind"] and not pacman["nolog"]: - cmd.append(">%s 2>&1" % os.path.join(self.root, LOGFILE)) + cmd.append(">\"%s\" 2>&1" % os.path.join(self.root, LOGFILE)) vprint("\trunning: %s" % " ".join(cmd)) # Change to the tmp dir before running pacman, so that local package -- cgit v1.2.3-70-g09d2 From c465d9e848b19b495259c7021a583c29fba92b44 Mon Sep 17 00:00:00 2001 From: Chantry Xavier Date: Thu, 17 Apr 2008 09:02:11 +0200 Subject: pactest : Use tarfile module. Previously, tar was called manually with os.system. This caused one fork per package/db creation, which is costly, especially on cygwin. Besides, it also caused some problems with directory with whitespaces (that could also be fixed with quotes, but well..) Using tarfile module is cleaner and more efficient, and still easy enough. Benchmark (time make check) : - windows / cygwin prepatch: real 6m36.360s user 2m28.914s sys 2m35.866s postpatch: real 5m25.428s user 1m26.029s sys 2m0.006s - linux prepatch: real 1m22.629s user 0m31.498s sys 0m18.899s postpatch: real 1m11.465s user 0m26.382s sys 0m12.986s Signed-off-by: Chantry Xavier --- pactest/pmdb.py | 9 ++++++++- pactest/pmpkg.py | 23 ++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'pactest') diff --git a/pactest/pmdb.py b/pactest/pmdb.py index e0f328ef..cfa146bd 100755 --- a/pactest/pmdb.py +++ b/pactest/pmdb.py @@ -19,6 +19,7 @@ import os import tempfile import shutil +import tarfile import pmpkg from util import * @@ -343,7 +344,13 @@ class pmdb: # Generate database archive mkdir(path) archive = os.path.join(path, "%s%s" % (self.treename, PM_EXT_DB)) - os.system("tar zcf %s *" % archive) + tar = tarfile.open(archive, "w:gz") + for root, dirs, files in os.walk('.'): + for d in dirs: + tar.add(os.path.join(root, d), recursive=False) + for f in files: + tar.add(os.path.join(root, f)) + tar.close() os.chdir(curdir) shutil.rmtree(tmpdir) diff --git a/pactest/pmpkg.py b/pactest/pmpkg.py index 3ee58156..48d79a35 100755 --- a/pactest/pmpkg.py +++ b/pactest/pmpkg.py @@ -20,6 +20,7 @@ import os import tempfile import stat import shutil +import tarfile from util import * @@ -153,25 +154,25 @@ class pmpkg: for i in self.backup: data.append("backup = %s" % i) mkfile(".PKGINFO", "\n".join(data)) - targets = ".PKGINFO" # .INSTALL - empty = 1 if len(self.install.values()) > 0: - empty = 0 - if not empty: mkinstallfile(".INSTALL", self.install) - targets += " .INSTALL" - # package files - if self.files: - targets += " *" - - #safely create the dir + # safely create the dir mkdir(os.path.dirname(self.path)) # Generate package archive - os.system("tar zcf %s %s" % (self.path, targets)) + tar = tarfile.open(self.path, "w:gz") + + # package files + for root, dirs, files in os.walk('.'): + for d in dirs: + tar.add(os.path.join(root, d), recursive=False) + for f in files: + tar.add(os.path.join(root, f)) + + tar.close() os.chdir(curdir) shutil.rmtree(tmpdir) -- cgit v1.2.3-70-g09d2