OvmfPkg/create-release.py: Support git hash versions
Previously we would run 'git svn info' if a .svn directory wasn't found. This would fail if the current local commit was not from git-svn. Now we look for the svn info in the output from git log. If the svn version is not in a git-svn-id tag from git log, then we use the git commit hash. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15042 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -54,12 +54,22 @@ else:
|
|||||||
minor = max(4, min(7, gcc_version[1]))
|
minor = max(4, min(7, gcc_version[1]))
|
||||||
TOOLCHAIN = 'GCC4' + str(minor)
|
TOOLCHAIN = 'GCC4' + str(minor)
|
||||||
|
|
||||||
def git_svn_info():
|
def git_based_version():
|
||||||
dir = os.getcwd()
|
dir = os.getcwd()
|
||||||
os.chdir('OvmfPkg')
|
if not os.path.exists('.git'):
|
||||||
stdout = run_and_capture_output(args=('git', 'svn', 'info'))
|
os.chdir('OvmfPkg')
|
||||||
|
stdout = run_and_capture_output(args=('git', 'log',
|
||||||
|
'-n', '1',
|
||||||
|
'--abbrev-commit'))
|
||||||
|
regex = re.compile(r'^\s*git-svn-id:\s+\S+@(\d+)\s+[0-9a-f\-]+$',
|
||||||
|
re.MULTILINE)
|
||||||
|
mo = regex.search(stdout)
|
||||||
|
if mo:
|
||||||
|
version = 'r' + mo.group(1)
|
||||||
|
else:
|
||||||
|
version = stdout.split(None, 3)[1]
|
||||||
os.chdir(dir)
|
os.chdir(dir)
|
||||||
return stdout
|
return version
|
||||||
|
|
||||||
def svn_info():
|
def svn_info():
|
||||||
dir = os.getcwd()
|
dir = os.getcwd()
|
||||||
@ -68,18 +78,18 @@ def svn_info():
|
|||||||
os.chdir(dir)
|
os.chdir(dir)
|
||||||
return stdout
|
return stdout
|
||||||
|
|
||||||
def get_svn_info_output():
|
def svn_based_version():
|
||||||
if os.path.exists(os.path.join('OvmfPkg', '.svn')):
|
buf = svn_info()
|
||||||
return svn_info()
|
revision_re = re.compile('^Revision\:\s*([\da-f]+)$', re.MULTILINE)
|
||||||
else:
|
mo = revision_re.search(buf)
|
||||||
return git_svn_info()
|
assert(mo is not None)
|
||||||
|
return 'r' + mo.group(1)
|
||||||
|
|
||||||
def get_revision():
|
def get_revision():
|
||||||
buf = get_svn_info_output()
|
if os.path.exists(os.path.join('OvmfPkg', '.svn')):
|
||||||
revision_re = re.compile('^Revision\:\s*(\d+)$', re.MULTILINE)
|
return svn_based_version()
|
||||||
mo = revision_re.search(buf)
|
else:
|
||||||
if mo is not None:
|
return git_based_version()
|
||||||
return int(mo.group(1))
|
|
||||||
|
|
||||||
revision = get_revision()
|
revision = get_revision()
|
||||||
|
|
||||||
@ -102,7 +112,7 @@ def gen_build_info():
|
|||||||
iasl_version = iasl_version.split(' version ')[1].strip()
|
iasl_version = iasl_version.split(' version ')[1].strip()
|
||||||
|
|
||||||
sb = StringIO.StringIO()
|
sb = StringIO.StringIO()
|
||||||
print >> sb, 'edk2: ', 'r%d' % revision
|
print >> sb, 'edk2: ', revision
|
||||||
print >> sb, 'compiler: GCC', gcc_version_str, '(' + TOOLCHAIN + ')'
|
print >> sb, 'compiler: GCC', gcc_version_str, '(' + TOOLCHAIN + ')'
|
||||||
print >> sb, 'binutils:', ld_version
|
print >> sb, 'binutils:', ld_version
|
||||||
print >> sb, 'iasl: ', iasl_version
|
print >> sb, 'iasl: ', iasl_version
|
||||||
@ -217,7 +227,7 @@ def build(arch):
|
|||||||
|
|
||||||
def create_zip(arch):
|
def create_zip(arch):
|
||||||
global build_info
|
global build_info
|
||||||
filename = 'OVMF-%s-r%d.zip' % (arch, revision)
|
filename = 'OVMF-%s-%s.zip' % (arch, revision)
|
||||||
print 'Creating', filename, '...',
|
print 'Creating', filename, '...',
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
|
Reference in New Issue
Block a user