summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2017-11-03 18:44:11 (GMT)
committerSam Thursfield <sam.thursfield@codethink.co.uk>2017-11-03 18:44:11 (GMT)
commitb917c363cc13b13ed553051844095469e1d6fc82 (patch)
tree374e0d6ac1b3f7fb9b18218f92577ab249b85d61
parent94955adfaff698034a4cb640263deefd05bfb3f1 (diff)
downloaddefinitions-b917c363cc13b13ed553051844095469e1d6fc82.tar.gz
Add scripts/baserock-release-metadata
This was meant to be added as part of MR !58, but of course I forgot to `git add`.
-rwxr-xr-xscripts/baserock-release-metadata66
1 files changed, 66 insertions, 0 deletions
diff --git a/scripts/baserock-release-metadata b/scripts/baserock-release-metadata
new file mode 100755
index 0000000..1b42967
--- /dev/null
+++ b/scripts/baserock-release-metadata
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+# Copyright (C) 2017 Codethink Limited
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; version 2 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+
+
+'''baserock-release-metadata
+
+Generates a YAML document with some simple metadata that should be included
+in release binaries
+
+This expects to be run inside the definitions repo so that it can figure
+out the Git commit being built.
+
+'''
+
+import collections
+import subprocess
+
+
+def git_show_commit():
+ return subprocess.check_output(
+ ['git', 'rev-parse', 'HEAD']).decode('unicode-escape').strip()
+
+
+def buildstream_version():
+ return subprocess.check_output(
+ ['bst', '--version']).decode('unicode-escape').strip()
+
+
+def main():
+ repo = "https://www.gitlab.com/baserock/definitions"
+ commit = git_show_commit()
+ build_tool = "Buildstream"
+ # This marks the version of BuildStream that checked out the sysroot
+ # artifact; the artifact may have pulled it from a cache though so
+ # we don't know what version of BuildStream actually built anything.
+ build_tool_version = buildstream_version()
+
+ # Here we produce a YAML document with specific ordering and formatting
+ # to ensure readability.
+ print("description: |\n"
+ " This sysroot was produced by the Baserock project.\n"
+ " See <http://www.baserock.org/> for more information.\n")
+ print("project-repo: %s" % repo)
+ print("project-commit: %s" % commit)
+ print()
+ print("build-tool: %s" % build_tool)
+ print("build-tool-version: %s" % build_tool_version)
+
+
+try:
+ main()
+except RuntimeError as e:
+ sys.stderr.write("%s\n" % e)
+ sys.exit(1)