Skip to content

Commit

Permalink
build: Also output commitmeta.json
Browse files Browse the repository at this point in the history
This is generally useful but especially so for the pkglist alone for
higher level tools displaying releases/build outputs.

Closes: #197
  • Loading branch information
jlebon authored and cgwalters committed Nov 21, 2018
1 parent e4103a2 commit 816b2dc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/cmd-build
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,10 @@ EOF
# since we may be overriding data from a previous build.
cat "${composejson}" tmp/meta.json "${commitmeta_input_json}" | jq -s add > meta.json

# And add the commit metadata itself, which includes notably the rpmdb pkglist
# in a format that'd be easy to generate diffs out of for higher level tools
"${dn}"/commitmeta_to_json "${workdir}/repo" "${commit}" > commitmeta.json

# Clean up our temporary data
rm tmp -rf
# Back to the toplevel build directory, so we can rename this one
Expand Down
27 changes: 27 additions & 0 deletions src/commitmeta_to_json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python3 -u

import argparse
import gi
import sys

gi.require_version('OSTree', '1.0')
gi.require_version('Json', '1.0')
from gi.repository import GLib, Gio, OSTree, Json

parser = argparse.ArgumentParser()
parser.add_argument("repo", help="OSTree repo")
parser.add_argument("rev", help="Revision to inspect")
args = parser.parse_args()

r = OSTree.Repo.new(Gio.File.new_for_path(args.repo))
r.open(None)

[_, rev] = r.resolve_rev(args.rev, True)
[_, commit, _] = r.load_commit(rev)
commitmeta = commit.get_child_value(0)

g = Json.Generator.new()
g.set_root(Json.gvariant_serialize(commitmeta))
stdout = Gio.UnixOutputStream.new(sys.stdout.fileno(), False)
g.set_pretty(True)
g.to_stream(stdout)

0 comments on commit 816b2dc

Please sign in to comment.