My Run In with CentOS at LinuxTag

As everyone can now see in Mo's post, my laptop cover is almost completely covered with stickers. Having no room left there, it's time to sticker up my laptop bag. I'm trying to start a new meme where i have Shadowman saying various things, and convincing people to use Fedora stickers. Hopefully there will be some pictures later, if i run into Mo.

On my quest to get some stickers, i decided that a CentOS sticker would also be appropriate. Although i was scheduled to start at the booth just then, i decided a quick jaunt over to the CentOS booth would only take a couple of minutes. The guys there were more than happy to help me sticker up my laptop bag further.

While i was there, i started talking with Didi and others about Hacking At Random. Well, the everyone there likes camping, so it seems we will have quite a bit of a CentOS presence there. They were planning on bringing a larger tent as well, so taking up the opportunity, we agreed to try to combine our tents a bit. Now it seems the FreeJ/Dyne/Fedora Village has just gotten a bit bigger.

For HAR, we're planning on starting an Event Box for EMEA and debuting it there. Hopefully if we get our hands on a projector and screen, we can do a combination of a Fedora/CentOS/FreeJ barcamp as well as VJing and running demos at night. If you want to participate in the process of putting together the Event Box, we'll be having a session at FUDCon on Saturday or Sunday to coordinate planning and hammer out a few details.

The New Treasurer of Fedora EMEA e.V.

Three blog posts in one day. I hope this doesn't become a daily habit.

Today we had our yearly LinuxTag members meeting of Fedora EMEA. For those of you that don't know, Fedora EMEA is The Bikeshed of politics. Picture this, a bunch of computer hackers with access to a legal entity with legal bylaws and rules that run in parallel but outside of the standard Fedora processes. Put us all in one room, give us a two hour time limit, and i guarantee you we'll argue about how to vote for at least an hour. All in all, it's alot of fun.

At our meeting, Max had to unfortunately announce that he is resigning as treasurer. At the time he joined, it was wise to keep the treasurer position tied in with managing the EMEA budget in Fedora while things were being defined in EMEA over the past year. By now though, we have a bit of a rhythm set up when it comes to sponsoring and supporting events. Ultimately, this position should be entirely in the hands of the community.

I had been thinking that perhaps after a year in the Netherlands, where i can get my own routine and rhythm set up, i would run for a position on the Fedora EMEA board. As it turned out, the position opened up and there was only one other volunteer. We took a vote (with alot of debate), and the position fell to me. For now i'm accepting the position, and we'll see where it goes from there.

Why did i vote?

I'm seeing the start of a new meme on Fedora Planet, so i figured i'd chip in a bit of useless information.

I voted because it's the thing to do. You grow up with a certain sense of civic responsibility to contribute where asked and to make sure that your personal views are in some way being represented. The reality about politics, though, is that if you really are so emotionally invested in your views, voting is not nearly enough. You join or form a political party, run for positions of power, write letters and communicate with the others involved, and simply put, make your voice heard. I simply did not feel emotionally involved enough, because i can do my work in Fedora regardless.

Perhaps when we look at the election model for various Fedora Boards, we have to look at voting as nothing more than a thumbs up or thumbs down. We really have to think about how to get people's views better represented and how to get people more emotionally involved.

Where are the trolls now?

I've been seeing alot of nonsense and FUD about Mono, Fedora, Gnome and whatnot bloating the intertubes. In some ways it's really bizarre to consider Mono dangerous when one of the chief developers of GHC and Haskell works gladly for Microsoft.

You can see on Simon Peyton-Jones' Microsoft Research Profile page here that he gladly works for the great evil Microsoft. Despite that, the Haskell community has been relatively FUD free, and there has been very little suspicion of interference by Microsoft. Much of Simon's work in Microsoft has gone on to influence F#, which, yes, is a key part of the .Net/Mono offering.

Personally, i'm quite happy to see GHC and Haskell code in Fedora. I don't quite get what all the fuss is about.

Speaking German After a Hiatus

I have to say, after spending a month speaking Dutch nearly all the time, my German is in a bit of a sorry state. I just got off the phone to reserve a shuttle to the hotel for tomorrow, and i can't say i was too proud of my German skills as much as i was last year at LinuxTag. I'm sure it'll come back in a couple of days, but now you can't say you haven't been warned ;).

See you all tomorrow.

Haskell Bindings to C from Start to Finish

Out of curiosity i wanted to learn how to put together bindings from C to Haskell. The primary need for this on my radar is enabling X composition directly in Haskell, to enable 3D effects in XMonad. Haskell is a great language for doing graphics work, so there is definitely good sense in providing bindings for such things.

However, working with X can be a bit of a large project as the build systems and workflows for bindings are already relatively complex. I decided to familiarize myself with C2HS, which seems like the future of Haskell bindings, based on the brief bit of research i did. Another important set of bindings we may need in the future are good bindings to the RPM library. Problem here is that there is no good documentation on testing bindings with C2HS from start to finish. What follows is roughly a guide to the results i got, minus the swearing, crashing out in a nervous caffinated wreck for a few hours in between, and the tasty "Hollandse Nieuw" herring i had when i woke up.

(This year's herring is really tasty, if you get the chance to visit Holland, try one or two of them.)

The following is just bare metal work, in order to test the basic functionality of your bindings. There will hopefully be posts following this one on how to use autotools and cabal in order to build packages. (As soon as i figure it out myself.)

C2HS's workflow can be summed up as this. Write code in the C2HS format which is passed through C2HS as a preprocessor, which yields Haskell code. You run this code through ghc with extra command line flags to link the right libraries, and it yields a nice Haskell Library that you can link to later. Then just import your code in your program like normal, and you're good to go.

As a sane demo, i am starting with the sample code from the RPM documentation. This can be found here under Listing 16-1

First off, make your project directory. For me this is /rpm/. Since i want the library to be RedHat.Rpm.RpmLib i also need a directory /rpm/RedHat/Rpm/. (I'm debating if i want to keep the RedHat prefix.) Then create a file /rpm/RedHat/Rpm/RpmLib.chs, and immediately begin it with:

{-# LANGUAGE ForeignFunctionInterface #-}
{-# LANGUAGE TypeSynonymInstances #-}

#include <rpmlib.h>

{# context lib="rpmlib" #}

module RedHat.Rpm.RpmLib (
rpmReadConfigFiles
) where

import C2HS
import Foreign.Ptr

rpmReadConfigFiles is the only function we need so far from RPM. The first two lines enable extensions to GHC. The first is for doing Foreign functions, the second will be used later. Then include a standard CPP include statement. Finally we declare the module and the tokens it exports and import two modules we need from Haskell. Some of these details can be put off into the build system later, but since we are working with the tools directly, we can just put them in our code.

The function we want to bind is defined in /usr/include/rpm/rpmlib.h as such:

/** \ingroup rpmrc
* Read macro configuration file(s) for a target.
* @param file colon separated files to read (NULL uses default)
* @param target target platform (NULL uses default)
* @return 0 on success, -1 on error
*/
int rpmReadConfigFiles(const char * file,
const char * target);

This presents a bit of a unique problem. Normally a C style string presents two possibilities we need to account for. Either it contains characters or it's an empty string. Haskell can handle this equally as well with the String type. However, here we have a third possibility, the two in parameters can be null pointers, which is not exactly the same as an empty string. Internally we can handle all three cases in Haskell as a Ptr CChar which lines up exactly to the C function. However, at the outer levels, we really need to create a function that can accept either a null pointer or a String. In order to handle this, we need a new class of RString, such that:

class RString t where
withRString :: t -> (Ptr CChar -> IO a) -> IO a

instance RString String where
withRString s m = withCString s m

instance RString CString where
withRString cs m = m cs

One of the gotchas of programming C level code in Haskell is that all C level code, namely pointers, need to run inside the IO Monad. There simply isn't a (safe) way to convert something like a String to a Ptr CChar outside of IO. C2HS makes use of a withT function pattern to marshall pure Haskell data to pointers to objects in C.

In our case, if we get a String, whether containing data or empty, we need to marshal it into a CString. If we get a Ptr though, we can assume it's already been marshalled. Chances are, there are cases that can break this, but for our simple example, there's relatively little harm we can do. In any case, withCString first marshals the String into a CString and then does pretty much what the Ptr version of our code does.

With all this squared away, we can define our function pretty much as per the documentation for C2HS.

{#fun unsafe rpmReadConfigFiles
`(RString s)' =>
{withRString* `s' ,
withRString* `s' } -> `Int'#}

This creates a new function that cannot call back into Haskell code, accepts anything of RString class, and marshals it with our code. This returns an IO Int. This is it for our binding.

The fun part is compiling it. The first step is to run c2hs on the .chs file. We need to include parameters to the C Preprocessor that tells c2hs where to find the C header files. We also use -l to copy C2HS.hs into the same directory, as it is needed by ghc later. The next step is to run GHC on the resulting .hs file.

/rpm/RedHat/Rpm/ $ c2hs --cppopts='-I/usr/include/rpm/' -l RpmLib.chs
ghc --make RpmLib.hs

Now that this is done, the next step is to build an executable that uses this binding in order to test it. This file, rpm1.hs goes in /rpm/

module Main
where

import RedHat.Rpm.RpmLib
import Foreign
import Foreign.C.String

nullP :: CString
nullP = nullPtr

main :: IO ()
main = do status <- rpmReadConfigFiles nullP nullP
putStrLn (show status)

Since we defined our class only for Ptr CChar (aka CString) and not for the general Ptr a, we use a helper to type cast nullPtr. There's probably a more idiomatic way to do this, but all we need is a kludge. The rest pulls the integer result from the function and prints it on the screen. To compile this, we use the following ghc magic. It includes another call to link in the rpm library.

/rpm/ $ ghc -lrpm --make -debug rpm1.hs
/rpm/ $ ./rpm1
0


That is from start to finish how to write your own C bindings in Haskell. Hopefully i'll figure out how to get this to work via cabal, so i don't need to run so many commands to run tests.

Fedora 11 Release Party Wau Report

I've been a bit remiss in reporting on our release party in a timely fashion, but better late than never.

Our plan was to have an outdoor hackfest following the tradition set by eth0:wau last summer. The rules are simple, grill meat, drink beer, and sit around with the computers outside as long as possible. Last year, it yielded this:


Perhaps we did better this year. I'll let you decide.

We started at a typically undutch time, an hour late. We had the fire up and going at around 6, but it wasn't till nearly seven when we started preparing food in the kitchen. People started showing up around then and kept coming as the night ran on until around 11. Our release party ran along side the birthday parties for two of Alex's housemates. Without that, it might have just been us nerds sitting around in the cold night weather hacking around. As it turns out, some of the guests are also a bit technically oriented, so a couple USB keys laters, we may have a couple switch overs to Linux.

Seeing it was a birthday party, and we had a bunch of extra I <3 Fedora shirts, gave the two guests of honour a very nice Fedora birthday present. Here's Piu, the cat, trying to get in on the action again.


The night ran on and it was the usual share nerdery, installing Fedora on a few machines and swapping files around via a sneakernet. Never underestimate the bandwidth of a truck full of DVDs. In the end i made it to around 3.30, where Alex said i was acting especially loupy, right before i fell asleep. A couple of people made it through all night long, though in the end pretty much everyone got a few hours of sleep at one point or another. As we all woke up at different times, we didn't get around to having a proper breakfast until close to 17:00 the next afternoon. As Alex keeps chickens in his backyard, we were treated to some very fresh eggs.


In the end we had the tents up until around 20:00, ate dinner, packed up and went home. All in all, i think we did it justice.

For more pictures see these links.
Fedora 11 Wageningen on Facebook
Fedora 11 Wageningen on Spacedout

I should be a better tester

Kanarip is right, i should test rawhide more frequently. I've come across some SELinux denials on the livecd using the installer, which don't affect things too badly but can really scare the newbies. Well, in particular, the newbies that use Dvorak all the time.

(Don't worry, i've already reported the bug.)

For this go around i've done things a bit different. Normally i tend to fetch the DVD installer, hand pick all the packages in need a head of time, download them and install. This time, i've decided to go the route we should recommend to the pedestrians. I used the KDE Live CD and so far it's been pretty smooth. KDE 4.2 is pretty fast, KDE 4.3 is even faster. Getting Firefox installed literally took a matter of seconds. I don't know how you can't recommend this to even the most basic users around. The entire system is just plain snappy.

Coming up: Fedora 11 Release Party in Wageningen

More Snarkyness

I've previously commented on how to redefine marketing to your advantage.

Today, i would like to introduce you to a bit more snarkyness at the expense of a direct competitor. We're familiar with the standard IRC conversation:

<luser> ping
<user> pong

In IRC channels, we also see this form (that conveniently lines up):

<luser> user: ping
<user> luser: pong

I propose we change the aspirated voiceless bilabial stop to an unaspirated voiced bilabial stop. To foreigners whose native languages do not include the aspirated distinction between voiced and voiceless variants, this change will be even less noticeable. This will discourage people from referring to a certain biased marketing play by a certain company.

<luser> bing
<user> bong

That is all for today.