A Very Aptly Ruby API

ruby

At Blue Systems we are running a whole slew of different deb repositories all over the place. Primarily of course for the various CI systems we are working on for Plasma Mobile, Debian, and KDE neon.

A while ago Rohan Garg suggested we should use Aptly, a relatively new repository management system written in Go featuring advanced features such as repository mirroring, publishing to Amazon S3 and a REST API. Since I do like me some REST APIs I was quickly sold on the idea of adopting it as our primary repository system.

Alas, most of our CI rigging is written in Ruby and there was no usable API gem in sight.

Low and behold: I wrote a Ruby gem for Aptly’s REST API. It’s called aptly-api.

It covers all the common repository usage from creating repositories and adding files, to publishing repositories to a publishing location. Let’s look at some code.

For example here we create a repository and publish it as public-name.

require 'aptly'

Aptly.configure do |config|
  config.host = 'localhost'
  config.port = 8080
end

repo = Aptly::Repository.create('kewl-new-repo')
repo.publish('public-name', Distribution: 'wily', Architectures: %w(amd64 i386))

Aptly has two notions of a repository. There is a repository and then there is a published repository. A published repository essentially is an on-disk representation of a repository, namely what you would actually find on any deb repository like archive.ubuntu.com. These published repositories have one (or more!) repositories associated with it. All packages in that repository will be part of the published repository. This allows you to have neat repository sets where internally you have packages separate in multiple repositories but publicly they show up in the same published repository tree. For instance you could have a repository for qt and a repository for kde-frameworks, but publicly your deb repository would contain both qt’s and kde-frameworks’ packages.

Let’s add a deb to our repository…

repo = Aptly::Repository.get('kewl-new-repo')
repo.upload('kitteh.deb')

At this point kitteh will not actually show up in the published directory, we first have to update it. In fact, let’s update all published repositories our repository is part of, chances are we want all to refresh anyway.

repo.published_in.each(&:update!)

For more useful information on aptly-api have a look at the gem documentation. If you find aptly-api useful, drop me a comment. Pull requests and bug reports are of course appreciated as well.


Bonus: Secure Remote

Aptly presently doesn’t support API authentication, so you’d rightfully wonder how exactly we secure the beast. Surely we aren’t publicly binding the API server for all the world to abuse.

The solution, as so often in life, is of course SSH. Namely if you want to use the API on a remote you could simply tunnel the relevant port to your localhost.

require 'aptly'
require 'net/ssh/gateway'

gateway = Net::SSH::Gateway.new('hostname', 'username')
port = gateway.open('localhost', 8080, 8080)

Aptly.configure do |config|
  config.host = 'localhost'
  config.port = port
end

 

Muon 5.5 and Carrots

image

Jonathan Riddell, Leader of Flies, kept holding me until I write a blog post, so here is one.

After 2 days of obscenely unsubsidized drinking and vicious discussions about carrots, the KDE and Kubuntu developers here at the developer sprint in Munich decided to release the Debian package manager Muon in version 5.5.0.

A very prominent thing to take away from this sprint is “oops”. I am not sure that is good, but oh well.

Hearts and kisses!

A Touch of Plasma in the Mountains

It is this time of the year again. In but a few weeks some 50 KDE contributors are going to take over the village of Randa in the Swiss Alps to work on making KDE software yet more awesome.

So if you would kindly click on this fancy image here to donate a penny a or two, I think you will make people around the world eternally grateful:

Fundraiser-Banner-2015

Not convinced yet? Oh my.

The KDE Sprints in Randa are an annual event where different parts of the KDE community meet in the village of Randa in Switzerland to focus their minds and spirit on making KDE software better, faster, more robust, more secure, and of course better looking as well.

Sprints are a big part of KDE development, they enable contributors to meet in person and focus the entire thrust of their team on pushing their project and the KDE community as a whole forward. KDE software is primarily built by a community of volunteers and as such they require support to finance these sprints to leap forward in development and bring innovation to software.

If you have not yet perused the Randa 2015 page, you definitely should. You will probably find that the list of main projects for this year not only sound very interesting, but will in all likelihood be relevant to you. If you own a smartphone or tablet you can benefit from KDEConnect which makes your mobile device talk to your computer (by means of magic no less). Or perhaps you’d rather have the opportunity to run Plasma on your mobile device? General investments in touch-support and enablement are going to go a long way to achieve that. Do you like taking beautiful photographs? Improvements to digiKam will make it even easier to manage and organize your exploits.
These are but a few things the KDE contributors are going to focus on in Randa. All in all there should be something for everyone to get behind and support.

KDE is a diverse community with activities in many different areas in and around software development. Standing as a beacon of light in a world where everyone tries to gobble up as much information about their users as possible, or lock users’ data in proprietary formats from which they cannot ever be retrieved again, or quite simply spy on people.

Be a benefactor of freedom. Support Randa 2015.