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!