changeset 299:c32dc72ba979

Turn the SourcePackager class attribute pkg_basename into a per-track configuratin option. The default value is the track name, as in most cases they're identical anyway. For now, the change is compatible with old SourcePackager subclasses that override pkg_basename.
author Bernhard Herzog <bh@intevation.de>
date Fri, 20 Nov 2009 21:06:10 +0000
parents e9d5b44f8f52
children e82fb08781a2
files test/test_packager.py test/test_readconfig.py treepkg/packager.py treepkg/readconfig.py
diffstat 4 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/test/test_packager.py	Fri Nov 20 20:22:34 2009 +0000
+++ b/test/test_packager.py	Fri Nov 20 21:06:10 2009 +0000
@@ -42,8 +42,6 @@
 
 class SourcePackager(treepkg.packager.SourcePackager):
 
-    pkg_basename = "testpkg"
-
     def do_package(self):
         pkgbaseversion, pkgbasedir = self.export_sources()
 
--- a/test/test_readconfig.py	Fri Nov 20 20:22:34 2009 +0000
+++ b/test/test_readconfig.py	Fri Nov 20 21:06:10 2009 +0000
@@ -36,6 +36,7 @@
 check_interval: 3600
 
 [pkg_simple]
+pkg_basename: simple1
 svn_url: svn://example.com/%(name)s/trunk
 base_dir: %(tracks_dir)s/%(name)s
 packager_class: readconfig_test.%(name)s
@@ -89,6 +90,10 @@
                  handle_dependencies=False,
                  packager_class="readconfig_test.extraargs",
                  pbuilderrc="/home/builder/mill/pbuilder/pbuilderrc",
+                 # pkg_basename is passed as an empty string by default.
+                 # The PackageTrack an empty pkg_basename it with the
+                 # value of name
+                 pkg_basename="",
                  root_cmd=['sudo'],
                  signing_key_id="",
                  svn_url="svn://example.com/extraargs/trunk",
@@ -105,6 +110,7 @@
                  handle_dependencies=True,
                  packager_class="readconfig_test.simple",
                  pbuilderrc="/home/builder/mill/pbuilder/pbuilderrc",
+                 pkg_basename="simple1",
                  root_cmd=['sudo'],
                  signing_key_id="abcd1234",
                  svn_url="svn://example.com/simple/trunk")])
--- a/treepkg/packager.py	Fri Nov 20 20:22:34 2009 +0000
+++ b/treepkg/packager.py	Fri Nov 20 21:06:10 2009 +0000
@@ -32,13 +32,10 @@
 
 class SourcePackager(object):
 
-    # Derived classes must supply the package basename
-    pkg_basename = None
-
     # Derived classes may want to override this message
     changemsg_template = "Update to revision %(revision)d"
 
-
+    pkg_basename = property(lambda self: self.track.pkg_basename)
     track = _fromparent("track")
     revision = _fromparent("revision")
     pkg_revision = _fromparent("pkg_revision")
@@ -49,7 +46,6 @@
 
     def __init__(self, parent):
         self.parent = parent
-        assert(self.pkg_basename)
 
     def determine_package_version(self, directory):
         """Returns the version number of the new package as a string
@@ -349,8 +345,11 @@
                  deb_fullname, packager_class="treepkg.packager",
                  pkg_revision_template="treepkg%(pkg_revision)d",
                  handle_dependencies=False, signing_key_id="", do_build=True,
-                 rules_svn_url=None, deb_build_options=""):
+                 rules_svn_url=None, deb_build_options="", pkg_basename=""):
         self.name = name
+        if not pkg_basename:
+            pkg_basename = name
+        self.pkg_basename = pkg_basename
         self.base_dir = base_dir
         self.builder = PBuilder(pbuilderrc, root_cmd,
                                 release_signing_keyid=signing_key_id)
--- a/treepkg/readconfig.py	Fri Nov 20 20:22:34 2009 +0000
+++ b/treepkg/readconfig.py	Fri Nov 20 21:06:10 2009 +0000
@@ -27,7 +27,7 @@
     "name", "base_dir", "svn_url", ("rules_svn_url", str, ""), "packager_class",
     ("root_cmd", shlex.split, "sudo"), "pbuilderrc",
     "deb_email", "deb_fullname", ("deb_build_options", str, ""),
-    "pkg_revision_template",
+    "pkg_revision_template", ("pkg_basename", str, ""),
     ("handle_dependencies", convert_bool),
     ("signing_key_id", str, ""),
     ]
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)