#!/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 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)