changeset 45:3e610233ccfe

use cmdexpand when calling subprocesses
author Bernhard Herzog <bh@intevation.de>
date Tue, 20 Mar 2007 17:27:46 +0100
parents a2ce575ce82b
children e1028211d34b
files enterprise/kdei18n.py treepkg/packager.py treepkg/subversion.py
diffstat 3 files changed, 27 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/enterprise/kdei18n.py	Mon Mar 19 20:14:07 2007 +0100
+++ b/enterprise/kdei18n.py	Tue Mar 20 17:27:46 2007 +0100
@@ -13,6 +13,7 @@
 import treepkg.packager
 import treepkg.util
 import treepkg.run as run
+from treepkg.cmdexpand import cmdexpand
 
 
 class SourcePackager(treepkg.packager.SourcePackager):
@@ -50,7 +51,8 @@
 
     def unpack_orig_tarball(self):
         orig_tarball = self.pkg_line.orig_tarball
-        run.call(["tar", "xjf", orig_tarball, "-C", self.work_dir])
+        run.call(cmdexpand("tar xjf $tarball -C $directory",
+                           tarball=orig_tarball, directory=self.work_dir))
         tarbasename = os.path.basename(orig_tarball)
         splitext = os.path.splitext
         return os.path.join(self.work_dir,
@@ -71,7 +73,7 @@
         treepkg.util.copytree(untarred_dir, de_dir)
         treepkg.util.copytree(new_de_dir, de_dir)
         logging.info("Running scripts/autogen.sh for kde-i18n-de tarball")
-        run.call(["/bin/sh", "scripts/autogen.sh", "de"], cwd=pkgbasedir,
+        run.call(cmdexpand("/bin/sh scripts/autogen.sh de"), cwd=pkgbasedir,
                  suppress_output=True)
 
         tarballdir = "kde-i18n-de-" + pkgbaseversion
@@ -79,7 +81,8 @@
 
         tarball = os.path.join(os.path.dirname(pkgbasedir),
                                tarballdir + ".tar.bz2")
-        run.call(["tar", "cjf", tarball, "-C", pkgbasedir, tarballdir])
+        run.call(cmdexpand("tar cjf $tarball -C $pkgbasedir $tarballdir",
+                           **locals()))
         logging.info("Created kde-i18n-de tarball")
         return tarball
 
--- a/treepkg/packager.py	Mon Mar 19 20:14:07 2007 +0100
+++ b/treepkg/packager.py	Tue Mar 20 17:27:46 2007 +0100
@@ -19,7 +19,7 @@
 import subversion
 import run
 import status
-
+from cmdexpand import cmdexpand
 
 def _filenameproperty(relative_dir):
     def get(self):
@@ -94,7 +94,8 @@
                      filename directly in workdir.
         """
         logging.info("Creating tarball %r", tarballname)
-        run.call(["tar", "czf", tarballname, "-C", workdir, basedir])
+        run.call(cmdexpand("tar czf $tarballname -C $workdir $basedir",
+                           **locals()))
 
     def copy_debian_directory(self, pkgbasedir, pkgbaseversion, changemsg):
         """Copies the debian directory and updates the copy's changelog
@@ -121,17 +122,18 @@
             oldversionprefix = oldversion.split(":")[0] + ":"
         else:
             oldversionprefix = ""
-        run.call(["debchange", "-c", changelog,
-                  "-v", oldversionprefix + pkgbaseversion + "-kk1",
-                  changemsg],
+        run.call(cmdexpand("debchange -c  $changelog"
+                           " -v ${oldversionprefix}${pkgbaseversion}-kk1"
+                           " $changemsg", **locals()),
                  env=self.pkg_line.debian_environment())
 
 
     def create_source_package(self, pkgbasedir, origtargz):
         """Creates a new source package from pkgbasedir and origtargz"""
         logging.info("Creating new source package")
-        run.call(["dpkg-source", "-b", os.path.basename(pkgbasedir),
-                  os.path.basename(origtargz)],
+        run.call(cmdexpand("dpkg-source -b $directory $tarball",
+                           directory=os.path.basename(pkgbasedir),
+                           tarball=os.path.basename(origtargz)),
                  cwd=os.path.dirname(pkgbasedir),
                  suppress_output=True,
                  env=self.pkg_line.debian_environment())
@@ -185,9 +187,11 @@
         self.status.creating_binary_package()
         util.ensure_directory(self.binary_dir)
         logging.info("Building binary package; loging to %r", self.logfile)
-        cmd = ["/usr/sbin/pbuilder", "build", "--logfile", self.logfile,
-               "--buildresult", self.binary_dir, self.dsc_file]
-        run.call(self.pkg_line.root_cmd + cmd, suppress_output=True)
+        run.call(cmdexpand("@rootcmd /usr/sbin/pbuilder build"
+                           " --logfile $logfile --buildresult $bindir $dsc",
+                           rootcmd=self.pkg_line.root_cmd, logfile=self.logfile,
+                           bindir=self.binary_dir, dsc=self.dsc_file),
+                 suppress_output=True)
         self.status.binary_package_created()
 
 
--- a/treepkg/subversion.py	Mon Mar 19 20:14:07 2007 +0100
+++ b/treepkg/subversion.py	Tue Mar 20 17:27:46 2007 +0100
@@ -10,20 +10,21 @@
 import os
 
 import run
+from cmdexpand import cmdexpand
 from util import extract_value_for_key
 
 
 def checkout(url, localdir):
     """Runs svn to checkout the repository at url into the localdir"""
-    run.call(["svn", "checkout", "-q", url, localdir])
+    run.call(cmdexpand("svn checkout -q $url $localdir", **locals()))
 
 def update(localdir):
     """Runs svn update on the localdir"""
-    run.call(["svn", "update", "-q", localdir])
+    run.call(cmdexpand("svn update -q $localdir", **locals()))
 
 def export(src, dest):
     """Runs svn export src dest"""
-    run.call(["svn", "export", "-q", src, dest])
+    run.call(cmdexpand("svn export -q $src $dest", **locals()))
 
 def last_changed_revision(svn_working_copy):
     """return the last changed revision of an SVN working copy as an int"""
@@ -32,6 +33,8 @@
     env = os.environ.copy()
     env["LANG"] = "C"
 
-    output = run.capture_output(["svn", "info", svn_working_copy], env=env)
+    output = run.capture_output(cmdexpand("svn info $svn_working_copy",
+                                          **locals()),
+                                env=env)
     return int(extract_value_for_key(output.splitlines(),
                                      "Last Changed Rev:"))
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)