changeset 499:e44c9c3f69f8

consolidate enterprise packagers
author Bjoern Ricks <bricks@intevation.de>
date Wed, 20 Oct 2010 07:51:53 +0000
parents 1c8cc563ac80
children 9ec15ae12a0f
files recipes/kde/enterprise/kde_l10n.py recipes/kde/enterprise/tags.py treepkg/packager.py
diffstat 3 files changed, 15 insertions(+), 112 deletions(-) [+]
line wrap: on
line diff
--- a/recipes/kde/enterprise/kde_l10n.py	Fri Oct 15 17:03:11 2010 +0000
+++ b/recipes/kde/enterprise/kde_l10n.py	Wed Oct 20 07:51:53 2010 +0000
@@ -59,18 +59,6 @@
 
     def __init__(self, *args, **kw):
         super(SourcePackager, self).__init__(*args, **kw)
-        self.enterprise_version = (time.strftime("%Y%m%d", time.localtime())
-                                   + "." + str(self.revision))
-
-    def determine_package_version(self, directory):
-        enterprise_version = self.enterprise_version
-        revision = self.revision
-        rules_revision = self.parent.rules_revision
-        pkg_revision = self.parent.pkg_revision
-        pkg_date = self.parent.pkg_date
-
-        return super(SourcePackager, self).determine_package_version($
-                                directory, locals())
 
     def create_l10n_de_tarball(self, pkgbasedir, pkgbaseversion):
         logging.info("Creating kde-l10n-de tarball")
--- a/recipes/kde/enterprise/tags.py	Fri Oct 15 17:03:11 2010 +0000
+++ b/recipes/kde/enterprise/tags.py	Wed Oct 20 07:51:53 2010 +0000
@@ -6,80 +6,21 @@
 # This program is free software under the GPL (>=v2)
 # Read the file COPYING coming with the software for details.
 
-"""Base classes for all kde entperprise packagers"""
+"""PackageTrack for kde entperprise tag only builds"""
 
-import re
-import time
 import logging
 
-import treepkg.packager
-import treepkg.subversion as subversion
+import recipes.kde.enterprise.generic as enterprise
 
+class PackageTrack(enterprise.PackageTrack):
 
-class SourcePackager(treepkg.packager.SourcePackager):
+    """In contrast to recipes.kde.enterprise.generic.PackageTrack
+       this PackageTrack either builds trunk or newest tag"""
+
+    revision_packager_cls = enterprise.RevisionPackager
 
     def __init__(self, *args, **kw):
-        super(SourcePackager, self).__init__(*args, **kw)
-        self.enterprise_version = (self.parent.pkg_date + "."
-                                   + str(self.revision))
-
-    def determine_package_version(self, directory):
-        enterprise_version = self.enterprise_version
-        revision = self.revision
-        rules_revision = self.parent.rules_revision
-        pkg_revision = self.parent.pkg_revision
-        pkg_date = self.parent.pkg_date
-
-        return super(SourcePackager, self).determine_package_version(
-                directory, locals())
-
-    def prepare_sources_for_tarball(self, pkgbasedir, pkgbaseversion):
-        self.update_version_numbers(pkgbasedir)
-
-    def get_change_msg(self):
-        return self.changemsg_template % dict(revision=self.revision,
-                                     pkg_date=self.parent.pkg_date,
-                                     rules_revision=self.parent.rules_revision)
-
-    def update_version_numbers(self, pkgbasedir):
-        """Updates the version numbers in the code in pkgbasedir.
-        The default implementation does nothing.  Derived classes should
-        override this method if necessary.
-        """
-
-
-class RevisionPackager(treepkg.packager.RevisionPackager):
-
-    source_packager_cls = SourcePackager
-
-    def __init__(self, *args, **kw):
-        self.pkg_date = kw.pop("pkg_date",
-                               time.strftime("%Y%m%d", time.localtime()))
-        super(RevisionPackager, self).__init__(*args, **kw)
-
-
-class PackageTrack(treepkg.packager.PackageTrack):
-
-    revision_packager_cls = RevisionPackager
-
-    extra_config_desc = [("tags_url", str, ""),
-                         ("tags_pattern", str, ""),
-                         ("tags_subdir", str, ""),
-                         ("tags_rules_subdir", str, "")]
-
-    def __init__(self, *args, **kw):
-        tags_url = kw.pop("tags_url")
-        tags_pattern = kw.pop("tags_pattern")
-        tags_subdir = kw.pop("tags_subdir")
-        tags_rules_subdir = kw.pop("tags_rules_subdir")
         super(PackageTrack, self).__init__(*args, **kw)
-        self.tag_detector = subversion.TagDetector(tags_url, tags_pattern,
-                                                   tags_subdir)
-        self.tag_rules_detector = subversion.TagDetector(tags_url, tags_pattern,
-                                                   tags_rules_subdir)
-        self.found_tag_rules = False
-        if tags_rules_subdir:
-            self.found_tag_rules = True
 
     def packager_for_new_revision(self):
         logging.info("Checking tags")
@@ -118,36 +59,4 @@
         else: # tag_url is not set -> build trunk
             # don't use rules from tags for trunk builds
             self.use_tag_rules = False
-            return super(PackageTrack, self).packager_for_new_revision()
-
-    def export_sources(self, to_dir):
-        if self.tag_url is not None:
-            logging.info("Exporting sources for tarball from %r to %r",
-                         self.tag_url, to_dir)
-            self.working_copy.export_tag(self.tag_url, to_dir,
-                                         revision=self.tag_revision)
-        else:
-            super(PackageTrack, self).export_sources(to_dir)
-
-    def copy_debian_directory(self, to_dir):
-        if self.use_tag_rules:
-            logging.info("Exporting debian package description from %s to %s",
-                    self.tag_rules_url, to_dir)
-            self.rules_working_copy.export_tag(self.tag_rules_url, to_dir)
-        else:
-            super(PackageTrack, self).copy_debian_directory(to_dir)
-
-    def tag_pkg_parameters(self, tag_url):
-        match = re.search(r"/enterprise[^.]*\.[^.]*\."
-                          r"(?P<date>[0-9]{8})\.(?P<baserev>[0-9]+)/",
-                          tag_url)
-        if match:
-            date = match.group("date")
-            baserev = match.group("baserev")
-            xml_log = subversion.log_xml(tag_url, baserev)
-            revisions = subversion.extract_tag_revisions(xml_log)
-            tag_change_count = len(revisions)
-            return (date, tag_change_count)
-        else:
-            raise RuntimeError("Cannot determine tag parameters from %r"
-                               % tag_url)
+            return super(PackageTrack, self).new_revsision_packager()
--- a/treepkg/packager.py	Fri Oct 15 17:03:11 2010 +0000
+++ b/treepkg/packager.py	Wed Oct 20 07:51:53 2010 +0000
@@ -632,7 +632,10 @@
         env["DEB_BUILD_PARALLEL"] = "true"
         return env
 
-    def packager_for_new_revision(self):
+    def new_revsision_packager(self):
+        """ Checks if a new revision is available and returns a new
+        revision packager class. Don't override this method in a subclass.
+        Use packager_for_new_revision() instead."""
         current_revision = (self.last_changed_revision(),
                             self.rules_working_copy.last_changed_revision())
         logging.info("New revision is %s", current_revision)
@@ -644,6 +647,9 @@
             logging.info("Revision %s has already been packaged.",
                          current_revision)
 
+    def packager_for_new_revision(self):
+        return self.new_revsision_packager()
+
     def package_if_updated(self, revision=None, do_svn_update=True):
         """Returns a new packager if the working copy has not been packaged yet.
         If do_svn_update is true -- the default -- update the working
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)