changeset 173:97435e92411a

Introduce filenameproperties for the various directories in the PBuilder class
author Bernhard Herzog <bh@intevation.de>
date Mon, 23 Jun 2008 19:29:39 +0000
parents 06af36f915f2
children 2d7415b84e32
files test/test_builder.py treepkg/builder.py
diffstat 2 files changed, 19 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_builder.py	Mon Jun 23 19:26:21 2008 +0000
+++ b/test/test_builder.py	Mon Jun 23 19:29:39 2008 +0000
@@ -78,7 +78,7 @@
             "USEDEVPTS=yes\n"
             "BUILDRESULT=%(basedir)s/result\n"
             "DISTRIBUTION=etch\n"
-            "APTCACHE=%(basedir)s/base/aptcache\n"
+            "APTCACHE=%(basedir)s/aptcache\n"
             "APTCACHEHARDLINK=yes\n"
             "REMOVEPACKAGES=lilo\n"
             "MIRRORSITE=\"http://example.com/debian\"\n"
--- a/treepkg/builder.py	Mon Jun 23 19:26:21 2008 +0000
+++ b/treepkg/builder.py	Mon Jun 23 19:29:39 2008 +0000
@@ -25,21 +25,26 @@
 # This file was automatically generated by initpbuilder.py.
 # for the possible settings see "man pbuilderrc"
 
-BASETGZ=%(basedir)s/base.tgz
-BUILDPLACE=%(builddir)s
+BASETGZ=%(basetgz_dir)s/base.tgz
+BUILDPLACE=%(build_dir)s
 USEPROC=yes
 USEDEVPTS=yes
-BUILDRESULT=%(resultdir)s
+BUILDRESULT=%(result_dir)s
 DISTRIBUTION=%(distribution)s
-APTCACHE=%(basedir)s/aptcache
+APTCACHE=%(aptcache_dir)s
 APTCACHEHARDLINK=yes
 REMOVEPACKAGES=lilo
 MIRRORSITE="%(mirrorsite)s"
 OTHERMIRROR="%(othermirror)s"
-BINDMOUNTS="%(extra-pkgdir)s"
+BINDMOUNTS="%(extra_pkg_dir)s"
 PKGNAME_LOGFILE=yes
 '''
 
+    basetgz_dir = util.filenameproperty("base")
+    build_dir = util.filenameproperty("build")
+    result_dir = util.filenameproperty("result")
+    aptcache_dir = util.filenameproperty("aptcache")
+    extra_pkg_dir = util.filenameproperty("extra-pkg")
 
     def __init__(self, pbuilderrc, root_cmd):
         """Initialize the PBuilder instance with the configuration file.
@@ -51,6 +56,7 @@
         """
         self.pbuilderrc = pbuilderrc
         self.root_cmd = root_cmd
+        self.base_dir = os.path.dirname(self.pbuilderrc)
 
     def init_pbuilder(self, distribution, mirrorsite, extramirrors):
         """Initializes the pbuilder instance"""
@@ -70,14 +76,15 @@
 
         # create the pbuilder directories.  basedir is created implicitly by
         # creating its subdirectories.
-        for subdir in ["base", "build", "result", "aptcache", "extra-pkg"]:
-            directory = os.path.join(basedir, subdir)
-            replacements[subdir + "dir"] = directory
+        for attr in ["basetgz_dir", "build_dir", "result_dir", "aptcache_dir",
+                     "extra_pkg_dir"]:
+            directory = getattr(self, attr)
+            replacements[attr] = directory
             print "creating directory:", repr(directory)
             util.ensure_directory(directory)
 
         # build OTHERMIRROR value.  We always include the extra-pkg dir.
-        othermirror = "deb file://%(extra-pkgdir)s ./" % replacements
+        othermirror = "deb file://%(extra_pkg_dir)s ./" % replacements
         if extramirrors:
             othermirror += " | " + extramirrors
         replacements["othermirror"] = othermirror
@@ -88,10 +95,9 @@
 
         # turn the extra-pkg directory into a proper deb archive
         print "turning the extra-pkg dir into a debian archive"
-        extra_pkgdir = replacements["extra-pkgdir"]
         run.call(cmdexpand("apt-ftparchive packages ."),
-                 stdout=open(os.path.join(extra_pkgdir, "Packages"), "w"),
-                 cwd=extra_pkgdir)
+                 stdout=open(os.path.join(self.extra_pkg_dir, "Packages"), "w"),
+                 cwd=self.extra_pkg_dir)
 
         # create the base.tgz chroot
         print "running pbuilder create"
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)