'Check Makefile and .config to return kernel version'

def get_xen_build_ver(self):

    version = patchlevel = sublevel = ''
    extraversion = localversion = ''
    for line in open((self.build_dir + '/xen/Makefile'), 'r').readlines():
        if line.startswith('export    XEN_VERSION'):
            start = (line.index('=') + 1)
            version = line[start:].strip()
        if line.startswith('export    XEN_SUBVERSION'):
            start = (line.index('=') + 1)
            sublevel = line[start:].strip()
        if line.startswith('export    XEN_EXTRAVERSION'):
            start = (line.index('=') + 1)
            extraversion = line[start:].strip()
    return ('%s.%s%s' % (version, sublevel, extraversion))
