[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [atomic-devel] Getting tree diffs from the Build Server



On Fri, Sep 5, 2014, at 10:56 AM, Jay Greguske wrote:
>
> I have a build server running that generates trees on certain events.
> I need a programmatic way to get a tree (commit?) ID, and what has
> changed since the last tree in a given repository. Ideally, this would
> be a list of changed RPMs or something.

rpm-ostree has code to inspect the RPM database inside a tree;
however, it isn't (yet) a shared library.

> There does not appear to be a remote API I can use for the build
> server to query this sort of thing, so I think I'm reduced to ssh'ing
> to the box that runs the service and running client commands. 

There isn't "the" build server right now, we have at least two codebases
that wrap rpm-ostree, and it sounds like you're making a third.  If
that's the case, certainly you could choose to make it an RPC server
or something too.

> Does
> anyone here have any recommendations on how to get the "latest" tree
> ID and what changed since the last one?

One thing to keep in mind is that there can be multiple branches per
repository.  We're not at the moment making use of that in the Fedora
context.

You can enumerate the branches, and then for each branch, traverse
the history.  If you look at the C implementation of "ostree refs" and
"ostree log", you can see how to do that.  Here's some demo Python
code:

#!/usr/bin/env python

import sys
from gi.repository import Gio, OSTree

repopath = sys.argv[1]

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

_,refs = r.list_refs(None, None)

for ref,commit in refs.iteritems():
    print "%s => %s" % (ref, commit)

    _,commit = r.load_variant(OSTree.ObjectType.COMMIT, commit)
    parent = OSTree.commit_get_parent(commit)
    if parent is None:
        print " (no parent)"
    else:
        print " parent: " + parent


Running it on a repo I have here:

fedora-atomic/f21/x86_64/cloud/docker-host =>
8d07f684474def4019dc62b58e4e02f6b6c67034ce802ac488c7ce98451a855f
 (no parent)
fedora-atomic/rawhide/x86_64/cloud/docker-host =>
b7ce8c06eb19e889de898237f95c6785b9d4be1b91e050172e1a24c77b4132bd
 parent:
 2473e486056dc781191431100f0c176694d213eafd63f8d3757ae6688fc86d6a
fedora-atomic/f21/x86_64/docker-host =>
2106157c09f7bb27dbe2ae0a5a05be85e39d7a46ffb6febdf8d9559c6aa6d4e6
 (no parent)
fedora-atomic/rawhide/x86_64/docker-host =>
f53cf01fda6afeab8c8522d6f228bc7cf7e74a8dd4e566267f41ee5b987135f4
 parent:
 8c62eb001e7abebbf316664247b0bd3f00081c8914da5c9de509056d9bfb2863
fedora-atomic/rawhide/x86_64/server/docker-host =>
c1527968faceb2b86375657761eb85e3ec1b73e7a00b49dd7c41a391ebe50dbf
 parent:
 014f39c36062e76a23bcc6e4a9d167b36ccd1a814a66a510a23c13f761b8a8b7

If you wanted to traverse the whole history, just pass the "parent" we
get in a loop back to load_variant().


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]