summaryrefslogtreecommitdiff
path: root/scripts/baserock-release-metadata
blob: 1b42967183c30edd54e5ad22051d25e0a028a0b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
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)