diff options
author | Jordan Justen <jordan.l.justen@intel.com> | 2014-01-03 19:19:38 +0000 |
---|---|---|
committer | jljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524> | 2014-01-03 19:19:38 +0000 |
commit | 57dcb83f5963b5e88c78381d1bc63db1fbb8f3ed (patch) | |
tree | 72b05d03f5af54b18bfdb40e1bfc9077366686bd | |
parent | 6d3d4a7e9fa89e66b27b5769e129e9234c0e4455 (diff) | |
download | edk2-platforms-57dcb83f5963b5e88c78381d1bc63db1fbb8f3ed.tar.xz |
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
-rwxr-xr-x | OvmfPkg/create-release.py | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/OvmfPkg/create-release.py b/OvmfPkg/create-release.py index 3099d27d6c..fa00cb75c0 100755 --- a/OvmfPkg/create-release.py +++ b/OvmfPkg/create-release.py @@ -54,12 +54,22 @@ else: minor = max(4, min(7, gcc_version[1]))
TOOLCHAIN = 'GCC4' + str(minor)
-def git_svn_info():
+def git_based_version():
dir = os.getcwd()
- os.chdir('OvmfPkg')
- stdout = run_and_capture_output(args=('git', 'svn', 'info'))
+ if not os.path.exists('.git'):
+ 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)
- return stdout
+ return version
def svn_info():
dir = os.getcwd()
@@ -68,18 +78,18 @@ def svn_info(): os.chdir(dir)
return stdout
-def get_svn_info_output():
- if os.path.exists(os.path.join('OvmfPkg', '.svn')):
- return svn_info()
- else:
- return git_svn_info()
+def svn_based_version():
+ buf = svn_info()
+ revision_re = re.compile('^Revision\:\s*([\da-f]+)$', re.MULTILINE)
+ mo = revision_re.search(buf)
+ assert(mo is not None)
+ return 'r' + mo.group(1)
def get_revision():
- buf = get_svn_info_output()
- revision_re = re.compile('^Revision\:\s*(\d+)$', re.MULTILINE)
- mo = revision_re.search(buf)
- if mo is not None:
- return int(mo.group(1))
+ if os.path.exists(os.path.join('OvmfPkg', '.svn')):
+ return svn_based_version()
+ else:
+ return git_based_version()
revision = get_revision()
@@ -102,7 +112,7 @@ def gen_build_info(): iasl_version = iasl_version.split(' version ')[1].strip()
sb = StringIO.StringIO()
- print >> sb, 'edk2: ', 'r%d' % revision
+ print >> sb, 'edk2: ', revision
print >> sb, 'compiler: GCC', gcc_version_str, '(' + TOOLCHAIN + ')'
print >> sb, 'binutils:', ld_version
print >> sb, 'iasl: ', iasl_version
@@ -217,7 +227,7 @@ def build(arch): def create_zip(arch):
global build_info
- filename = 'OVMF-%s-r%d.zip' % (arch, revision)
+ filename = 'OVMF-%s-%s.zip' % (arch, revision)
print 'Creating', filename, '...',
sys.stdout.flush()
if os.path.exists(filename):
|