Archiv für Juli 2008

That edgy chroot can go … oops!

I’m quite a heavy user of chroots, since I work with many different releases, and Debian, too. That usually means I have to clean them up at some point, too.

It happened at least twice now: I deleted an old chroot without unmounting all those bind mounts I have in them (/proc, /sys, /tmp, and most importantly, /home). Thus an rm -rf /chroots/edgy will remove my entire Home-partition, too! Fortunately I Control-C’ed early enough the second time to not cause any real damage except for killing my X socket in /tmp. Phew! But the first time (some months ago already) I lost quite some amount of data.

Thus, very high in my list of things I’d change to a default if I had a time machine to go back to the design of Unix:

alias rm='rm --one-file-system'

which now went into my standard ~/.bashrc.

Argh dbus-python

I have banged my head around integrating PackageKit into Jockey for several days now, and it’s driving me up the wall. While a standalone PackageKit client works very well, it completely breaks when I integrate the PackageKit client into my Jockey D-BUS backend.

At first I assumed I just made something wrong, so I tried a dozen different approaches, read the libpackagekit source, added a ton of debugging statements, but nothing helps, I never get back D-BUS signals from PackageKit while being in an inner gobject.MainLoop() in a D-BUS service handler. I use the exact approach that libpackagekit uses as well, so I don’t think I’m completely on crack.

I’m more and more convinced that this is an actual bug in dbus-python or perhaps in d-bus itself. I filed an upstream bug now, and really hope that some D-BUS expert can help me here.

Using PackageKit in Python

In order to provide a sensible upstream implementation for package query/install/remove methods in Jockey, I started playing with PackageKit and recently packaged and fixed the latest upstream version 0.2.2 work reasonably well on Intrepid.

Unfortunately there are no official Python bindings yet. The raw D-BUS interface is slightly inconvenient to use, since it is fully asynchronous. This seems to be pretty redundant to me, since D-BUS already provides asynchronous method calls (if you need them) and makes writing code painful in synchronous programs.

Thus I went ahead and created a fairly easy Python class for calling the most common PackageKit functions from a Python program (source code), including some demo code.

Now the usage becomes fairly simple:

    pk = PackageKitClient()

    print pk.Resolve('none', 'pmount')
    # [(False, 'pmount;0.9.17-2;amd64;Ubuntu', 'mount removable devices as normal user')]

    print pk.GetDetails('installation-guide-powerpc;20080520ubuntu1;all;Ubuntu')
    # ('unknown', 'unknown', 'This package contains the Ubuntu installation guide \
    # for the PowerPC architecture, in a variety of languages.\nA shorter reference, \
    # the installation HOWTO, is included in an appendix. ', '', 1074334)

    def cb(status, pc, spc, el, rem, c):
        print 'install pkg: %s, %i%%, cancel allowed: %s' % (status, pc, str(c))
        return True # return False to cancel
    pk.InstallPackages(['pmount;0.9.17-2;i386;Ubuntu', 'quilt;0.46-6;all;Ubuntu'], cb)

As usual in Python, errors are represented as exceptions.

This just leaves a few nitpicks now, such as PackageKit not being able to determine the package license with Apt, but by and large this provides the basic building blocks now.

Tags: , , ,

Asteroids bot submitted, publishing source

A while ago I blogged about my participation in the c’t programming contest to write a bot that plays against the 1979 Atari console.
Submission deadline was June 30th, and the results are trickling in now.

I am on rank 104, which I’m more than satisfied with. Unsurprisingly I didn’t make the top 50, I spent way too little time on it. But I had lots of fun with it, I have something that works, and at least outperforms my own Asteroids skills :-)

In case anyone is interested in it, the source code is on http://piware.de/bzr/ct-asteroids/. It’s a bzr branch, so you can bzr get the directory.

Tags: , , ,