Update an iso with jigdo

From time to time Debian has a new point release, which is an update to their stable version.
The current stable release is 5.0 with codename Lenny and recently Debian was updated from 5.0.4 to 5.0.5.
I have both the i386 as the amd64 image of DVD 1 of that release, so now I want to update both iso images from version 5.0.4 to 5.0.5. I could download both iso image via the website, but that would make me download 2 x 4.4 GB. While not a problem, there is an other way to get those image to version 5.0.5 and it uses jigdo.
Debian recommends using jigdo over direct download too, see the Downloading Debian CD images with jigdo page.
Here I'll provide instructions to update the i386 image and for amd64 they're basically the same but switch i386 with the amd64 counterpart.

Preparations

In order to update the iso image with jigdo, there are a number of things we need:

  1. jigdo program
  2. a cd/dvd/iso of the image to update
  3. jigdo 'control' file

jigdo program

The jigdo program is readily available in the Debian archives, so the following command will get it on your system:
#aptitude install jigdo-file

a cd/dvd/iso of the image to update

I have an .iso image file with the contents of the 5.0.4 image and want to make that available to jigdo, so mount the .iso file to a directory (create it if needed). And here are the commands to accomplish it:
# mkdir /media/isoimage    'create the direcory to mount to
# mount -o loop debian-504-i386-DVD-1.iso /media/isoimage/   'mount the image to that mount point
# exit   'exit as root, the rest will be done as a normal user

jigdo 'control' file

A .jigdo file has all the information needed to construct the CD/DVD and is accomplished by a template file. But you don't need to download either the .jigdo file or the .template file up front, since jigdo can do that for you. But you will need the url to the .jigdo file and I usually put it in my copy buffer, so that I can paste that url easily.
For i386 that means I need the http://cdimage.debian.org/debian-cd/5.0.5/i386/jigdo-dvd/debian-505-i386-DVD-1.jigdo file.

Now that we have all the preparations in place, it's time to put them together.

Put it all together

Start jigdo with the url to the .jigdo file
$ jigdo-lite http://cdimage.debian.org/debian-cd/5.0.5/i386/jigdo-dvd/debian-505-i386-DVD-1.jigdo
It will now download the .jigdo file and then it reports what it has found, namely
'Debian GNU/Linux 5.0.5 "Lenny" - Official i386 DVD Binary-1 20100626-17:50 (20100626)' (debian-505-i386-DVD-1.iso)
It then provides instructions on how to proceed:
If you already have a previous version of the CD you are downloading, jigdo can re-use files on the old CD that are also
present in the new image, and you do not need to download them again.

And that is exactly the case in our situation, we already have some/most of the files already and mounted it under /media/isoimage (step 2 of the preparation).
Jigdo presents a list of default mount points (like /media/cdrom) and if you've used jigdo in the past, other locations as well. If the desired location is in that list, you can select that by choosing it's number. Otherwise just type it's location.

Jigdo then proceeds with downloading the .template file and after that it'll scans the provided files (under /media/isoimage) with the list of needed files (from the .template) to make a list of files which are already present and therefor don't need to be downloaded again.
It then makes a (temporary) iso file containing the files already present and placeholders for the other files, which do need to be downloaded.
After it has done that, jigdo will provide you an option to specify another location of files you already have. Since it's not the case in our situation, we just press <Enter> to go to the next step, specifying the Debian mirror to download the other files from.
Since I live in the Netherlands, I specified http://mirrors.nl.kernel.org/debian/ as my mirror and then it started to download the 583 files needed to have this image complete.

Depending on the number and size of the files to download and the speed of the mirror and/or your connection, this can take a while, so feel free to do other things while jigdo does it's magic.
When all the files have been downloaded it will check the newly constructed iso files against the checksums (MD5 I believe) to verify if all the bits have been downloaded successfully and if not it'll provide you an option to fix that.

Sharing the goodness

I like the bittorrent protocol in order to download/share good software and a Debian CD/DVD definitely qualifies as such ;-)
So after I have my new .iso file, I copy/link it to the location where I have my torrent files.
Then I open the http://cdimage.debian.org/debian-cd/5.0.5/i386/bt-dvd/debian-505-i386-DVD-1.iso.torrent with my bittorrent program and it sees it already has the file, checks it and starts seeding it afterwards.