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

 

Kubuntu apps repraise

Some of you might have noticed that recently two new Kubuntu apps hit the CD for the upcoming 9.10 release.

Also some bugfix improvements were done to the available ones.

AptUrl

Apturl is a tiny application that allows installation of packages via apt:// URLs. So for example apt://firefox will install Firefox. This fancyness is available in Ubuntu and Firefox since 7.10 and starting with 9.10 also in Kubuntu (aight, 4 releases lag is not that bad ;)).

The good thing about KDE is that, since AptUrl provides a protocol handler for KDE it is technically available to any KDE application right away.
So if you some friend a message containing apt://tellico Kopete will allow them to open the link and the Apturl app starts doing its magic.

Also, you can just as well enter such an URL in KRunner (the thing that pops up when pressing Alt+F2). I suppose you get the point 🙂

Kubuntu-Firefox-Installer
At some recent Kubuntu meeting we came to discuss the situation of web browsers. Basically coming down to whether we do not ship Firefox by default. The answer appears to be that it wouldn’t fit on the CD (or only at the cost of translations).
So dearest seele suggested that we create a simplified installer that allows users to find something ‘firefoxish’ that leads them directly to installation. The apachelogger code-monkey seemed to like that idea and started hacking on kubuntu-firefox-installer.
The application is really fairly simple. It provides a menu entry in the Internet category of the menu and upon launch will offer the user to install Firefox. It currently does not remove itself when Firefox finished installing and doesn’t use the official Firefox icon (due to trademark restrictions) though both should be resolved one way or another by release time of 9.10.
In addition to the Firefox installer I trying to get a least my Oxygen theme for Firefox ported to 3.5 in time, so the user experience can be even better.
Others
I hope to have install-package (the thing that is used when installing codecs for example) replaced by KPackageKit rather sooner than later (dantti to the rescue!). Mostly because the install-package UI looks pretty bad alright (next to be nuked is gdebi-kde).
qt-language-selector (the thing that allows installation and selection of the system-wide language) is in immediate need of UI love as well, so I might digg a bit into that. Also the way it is integrated into KDE’s locale KCM is quite confusing.
software-properties (management of sources.list) is in a pretty good shape, it got some annoying bugs and doesn’t support import of sources.list files yet.
Really, even though those apps are written in python their code is not half bad 😉
All in all I am quite confident that 10.04 (i.e. the release after 9.10), which is likely going to be a long term support release for Kubuntu, will ship with a set of actually working applications. Be it Kubuntu specific ones or those that we (had to) include prematurely.

Improving Kubuntu’s l10n + Icon making

https://lists.ubuntu.com/archives/kubuntu-devel/2009-June/002964.html

The best mail in all of June 😀
Which made me create:
… a fancy ruby script to parse KDE’s process_orphans.txt file in order to track po movements (which need to be applied manually to the Launchpad templates), the design is as wicked as it can get, but it seems to work (at least for core KDE).
Talking about ruby… the ruby tutorial at the Kubuntu Tutorials Day was kind of weird (I still find the concept of IRC talks rather confusing TBH), it certainly could have been worse though. I think that it is pretty diffcult to squeeze the awesomeness of ruby into a one hour tutorial. Pretty lame excuse, huh? 😛
Later on kwwii did an awesome talk about artworking which made me create:
Though it might be better to use the Kubuntu icon rather than the text, because you really wouldn’t notice that this icon is about Kubuntu at 48×48.
All in all, the tutorials were really awesome and totally worth almost falling asleep at the dentist’s today 🙂