[Treepkg-commits] r98 - in trunk: test treepkg

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Jun 23 21:29:40 CEST 2008


Author: bh
Date: 2008-06-23 21:29:39 +0200 (Mon, 23 Jun 2008)
New Revision: 98

Modified:
   trunk/test/test_builder.py
   trunk/treepkg/builder.py
Log:
Introduce filenameproperties for the various directories in the PBuilder class


Modified: trunk/test/test_builder.py
===================================================================
--- trunk/test/test_builder.py	2008-06-23 19:26:21 UTC (rev 97)
+++ trunk/test/test_builder.py	2008-06-23 19:29:39 UTC (rev 98)
@@ -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"

Modified: trunk/treepkg/builder.py
===================================================================
--- trunk/treepkg/builder.py	2008-06-23 19:26:21 UTC (rev 97)
+++ trunk/treepkg/builder.py	2008-06-23 19:29:39 UTC (rev 98)
@@ -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"



More information about the Treepkg-commits mailing list