Hacking Koji

For Fun aNd Profit

 

Mike McLean

Release Engineering Development

About Mike

  • Koji author/maintainer

  • Release Engineering Development

  • Long ago: installer QA

  • Past life: mathematics

  • FAS: mikem

  • mikem@redhat.com

About Koji

  • Fedora's build system

  • but also used by

    • Red Hat

    • CentOS

    • Scientific Linux

    • Amazon

    • and more

WHY Hack IT?

  • Custom client scripts

  • Dig into data

  • Interface with other infra

  • Customize behavior

  • Appearance

  • New features

Components

[command line]

[mike@localhost ~]$ koji help
[mike@localhost ~]$ koji list-history --package koji --after 2016-07-21
Fri Jul 22 05:40:19 2016 koji-1.10.1-10.fc24 tagged into f24-updates-pending by bodhi
Fri Jul 22 12:22:12 2016 koji-1.10.1-10.fc24 untagged from f24-updates-testing by bodhi
Fri Jul 22 12:22:12 2016 koji-1.10.1-10.fc24 tagged into f24-updates by bodhi [still active]
Fri Jul 22 12:22:50 2016 koji-1.10.1-10.fc24 untagged from f24-updates-pending by bodhi
Tue Jul 26 13:21:37 2016 package list entry created: koji in f26 by mohanboddu [still active]
Tue Jul 26 14:23:19 2016 koji-1.10.1-11.fc25 tagged into f26 by mohanboddu [still active]


koji list-history
$ koji --noauth call getPackage koji
{'id': 1181, 'name': 'koji'}

$ koji --noauth call listBuilds --kwargs
'{"packageID":1181, "queryOpts":{"limit":1}}' [{'build_id': 781616, 'completion_time': '2016-07-19 08:25:15.011642', 'completion_ts': 1468916715.01164, 'creation_event_id': 17252617, 'creation_time': '2016-07-19 08:02:03.281765', 'creation_ts': 1468915323.28176, 'epoch': None, 'name': 'koji', 'nvr': 'koji-1.10.1-11.fc25', 'owner_id': 3445, 'owner_name': 'releng', 'package_id': 1181, 'package_name': 'koji', 'release': '11.fc25', 'start_time': '2016-07-19 08:02:03.281765', 'start_ts': 1468915323.28176, 'state': 1, 'task_id': 14940366, 'version': '1.10.1', 'volume_id': 0, 'volume_name': 'DEFAULT'}]
...
build(src, target, opts=None, priority=None, channel=None)
  description: Create a build task

        priority: the amount to increase (or decrease) the task priority, relative
                  to the default priority; higher values mean lower priority; only
                  admins have the right to specify a negative priority here
        channel: the channel to allocate the task to
        Returns the task id

...

$ koji list-api

[Python lib]

import koji
session = koji.ClientSession(
    'https://koji.fedoraproject.org/kojihub')

pkg = session.getPackage('koji')
builds = session.listBuilds(packageID=pkg['id'])

for b in builds:
    print b['nvr']

A Simple Example

More examples

see the koji client

Other Languages

  • It's just XML-RPC (with nil extension)

  • koji --debug-xmlrpc can be helpful

$ curl --data @req http://koji.fedoraproject.org/kojihub
$ cat req
<?xml version='1.0'?>
<methodCall>
<methodName>getTag</methodName>
<params>
<param>
<value><string>f25</string></value>
</param>
</params>
</methodCall>
 

Web Themes

  • Override static images and css
  • /usr/share/koji-web/static/themes/MYTHEME
  • set KojiTheme=MYTHEME in web.conf
  • extra-nav.html
  • extra-footer.html

Hub Policy

Hub Plugins

Builder Plugins

change the code

  • git clone https://pagure.io/koji.git
  • ...
  • make test
  • make srpm

Contributing

  • https://pagure.io/koji
  • koji-devel@lists.fedorahosted.org

Q&A

THANK YOU!

redhat.com