A pre-release is any release where %{release} starts with 0. When building RPMs of pre-releases, a datestamp and githash are included in the RPM %{release} string. This allows to easily determine when and what is included in the built packages. --- oz.spec.in | 2 +- setup.py | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/oz.spec.in b/oz.spec.in index ece60ec..ca7583e 100644 --- a/oz.spec.in +++ b/oz.spec.in @@ -1,7 +1,7 @@ Summary: Library and utilities for automated guest OS installs Name: oz Version: @VERSION@ -Release: 1%{?dist} +Release: 0%{?dist} License: LGPLv2 Group: Development/Libraries URL: http://aeolusproject.org/oz.html diff --git a/setup.py b/setup.py index ff2b318..9ed0615 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,15 @@ from distutils.core import setup, Extension, Command from distutils.command.sdist import sdist as _sdist -import os +import os, sys +import subprocess + +def call(*args): + p = subprocess.Popen(*args, shell=True, \ + stdout=subprocess.PIPE) + return p.communicate()[0]
VERSION = '0.7.0' +RELEASE = call("grep '^\s*Release:' oz.spec.in | gawk '{print $2}'")
datafiles = [('share/man/man1', ['man/oz-install.1', 'man/oz-customize.1', 'man/oz-generate-icicle.1', @@ -13,8 +20,13 @@ class sdist(_sdist): """ custom sdist command, to prep oz.spec file for inclusion """
def run(self): - cmd = (""" sed -e "s/@VERSION@/%s/g" < oz.spec.in """ % - VERSION) + " > oz.spec" + cmd = 'sed -e "s|@VERSION@|%s|g"' % VERSION + if RELEASE.startswith('0'): + git_head = call("git log -1 --pretty=format:%h").strip() + date = call("date --utc +%Y%m%d%H%M%S").strip() + git_release = "%sgit%s" % (date, git_head) + cmd += ''' -e "s|^(Release:[^%%]*)|\1.%s|"''' % git_release + cmd += ' < oz.spec.in > oz.spec' os.system(cmd)
_sdist.run(self)