Skip to content

Commit

Permalink
Add support for delta generation against the package shipped within
Browse files Browse the repository at this point in the history
BaseDeltaRelease configuration option e.g. 2011, 2011.1, etc.
  • Loading branch information
Ozan Çağlayan committed Mar 31, 2011
1 parent 951e71c commit 6ad69b5
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 0 deletions.
8 changes: 8 additions & 0 deletions buildfarm/pisiinterface.py
Expand Up @@ -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


Expand Down Expand Up @@ -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)
Expand Down
65 changes: 65 additions & 0 deletions buildfarm/releasecache.py
@@ -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)
6 changes: 6 additions & 0 deletions buildfarm/utils.py
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions data/buildfarm.conf
Expand Up @@ -7,6 +7,7 @@ Name=Pardus
Release=
SubRepository=devel
Architecture=
BaseDeltaRelease=

[SCM]
SCM=svn
Expand Down

0 comments on commit 6ad69b5

Please sign in to comment.