Permalink
Browse files

Add support for delta generation against the package shipped within

BaseDeltaRelease configuration option e.g. 2011, 2011.1, etc.
  • Loading branch information...
1 parent 951e71c commit 6ad69b55181d83143edb15e195617256ece4d333 Ozan Çağlayan committed Mar 31, 2011
Showing with 80 additions and 0 deletions.
  1. +8 −0 buildfarm/pisiinterface.py
  2. +65 −0 buildfarm/releasecache.py
  3. +6 −0 buildfarm/utils.py
  4. +1 −0 data/buildfarm.conf
@@ -17,6 +17,7 @@
import pisi.config
from buildfarm import cli, logger, utils
+from buildfarm.releasecache import ReleaseCache
from buildfarm.config import configuration as conf
@@ -79,6 +80,13 @@ def build(self, pspec):
self.builder.search_old_packages_for_delta(max_count=3,
search_paths=(utils.get_stable_packages_directory(),))
+ # and 1 for the previous distribution release (e.g. 2011.1)
+ package_name = utils.get_package_name_from_path(pspec)
+ last_disto_release = ReleaseCache().get_last_release(package_name)
+ if last_distro_release:
+ self.builder.search_old_packages_for_delta(release=last_distro_release,
+ search_paths=(utils.get_stable_packages_directory(),))
+
self.builder.build()
logger.info("Created package(s): %s" % self.builder.new_packages)
View
@@ -0,0 +1,65 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2011 TUBITAK/UEKAE
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Please read the COPYING file.
+
+import os
+import pisi
+import piksemel
+
+from buildfarm import utils
+from buildfarm import logger
+from buildfarm.config import configuration as conf
+
+class ReleaseCache(object):
+ """Holds a mapping of source package names to release numbers.
+ This is used to fetch the release numbers of packages back in
+ release time like 2011, 2011.1, etc."""
+
+ __metaclass__ = pisi.util.Singleton
+
+ def __init__(self):
+ self.d = {}
+
+ # Final local index that should exist
+ local_index = os.path.join(conf.buildfarmdir, "index-%s.xml" % conf.basedeltarelease)
+
+ if not os.path.exists(local_index):
+ remote_index = utils.get_remote_tags_repository_index_url()
+ try:
+ index_file = pisi.file.File(remote_index,
+ mode=pisi.file.File.read,
+ transfer_dir=conf.buildfarmdir,
+ compress=pisi.file.File.COMPRESSION_TYPE_AUTO)
+ # Index available, rename it
+ os.rename(os.path.join(conf.buildfarmdir, "pisi-index.xml"), local_index)
+ os.unlink(os.path.join(conf.buildfarmdir, "pisi-index.xml.bz2"))
+ except:
+ logger.error("Could not fetch %s will not build delta packages against %s release!" % (remote_index,
+ conf.basedeltarelease))
+ return
+
+ # Parse it
+ doc = piksemel.parse(local_index)
+
+ for specfile in doc.tags("SpecFile"):
+ source = specfile.getTag("Source")
+ name = source.getTagData("Name")
+
+ history = specfile.getTag("History")
+ update = history.getTag("Update")
+ release = update.getAttribute("release")
+
+ self.d[name] = release
+
+ def get_last_release(self, package_name):
+ """Returns the release number of package_name in the last
+ release."""
+ return self.d.get(package_name)
View
@@ -84,6 +84,12 @@ def get_remote_repository_url():
conf.release,
conf.subrepository)
+def get_remote_tags_repository_index_url():
+ return os.path.join(conf.scmrepositorybaseurl,
+ "tags",
+ conf.basedeltarelease,
+ "pisi-index.xml.bz2")
+
def get_package_log_directory():
return os.path.join(conf.logdir,
conf.release,
View
@@ -7,6 +7,7 @@ Name=Pardus
Release=
SubRepository=devel
Architecture=
+BaseDeltaRelease=
[SCM]
SCM=svn

0 comments on commit 6ad69b5

Please sign in to comment.