[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

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

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

_,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)"
        print " parent: " + parent

Running it on a repo I have here:

fedora-atomic/f21/x86_64/cloud/docker-host =>
 (no parent)
fedora-atomic/rawhide/x86_64/cloud/docker-host =>
fedora-atomic/f21/x86_64/docker-host =>
 (no parent)
fedora-atomic/rawhide/x86_64/docker-host =>
fedora-atomic/rawhide/x86_64/server/docker-host =>

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]