# HG changeset patch # User Bernhard Herzog # Date 1214249379 0 # Node ID 97435e92411ae8de03b78610369a2de3bd7293a7 # Parent 06af36f915f29a8c16c0e1999ed144c3c617702c Introduce filenameproperties for the various directories in the PBuilder class diff -r 06af36f915f2 -r 97435e92411a test/test_builder.py --- 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" diff -r 06af36f915f2 -r 97435e92411a treepkg/builder.py --- 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"