Commit f31c364b authored by Vangelis Koukis's avatar Vangelis Koukis Committed by Christos Stavrakakis

WIP commit for the devtools build system

parent c12e0430
Copyright (C) 2010, 2011, 2012 GRNET S.A. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
1. Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and
documentation are those of the authors and should not be
interpreted as representing official policies, either expressed
or implied, of GRNET S.A.
#!/bin/bash
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
parse_git_branch()
{
git branch 2> /dev/null | grep '^*' | sed 's/^*\ //g'
......@@ -98,7 +131,7 @@ snap=false
mrgextra=-m
dchextra=-R
mrgmsg="Merge branch '$REMOTEUPSTREAM' into $REMOTEDEBIAN"
dialog --yesno "Create Snapshot?" 5 20 && snap=true && dchextra=-S && mrgextra= && mrgmsg=
dialog --yesno "Create Snapshot?" 5 20 && snap=true && GITFLOW_BUILD_MODE=snapshot && dchextra=-S && mrgextra= && mrgmsg=
# merge local branch into tmp branch with a nice commit message,
# so it can be pushed as is to upstream debian
......@@ -107,7 +140,11 @@ git merge $mrgextra ${mrgextra:+"$mrgmsg"} $LOCALBRANCH
# auto edit Debian changelog depending on Snapshot or Release mode
export EDITOR=/usr/bin/vim
git-dch --debian-branch=$TMPDEBIAN --git-author --ignore-regex=".*" --multimaint-merge --since=HEAD $dchextra
# use the devtools to determine Debian version
export GITFLOW_BUILD_MODE
version=$(devtools/version.py debian)
git-dch --debian-branch=$TMPDEBIAN --git-author --ignore-regex=".*" --multimaint-merge --since=HEAD -N $version
git add debian/changelog
# get version from the changelog
......
#!/usr/bin/env python
#
# Copyright 2012 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# 2. Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials
# provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
#
#
"""Unit Tests for devtools.version
Provides unit tests for module devtools.version,
for automatic generation of version strings.
"""
import os
import unittest
from pkg_resources import parse_version
from version import debian_version_from_python_version
class DebianVersionObject(object):
"""Object representing a Debian Version."""
def __init__(self, pyver):
self.version = debian_version_from_python_version(pyver)
def __str__(self):
return self.version
def debian_compare_versions(a, op, b):
i = os.system("dpkg --compare-versions %s %s %s" % (a, op, b))
return i == 0
# Set ordering between DebianVersionObject objects, by adding
# debian_compare_versions
for op in ["lt", "le", "eq", "ne", "gt", "ge"]:
def gen(op):
def operator_func(self, other):
return debian_compare_versions(self.version, op, other.version)
return operator_func
setattr(DebianVersionObject, "__%s__" % op, gen(op))
def _random_commit():
import random
import string
return "".join(random.choice(string.hexdigits) for n in xrange(8)).lower()
# Add a random commit number at the end of snapshot versions
def version_with_commit(parse_func, v):
if "_" in v:
return parse_func(v + "_" + _random_commit())
else:
return parse_func(v)
V = lambda v: version_with_commit(parse_version, v)
D = lambda v: version_with_commit(DebianVersionObject, v)
class TestVersionFunctions(unittest.TestCase):
def setUp(self):
self.version_orderings = (
("0.14next", ">", "0.14"),
("0.14next", ">", "0.14rc7"),
("0.14next", "<", "0.14.1"),
("0.14rc6", "<", "0.14"),
("0.14.2rc6", ">", "0.14.1"),
("0.14next_150", "<", "0.14next"),
("0.14.1next_150", "<", "0.14.1next"),
("0.14.1_149", "<", "0.14.1"),
("0.14.1_149", "<", "0.14.1_150"),
("0.13next_102", "<", "0.13next"),
("0.13next", "<", "0.14rc5_120"),
("0.14rc3_120", "<", "0.14rc3"),
# The following test fails, but version.python_version
# will never try to produce such a version:
# ("0.14rc3", "<", "0.14_1"),
("0.14_120", "<", "0.14"),
("0.14", "<", "0.14next_20"),
("0.14next_20", "<", "0.14next"),
)
def test_python_versions(self):
for a, op, b in self.version_orderings:
res = compare(V, a, op, b)
self.assertTrue(res, "Python version: %s %s %s"
" is not True" % (a, op, b))
def test_debian_versions(self):
for a, op, b in self.version_orderings:
res = compare(D, a, op, b)
self.assertTrue(res, "Debian version %s %s %s"
" is not True" % (a, op, b))
def compare(function, a, op, b):
import operator
str_to_op = {"<": operator.lt,
"<=": operator.le,
"==": operator.eq,
">": operator.gt,
">=": operator.ge}
try:
return str_to_op[op](function(a), function(b))
except KeyError:
raise ValueError("Unknown operator '%s'" % op)
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
......@@ -47,11 +47,11 @@ from astakos import get_version
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util import version
version.update_version('astakos', 'version', HERE)
# use devtools to update the version file
from devtools.version import update_version
update_version('astakos', 'common', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from astakos.version import __version__
......
......@@ -44,11 +44,11 @@ from setuptools import setup, find_packages
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util.version import update_version
# use devtools to update the version file
from devtools.version import update_version
update_version('synnefo.versions', 'common', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from synnefo.versions.common import __version__
......
......@@ -44,11 +44,11 @@ from setuptools import setup, find_packages
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util.version import update_version
# use devtools to update the version file
from devtools.version import update_version
update_version('synnefo.versions', 'app', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from synnefo.versions.app import __version__
......
......@@ -40,11 +40,11 @@ from setuptools import setup
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util.version import update_version
# use devtools to update the version file
from devtools.version import update_version
update_version('synnefo.versions', 'ganeti', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from synnefo.versions.ganeti import __version__
......
......@@ -42,12 +42,13 @@ from fnmatch import fnmatchcase
from setuptools import setup, find_packages
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util import version
version.update_version('pithos.api', 'version', HERE)
# use devtools to update the version file
from devtools.version import update_version
update_version('pithos.api', 'version', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from pithos.api.version import __version__
......
......@@ -42,12 +42,13 @@ from fnmatch import fnmatchcase
from setuptools import setup, find_packages
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util import version
version.update_version('pithos.backends', 'version', HERE)
# use devtools to update the version file
from devtools.version import update_version
update_version('pithos.backends', 'version', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from pithos.backends.version import __version__
......
......@@ -44,12 +44,13 @@ from fnmatch import fnmatchcase
from setuptools import setup, find_packages
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util import version
version.update_version('pithos.tools', 'version', HERE)
# use devtools to update the version file
from devtools.version import update_version
update_version('pithos.tools', 'version', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from pithos.tools.version import __version__
......
......@@ -44,11 +44,11 @@ from setuptools import setup, find_packages
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util.version import update_version
# use devtools to update the version file
from devtools.version import update_version
update_version('synnefo_tools', 'version', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from synnefo_tools.version import __version__
......
......@@ -44,11 +44,11 @@ from setuptools import setup, find_packages
HERE = os.path.abspath(os.path.normpath(os.path.dirname(__file__)))
try:
# try to update the version file
from synnefo.util.version import update_version
# use devtools to update the version file
from devtools.version import update_version
update_version('synnefo.versions', 'webproject', HERE)
except ImportError:
pass
raise RuntimeError("devtools is a build dependency")
from synnefo.versions.webproject import __version__
......
# This is a comment!
0.14next
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment