Patching up a monster of frankeinsteinian proportions

I’ve spent the first week of the year on vacation with some friends. The second week of the year has been mixed between going on with the jobs I should have gotten working already, fighting a bad case of cold, and getting insulted by a customer of mine for actually having gotten real vacation time for once in two years. More to the point: said customer doesn’t actually pay me overtime, or actually at all for the support.

Tonight I wanted to relax and think about my own needs. Not personal needs, alas, but at least needs for my work to become easier. Since I haven’t made any progress at all regarding RT I decided to look into a different need of mine: cataloguing customers’ computers.

I originally simply kept a file listing the computers I set up for customers — then I started getting more customers, and sometimes getting a computer back after many months since last time. And I started forgetting which computer was which. Nowadays I have 79 computers on my “database” (which is just a git repository with a bunch of HTML files as well as lshw dumps), without counting those that have been dismissed.

To recognise the computers, I started printing labels with a QR Code on them, which contains the URL of the computer’s HTML file on my website (password-protected). My original method required me to feed a multi-label A4 sheet into my laser printer and print one, two or three labels out on that… but it turned out to be a waste of time and of money in sheets, given that most of the time I ended up wasting half of it, as the printer refused to print aligned more than half the time. I’ve since bought a Dymo label printer, which is why you’ll find their drivers in Portage maintained by yours truly — the nice thing about Dymo’s label printers is that their drivers are fully GPL-2, while as far as I can tell both Zebra and Brother have binary blobs, that make them unsuitable for use on amd64-based systems.

As you can tell, there are a few things that I did in Gentoo that relate to this little “database” of mine: the lshw fixes to try getting it back into SysRescueCD (it’s still not there — and I lost the password for my account on their forums), the Dymo drivers noted above, and dev-ruby/barby which is a quite interesting library that allows you to generate almost any kind of barcode. And now it’s time of MongoDB Ruby libraries as I’m trying to write an actual web application to manage the “database” and make it a real database.

Today’s achievement is big: I finally got Rails (3.1) to play nice with MongoDB. Not using MongoMapper, the author of which, as I already talked about I would prefer not having much to discuss with. But thanks to Mauro I got pointed at Mongoid which is a much more well developed alternative.

Okay sure there are quite a few things to kink out in the packaging of Mongoid – for instance the fact that the gem packages a Rakefile that relies on a (missing) Gemfile, or the fact that two out of three rspec targets in said Rakefile fail, one of which by crashing the interpeter – but at least their unit-tests work, and the code works as intended when loaded it up. Which is more I can say about MongoMapper.

Oh and it doesn’t seem to require extra code to be added just to work correctly with Passenger.

The only problem I have now is fixing up one side issue: how do I print the labels once I load this into my webserver? I could download the PDF I use to print the label and then print that.. but it’s a bit of a time-waster. Of course both the server and Yamato (where the label printer is connected) are IPv6-enabled and .. well, the IPP protocol used by CUPS is fine to be used over the internet, as it can use SSL encryption. Which yes, means that I’ll be setting up a web application … that calls home to print a label, how crazy is that?

My only issue with this is that I’d rather not install cups on the webserver (especially since there is currently no way to just build the client side of it, which would be the only part of it I would need on the server — yeah I know, it’s funky), so I can’t just call lpr mylabel.pdf… and as far as I can tell, the only way to access IPP from Ruby is one of the many CUPS library bindings available as gems, which are all 0.0 versions, and do not inspire me the least. Since IPP is based off HTTP, I would have expected more implementations of it, to be honest.

Possibly, it should be possible to extend some HTTP Ruby library to send IPP requests as well; for what I’m concerned, I’d just need the “Print-Job” method to be implemented, which would allow me to send the PDF file to be printed with the default options. I guess I’ll resolve that bit once I’m done with the rest of my application, though.

AirPrint in Gentoo

I’m interrupting the series of posts about gold to post about something I was working on as part of a different job. More about gold will resume next week.

For one of my customers, I’m developing a private web application that would probably make most Free Software enthusiasts – not just the advocates – cringe. It is developed in ASP.NET, with a SQLServer backend, and is targeted at iPad users. While in general this looks like a bad combination for a Free Software developer, paid work is paid work, and even working on Windows has its upsides, namely learning about alternative approaches and the good and bad things about them, to make your software better — to be honest I’m not sure I dislike ASP.NET more than I disliked Hobo (the Rails plugin) last year.

Putting the iPad to good use is also easy: I’m reading even those O’Reilly books that were previously cumbersome to read, PDFs like CJKV Information Processing which I bought last year and never went around to read, because of not being available in ePub format.

Let me say that, as a toy, the iPad is far from bad: Apple’s hands-on approach can be criticized, but the results for a naïve, jaded user are almost near perfection. On the other hand, I don’t think I’d trade my Milestone for an iPhone any time soon, even with all its troubles — the most bothersome issue is due to my CyanogenMod installation where the “hold call” button is pressed by my cheek while talking; it seems like I’m not alone and I’m now trying the method reported there to see if it helps.

While they really seem to have an app for everything, and their not-really-multitasking approach appears to work better than what I’m used to on Android, it is rough on the edges for the meddlers: I can’t install additional certificates (I can on Android); I can’t use an email address different than the GMail login (I can on Android); it doesn’t sync contacts on Google Contacts on the fly (Android does), and so on a few more “minor” things that I just love, in my Android.

But there is also one thing that the iPad can do and my Android can’t: printing. Of course it should be easy to do, especially given that Linux’s printing system is the same CUPS used by Apple – and actually, developed, given they bought the original developers! – but that’s not really the way they decided to do it. In a very environment unfriendly way, Apple decided that you can’t just use any printer with their iPad, you need to buy a new one, as they will not provide the AirPrint interface with older models.

You can guess that people already found out how to avoid that. I had saved a long time ago a post by Eric Sandeen on the topic, which later points to a GitHub project with a script that generates a service file for Avahi, which can then be used to advertise the printer properly.

But even with this it is far from being straightforward to deal with it. First problem I found is that the script needs the cups Python extension; this is not provided by net-print/cups[python] as I first expected – I since updated the USE flags’ description in the metadata.xml file: the interpreter flags are used for cups’s own CGI scripting support, which is definitely non-obvious – but rather by the dev-python/pycups package.

The next problem is that, because of technical limitations on the size of TXT records used in mDNS discovery – if you didn’t look up post and projects I have listed above, the AirPrint protocol is actually just the usual IPP as provided by cups, wrapped through mDNS with a custom record for exposing the printer’s features – some of the printer’s options are not exposed. One of those that is ignored is duplexing, but since my only real reason to print from the iPad is printing invoices, which I always print duplex – don’t get me started on why I should be printing invoices – I wanted to expose it. Luckily the generated Avahi service file is easy to fiddle with.

Next up, actually trying to print. Unfortunately there is one thing that could be a bit difficult to guess: CUPS validates the Host header passed (IPP is based on HTTP/1.1). By default, if you don’t fiddle with its configuration, what it looks for is the same hostname as set in the system, but what gets sent by the iPad is what it has found through mDNS/Avahi, which is the base host name followed by the .local domain. In my case that meant CUPS was expecting deepspace9.home.flameeyes.eu and it got deepspace9.local. Since the CUPS configuration is heavily inspired by Apache, just adding ServerName and ServerAlias should be enough… but it’s worth noting that when accessing CUPS through a browser, especially with SSL enabled, it will send the port number as well, so you should alias both hostname and hostname:631.

The takeaway of this all? Well, sometimes proprietary software solutions are not any better than Free Software — not that there is a good way to handle that for us as well, but it still shows its fragile support even using the same server software as the protocol’s creator.

Time-friendly gadgets and souvenirs

With about four different jobs at my hands right now, my free time tends to be quite limited. Since it is free time that I employ to keep my mental sanity (a difficult task since I’m having more trouble at home than you might dream in a bad nightmare), work on Gentoo packages that I’m not paid to work on, and finally take care of housekeeping, the more free time I have the better.

Of the three main activities, the one that I’d like to cut shorter is definitely housekeeping; even more so since I’m hoping to get a real office before the summer heat becomes unbearable for me and the boxes, in which case I’d be needing to increase the slots given to housekeeping (or is it officekeeping then?). So, how do you reduce the time spent in this activity without having to pay someone else to do it (which is something that I’ll probably do for the office, at some point)?

Simple: you start by cutting down the amount of gadgetry, souvenirs, and general ornaments you have laying around, and replacing them with something more time friendly, to begin with. Especially where computers and electronics are involved, the most time-expensive task you have to deal with is, in my opinion, dusting. Ornaments waste even more of your time by both obstructing the surfaces to dust, and requiring you to dust them properly.

Unfortunately, even though this is not news to me, the task is made more difficult by two issues: the first is that I’m weak and last year, visiting fairs, I bought a “few” action figures (mostly from Monster Hunter games; the second is that my whole family doesn’t seem to like the idea of not having ornaments, and not buying ornaments as souvenirs and presents in general. To the point that I have a whole drawer in my bedroom that is full of souvenirs, most of which I was given by my sister each time she visited Italy or Europe.

While ornaments and souvenirs tend to be generally pointless and just waste of space and time, I reckon that most people, me included, like having a memento of their travels, and give one to their friends and family. At the same time, I like the idea of seeing around me items that link to things I like, such as games and comics. With all this considered, I started forming an opinion about what, as the post’s title already gives away, is a time friendly gadget. There are indeed a few, and they usually are quite good alternatives.

Clothing is probably the most important, time-friendly gadget. But not in the form of things so silly you’d never wear them. But for instance T-shirts, even silly ones, are usually just fine to receive (as long as they are the right size), especially if you are geek enough to consider them a distinction badge, like Adam Savage in Mythbusters. I have followed a similar approach when I visited London a couple of years ago; my main memento of that travel? A flat cap which looks definitely British, but which I use daily when the weather is rainy — but I guess I’m not part of the norm given I also wear a fedora during winter, and lighter hats during summer. And before somebody asks, I’ve been doing that since before watching Mythbusters; it’s a passion I got from my maternal grandfather.

Cups are also a great gadget and souvenir, even though from time to time they are hard to take home, since they are fragile. Not only I’m very happy having bought an FSFE cup (which is featured in an old article of mine iconic as it feels to me) the one time I went to FOSDEM. Mostly because, even though my mother keeps complaining we got too many of them, they never go to waste: at some point you either break some or they get too ruined to use daily… then you just take a few new ones and you’re set. Furthermore, I wouldn’t mind a few more cups nowadays since I’ll have to bring some with me in my office, reducing the availability in house. Which is why I added to Amazon’s Universal Wishlist a cup from The Oatmeal’s Bobcats (might not be entirely safe for work, depending on which side of the pond you live, I guess).

Depending on the final destination of souvenirs, food is also often good enough: tea from London, spices from Turin, and my sister got me (dark) chocolate from the mountains last time she went there on vacation. While it might not be a lasting memory, at least it would be enjoyed, and once all of it is eaten, there is nothing left taking up space and requiring time to clean. Unfortunately there are still issues, as not everybody has the same tastes, and at the same time, enough people, me included, can’t tolerate certain food.

The final nail in the coffin for the problem, at least for me, is prints: you just need some glass to gold them on, and you’re set: they take very little space on a wall, they can be cleaned pretty quickly, and even if you need to store them you don’t have to take care not to break them as much as many other trinkets.

What surprises me, though, is that in the era of digital distribution, I can only buy prints in dead-tree form: no webcomic I follow and care of seem to sell high-resolution images to be printed, probably to avoid somebody to sell rip-offs… on the other hand, I wouldn’t mind having the print even if it had my name all over it (maybe I’d actually like it better that way!). Of course you’d then have to find some way to print the high-resolution image, but luckily, one of my customers is actually a print shop so I wouldn’t have trouble there.

Space ain’t cheap

I’m not referring to hosting space (I luckily don’t need it, as I have my own site, as you remember), nor I’m referring to hard disk space (that is quite cheap nowadays, enterprise has 500GB on two disks), nor to outer space (that ain’t cheap either, but I can’t even take a plane, figures if I would go that up)… I’m referring to actual space you got at your home, or office, or whatever.

I don’t live in an apartment or in a small house, so one would suspect I had enough space here, but I’ve started needing a lot more space especially to handle stuff for my job. So I’ve had to move stuff around to make space for what I have without having to get a house all by myself.

Unfortunately, as I said, space ain’t cheap: if you want to make space up for more stuff, you need to buy new furniture, and Ikea is not always an option, so you need quite a lot of money. As I don’t really have that much money to spend on furniture, I’ve started looking for alternative solutions. One of these was to move my laser printer out of my «home office» and into the corridor, on a little table I had in my room before; the problem is that there isn’t connectivity there, just power supply, and even the network card of my printer would cost me €170, which is way too much for what I can afford myself to spend for space; so I decided to try this one: I bought an Apple Airport Express ; I can do that because I have OSX, unfortunately there is no way, as far as I know, to configure this one with Linux :( .

I don’t need the AirTunes thing, as my only speakers are in this room, and are connected to the home theatre, but for €99, it seemed a pretty decent way to connect the printer, and it is also quite small, that is one of the requirements for me at the moment, I need stuff that is small. So I ordered it Monday, and today it arrived. I read a few users around the ‘net saying that it was using a non-standard 9101 port for JetDirect protocol, or that it didn’t work with CUPS after updating the firmware, so I was ready to try it out and in case send it back to Apple if it didn’t work.

Instead, even after updating the firmware, my printer is still at port 9100, CUPS prints fine on it (although it does not do Bonjour/MDNS autodiscovery, that would be pretty nice, to me), and the connection is stable.

If Apple was to release some public interface to set it up, so that you could buy one and use it with Linux, I think I would buy a couple more of them, the hardware is good, and the services too.

CUPS and Gentoo/FreeBSD

Okay a combined status update for you today :)

So, the CUPS problem I had with the USB printer turned out being an error with the way cups was configured in Gentoo and somehow to the way CUPS tries to enforce security. To summarise, if the SystemGroup setting in the cups.conf file was set to “lp”, the backend runned as “lp:nobody” instead of “lp:lp”, so the “root:lp” device was unaccessible. Thanks to genstef, the new ebuild now creates an “lpadmin” group and use that as group for printers administration, while lp is left to be used to for accessing the device. Please note that if you configured lp in particular ways, you’d have to fix it at this point.

Now I can print safely from the Linux box; I’m also waiting for kdelibs to build to test the kdeprint patches needed to work with cups 1.2, so that finally we would be all set for upgrade, almost.

Also genstef added libpaper to the tree (Ubuntu version) so that people can set the default paper format they want to use (in my case A4).
I’ve already marked the ebuild ~x86-fbsd so that Gentoo/FreeBSD users can be safe.

Still, there are problems with using Gentoo/FreeBSD as printing server, although it works fine with a networked printer, right now the devices has no permissions set at all. This is a problem because FreeBSD to set the permissions uses a series of scripts that are run by rc, and by devd.

Using the same scripts would probably be possible, but I wouldn’t suggest that, as we have a structure quite different, so… well… I hope someone will have time to work on a gentoo-bsd-devfs scriptset :)

CUPS 1.2, problems and impressions

So, today I started looking at CUPS 1.2 to add the needed patches to KDE, as I was asked by genstef.

Unfortunately, it doesn’t work that well for me, actually it doesn’t work at all. Ignoring some problems with multilib-strict that might be better handled by following upstream on this, my USB printer doesn’t seem to work.

I’ve submitted a bug to upstream and I’m now waiting for them to find the cause and a solution.

Right now, I won’t suggest to anybody to use that version of cups, considering this problem that might hit others, too. I’ll anyway hope to get the proper KDE patches merged as soon as I can print with my printer.

But a part the problems, I got a really good impression on CUPS 1.2, the configuration file is finally human readable (no more crufted Apache-like configuration file long entire pages), the Web interface is really improved, more friendly and better looking.

One of the things I really loved of the new CUPS is the administration interface, with the list of identified USB printers and a button to add them directly.
Not bad at all, although the drivers selection might be better, rightnow it moves you directly on the brand of printer you have, but it fails to recognise my Kyocera Mita as what it is and brings me to “Kyocera” page (where my model isn’t found obviously).

I hope this will really improve the support for printing in Linux. Already the usage of CUPS by Apple in Mac OSX gave us better support for printers as many vendors started to provide PPDs for CUPS to work (this is the case of Kyocera Mita, too), now if the interface becomes also more friendly for the basic user, it’s a big leap forward.

Myself, I love not having to change anything but enabling browsing to have my laptop to print on the amd64 station, both on Linux and OSX.

++ for CUPS :)