ia64/xen-unstable

changeset 12119:397cc120ae18

[XEND] Add some sort of rudimentary version embedding into the source
so we can report the Xend version number as opposed to Xen's version
number.

Signed-off-by: Alastair Tse <atse@xensource.com>
author Alastair Tse <atse@xensource.com>
date Thu Oct 12 12:27:56 2006 +0100 (2006-10-12)
parents 2ea55aa1dd46
children d21c7908e75c
files tools/python/setup.py tools/python/xen/__init__.py tools/python/xen/xend/XendNode.py tools/python/xen/xend/server/SrvDaemon.py
line diff
     1.1 --- a/tools/python/setup.py	Sat Oct 07 18:22:48 2006 +0100
     1.2 +++ b/tools/python/setup.py	Thu Oct 12 12:27:56 2006 +0100
     1.3 @@ -1,7 +1,39 @@
     1.4 +#!/usr/bin/python
     1.5  
     1.6  from distutils.core import setup, Extension
     1.7  import os
     1.8  
     1.9 +XEN_TOOLS_VERSION = '3.0.4'
    1.10 +
    1.11 +def embed_version():
    1.12 +    """ Embed Mercurial Changeset Version in xen/__init__.py. """
    1.13 +    try:
    1.14 +        import commands
    1.15 +        import re
    1.16 +        output = commands.getoutput('hg tip')
    1.17 +        version = XEN_TOOLS_VERSION
    1.18 +        changeset = ''
    1.19 +        date = ''
    1.20 +        if output:
    1.21 +            for line in output.split('\n'):
    1.22 +                is_changeset = re.search(r'^changeset:\s*(.*)$', line)
    1.23 +                if is_changeset:
    1.24 +                    changeset = is_changeset.group(1)
    1.25 +                is_date = re.search(r'^date:\s*(.*)$', line)
    1.26 +                if is_date:
    1.27 +                    date = is_date.group(1)
    1.28 +
    1.29 +        xen_init = open('xen/__init__.py', 'w')
    1.30 +        xen_init.write('# Warning, this file is autogenerated by setup.py\n')
    1.31 +        if version and changeset and date:
    1.32 +            xen_init.write('VERSION = "%s-%s (%s)"\n' %
    1.33 +                           (version, changeset, date))
    1.34 +        else:
    1.35 +            xen_init.write('VERSION = "%s"\n' % version)
    1.36 +        xen_init.close()
    1.37 +    except:
    1.38 +        print 'Warning: Unable to extract version.'
    1.39 +
    1.40  XEN_ROOT = "../.."
    1.41  
    1.42  extra_compile_args  = [ "-fno-strict-aliasing", "-Wall", "-Werror" ]
    1.43 @@ -38,8 +70,11 @@ acm = Extension("acm",
    1.44                 libraries          = libraries,
    1.45                 sources            = [ "xen/lowlevel/acm/acm.c" ])
    1.46  
    1.47 +
    1.48 +embed_version()
    1.49 +
    1.50  setup(name            = 'xen',
    1.51 -      version         = '3.0',
    1.52 +      version         = XEN_TOOLS_VERSION,
    1.53        description     = 'Xen',
    1.54        packages        = ['xen',
    1.55                           'xen.lowlevel',
     2.1 --- a/tools/python/xen/__init__.py	Sat Oct 07 18:22:48 2006 +0100
     2.2 +++ b/tools/python/xen/__init__.py	Thu Oct 12 12:27:56 2006 +0100
     2.3 @@ -1,1 +1,2 @@
     2.4 - 
     2.5 +# Warning, this file is autogenerated by setup.py
     2.6 +VERSION = "3.0.4-50:fa1d6b491cc5 (Fri Oct 06 22:50:29 2006 +0100)"
     3.1 --- a/tools/python/xen/xend/XendNode.py	Sat Oct 07 18:22:48 2006 +0100
     3.2 +++ b/tools/python/xen/xend/XendNode.py	Thu Oct 12 12:27:56 2006 +0100
     3.3 @@ -71,7 +71,9 @@ class XendNode:
     3.4  
     3.5      def xen_version(self):
     3.6          info = self.xc.xeninfo()
     3.7 -        return {'Xen': '%(xen_major)d.%(xen_minor)d' % info}
     3.8 +        from xen import VERSION
     3.9 +        return {'Xen': '%(xen_major)d.%(xen_minor)d' % info,
    3.10 +                'Xend': VERSION}
    3.11  
    3.12      def get_name(self):
    3.13          return self.name
     4.1 --- a/tools/python/xen/xend/server/SrvDaemon.py	Sat Oct 07 18:22:48 2006 +0100
     4.2 +++ b/tools/python/xen/xend/server/SrvDaemon.py	Thu Oct 12 12:27:56 2006 +0100
     4.3 @@ -289,6 +289,12 @@ class Daemon:
     4.4              log.info("Xend changeset: %s.", xinfo['xen_changeset'])
     4.5              del xc
     4.6  
     4.7 +            try:
     4.8 +                from xen import VERSION
     4.9 +                log.info("Xend version: %s", VERSION)
    4.10 +            except ImportError:
    4.11 +                log.info("Xend version: Unknown.")
    4.12 +
    4.13              relocate.listenRelocation()
    4.14              servers = SrvServer.create()
    4.15              servers.start(status)