apt-checkpoint 0.1 released

I’m happy to announce that apt-checkpoint 0.1 has been released..

I’m excited about this, partially because this is the first “open source” project that I’ve gotten to a releasable state but also because it’s just a damn handy utility. I pimped the project in #debian-devel (on irc.freenode.net) today. A few people said things like “that’d be useful for me” and “this is a good idea, i’ll try it out in a chroot later. actually it will be really useful for chroots when you want to revert changes.”, while another sputtered “packages are not required to support downgrading at all” and “while [ 1] ; do dpkg –get-selections | awk ‘{print $1}’ | grep -v apt | xargs dpkg –purge; done.” and “Use a file system with snapshots.”

Of course, there are various ways of manually downgrading packages. The problem with his suggestion is that, while technically feasible, is not a clean solution. I shouldn’t have to pipe commands back and forth to accomplish what should be a seamless, automated task. Linux isn’t just the playground the technologically elite. Linux needs to be user-friendly, while still allowing us technophiles to get our hands dirty. apt-checkpoint, while rough and cludgy, is just an example of the kind of usability people need. They should be able to upgrade and, if something breaks, seamlessly rollback, akin to restore points in Windows (which are used for the exact same reason).

A few people have already started to play with apt-checkpoint. Hopefully I’ll get some good feedback from them, and a stable 0.2 release will be ready in the near future.

apt-checkpoint progress

I’ve been making some decent progress on apt-checkpoint over the last few days. I’m using the python module apt_pkg to interface with the packages. I want to keep this package as lightweight as possible, and I think it’s a fair assumption to make that Python will be available “out of the box” on most Debian systems. Plus, Python is a nice language. I still favor C#, but Mono isn’t quite as widely used yet and for a tool like this, I think Python is a better fit.

My first goal was to get apt-checkpoint working, and it is now functional enough for me to do more testing. With the checkpoint generated, I was able to start working on apt-diff. I ran apt-checkpoint, apt-get install apache, and then apt-diff, which I’ve showed below:

stone@durin:~/src/apt-checkpoint$ ./apt-diff.py
Reading Package Lists… Done
Building Dependency Tree… Done
Package not found in checkpoint but installed: apache

So far, so good. I am able to detect a new package has been installed since the last checkpoint. I need to test version checking and work out the logic for apt-diff, but I’m pleased with the progress so far. At this rate, I should be ready to release something in a few weeks.

apt-checkpoint (The anti-whiprush)

I finally got tired of OSX so I installed Debian on my iBook. After getting it up and running, I decided to try getting GNOME 2.6 installed from the experimental repository. Boy, was that a big mistake. One of the reasons it is still in experimental is that it’s not being built for all platforms yet. Unfortunately, there seem to be some critical packages still missing for the PowerPC (ppc). After an unfortunate dist-upgrade, I was left with a horribly broken GNOME install and no easy way of getting back. I whiprushed myself.

<StoneTable> `whiprushed
<rewt> To be whiprushed is to bring hell upon yourself by apt-get dist-upgrading without knowing wth you’re doing, and then being pulled over with expired tags and <cut to jail scene> ending up in a jail cell for the night with a heroin addict for a roommate. All because you messed up that Debian system.

The problem:
No way to revert the system back to a point-in-time when the system was working (ala restore points in Windows).

I started thinking about the process I went through to restore my system to the point it had been before I destroyed GNOME. Removing all of the GNOME 2.6 packages I had installed, including their dependancies in experimental. Being left with a broken apt-get and having to remove it, download the .deb from unstable and manually installing it. Becoming intimately familiar with querying out package data with dpkg, and finally reinstalling all of GNOME 2.4 and all of the subsequent packages that got removed in the process.

What a pain in the ass.

The solution:
It hit me as I was driving to work: apt-checkpoint. What we need is a method to create a ‘checkpoint’ that says this is a known good working system at this point in time and records the installed packages, versions, configurations, as well as the original packages (optionally, if available). Then an apt-diff tool could be used to compare the current system with this checkpoint of the working system to pin-point differences, and an apt-rollback tool that could actually restore the known good system configuration to an otherwise whiprushed system.

Maybe it’s just me, but I like to live bleeding edge. I run Debian unstable on all of my desktops and occasionally something gets screwed up, either by my own ineptitude or that of a package maintainer. Shit happens. If I had these tools, though, reversing the change that broke my system would be a relatively simple task (or at least the identification of the broken package/dependancy would be easier to find).

With the solution in hand, I’ve started work on apt-checkpoint, apt-diff, and apt-rollback, an anti-whiprush toolkit to save me (and you) from destroying your system by an ill-advised dist-upgrade. Hopefully I can get a simple, working solution in relatively short order. After all, simple solutions are often the best kind.

Converting OSX Icons to png

I found some Matrix icons that I wanted to use on my Linux desktop. Unfortunately, the only available formats are for OSX or Windows (.ico). I prefer to use png, so I set out to convert the OSX-flavored icons to png.

You will need to download and install a few programs in order for this to work.

First, you need to get a copy of StuffIt for Linux. For those of you morally opposed to using close-source software, shame on you for even considering using Macintosh icons on your Linux desktop. Begone, you.

Next, download yourself a copy of icns2png [Local mirror].

Finally, grab these two scripts: clean and convert. Don’t forget to mark them executable.

Extracting the .bin/.hqx
I downloaded mtrx_icn.bin and saved it to ~/icons. Unstuff this .bin file to seperate the data in to two files.

stone@durin:~/icons$ unstuff mtxr_icn.bin
The Matrix Rebooted Icons.sit.info
The Matrix Rebooted Icons.sit.data
/home/stone/icons/The Matrix Rebooted Icons.sit.info ..
/home/stone/icons/The Matrix Rebooted Icons.sit.data ...........................................................................................................
stone@durin:~/icons$

Next, we need to extract the actual icons themselves. Without setting the parameters to tell unstuff how to treat the file, it will extract 0-byte Icons.

stone@durin:~/icons$ unstuff -e=unix -m=auto -t=on The\ Matrix\ Rebooted\ Icons.sit.data
...
(lots of files being extracted)
...
stone@durin:~/icons$

Fixing the filename
When unstuff extracts the Icon files, it leaves behind a carriage return (\r) embedded within the filename. Whoops.


stone@durin:~/icons$ ls -b The\ Matrix\ Rebooted\ Icons
Icon\r Read\ Me\ Please The\ Icons

I tried various ways of using find, xargs, and perl to do this but failed. So what we have here is clean. Simply, it will remove any control codes, including carriage returns and line feeds, from a filename. I spent way too much time trying to find a solution to this, so I hope it comes in handy for someone else.


#!/bin/sh

if [ ! -n "$1" ]; then
echo "Usage: clean.sh "
exit 0
fi

set -o noglob
find "$1" -name 'Icon*' -print | while read name ; do
newname="`echo $name | tr -d [:cntrl:]`"
mv "$name" "$newname" # do the move
done

~/icons$ ./clean The\ Matrix\ Rebooted\ Icons
stone@durin:~/icons$

Converting to png

Now that the filenames are fixed, we can get to our ultimate goal, converting the icons to png. For this, I hacked up another script, similar to clean.sh, and called it convert.


if [ ! -n "$1" ]; then
echo "Usage: convert.sh "
exit 0
fi

set -o noglob
find "$1" -type f -name 'Icon' -print | while read name ; do
icns2png "$name" # Convert to png
rm "$name" # remove old Icon
done

This one is simple enough that you can probably accomplish the same thing with find, -exec and xargs.

Matrix\ Rebooted\ Icons
Icon2PNG Linux Edition - (C) 2002 Mathew Eis
Converting The Matrix Rebooted Icons/Icon to The Matrix Rebooted Icons/Icon.png...
(repeat the above two lines for each Icon)
stone@durin:~/icons$

And you’re done. All of the OSX Icons have now been converted to png. Happy theming!

(Almost) A week with Fedora

So, last week I decided that it was time to reinstall Linux on my laptop. Being the glutton for punishment that I am, I followed the advice of #linux and installed Fedora instead of Debian.

I have to say that, despite my misgiving, I was impressed with Fedora. Right out of the box, everything worked. Wireless, XFree86, cups, you name it. And it looked damn good. Nice, crisp anti-aliased fonts.

I played with it for several days, I was able to use Red-Carpet to install Mono and all the dependancies in order to get MonoDevelop to run. Heck, I even had Mono CVS building smoothly.

Despite some frustrations with yum/red-carpet/up2date not being what I’m used to with apt-get, I was content.

And then my hard drive died.

Do you realize how hard it is to find a decent replacement laptop hard drive on a Sunday? It’s bloody difficult, I’ll tell you right now. You would think that, living as close to Chicago as I do, that there would be one store selling higher-end hardware. I had my eye on a top-of-the-line 7200rpm hitachi drive, but the only regional store that I could find that sold it, CDW, is closed on sundays.

Instead, I opted for a 5400rpm Hitachi drive with an 8Mb cache. So far, it feels considerably faster than the standard 4200rpm drive that came with the laptop.

Facing a complete reinstall, I decided that, although Fedora is nice as an easy-to-get-running desktop, it isn’t right for me. I like the power that I feel when I run `apt-get -t experimental upgrade`.

Now I’m back to Debian, running Kernel 2.6.4 and GNOME 2.6 and quite happy. Long live Debian.