CLI Magic: Aptify your CDs

52

Author: Sven Hoexter

I’ve been using APT-RPM for several years now. From time to time, I find that I need to install packages that are not included with the distribution I’m running. Normally, this is not a problem if you have a fast Internet access, but sometimes you may be in a situation where you have no Internet access at all. Here’s how to cope with that situation by creating a CD for use by APT-RPM.Actually, there are couple of ways to proceed, as noted on the APT-RPM homepage. One solution is download the necessary packages on a system with good Internet access, then create a CD which contains them, then copy the packages from the CD onto the hard drive of the target system. There, you could generate a local index with the genbasedir command. But what I want are CDs that work with the apt-cdrom program. Apt-cdrom adds the package lists from a base directory on the CD to your local system and adds a line identifying the CD to your sources list.

Preparing a CD

Here is what you can do to give a friend with slow Internet access a CD with the add-on packages for SUSE Linux 9.1 available on ftp.gwdg.de.

The first step is to create a directory called SUSE-add-on under a directory called susecd using the command mkdir -p ~/susecd/SUSE-add-on.

Next, download all the sections you need (in my case RPMS.packman, RPMS.packman-i686, and RPMS.suser-rbos) with wget:


cd ~/susecd/SuSE-add-on
wget -r --retr-symlinks ftp://ftp.gwdg.de/pub/linux/suse/apt/SuSE/9.1-i386/RPMS.packman
wget -r --retr-symlinks ftp://ftp.gwdg.de/pub/linux/suse/apt/SuSE/9.1-i386/RPMS.packman-i686
wget -r --retr-symlinks ftp://ftp.gwdg.de/pub/linux/suse/apt/SuSE/9.1-i386/RPMS.suser-rbos

This gives you the following structure:
~/susecd
            
               
SuSE-add-on
               
              
       
               
              
         RPMS.packman
               
              
         RPMS.packman-i686
               
              
         RPMS.suser-rbos

The next step is to generate the package lists in the base directory for the CD. Note: you need to have APT-RPM installed on your system to have the genbasedir program.


genbasedir --flat --bloat --progress ~/susecd/SuSE-add-on/

If everything goes right, you should have a susecd/SuSE-add-on/base subdirectory with the following files:


pkglist.packman
pkglist.packman-i686
pkglist.suser-rbos
pkglist.packman.bz2
pkglist.packman-i686.bz2
pkglist.suser-rbos.bz2
release
release.packman
release.suser-rbos
release.packman-i686

There’s one more thing you have to do before you create the CD image with mkisofs. You need to add another subdirectory called .disk under susecd, which will contain a file named info for apt-cdrom to read. The info file should contain a description for the CD, which will appear in the sources.list later. To do that, enter these commands:


mkdir susecd/.disk
echo "SuSE Linux 9.1 Unofficial Add-on CD i386 20040722" > ~/susecd/.disk/info

Now you’re ready to master the ISO file with mkisofs and burn it with
cdrecord:

mkisofs -J -l -r -o /tmp/suseaddon.iso ~/susecd

Back at our destination

You can now carry your new “apt-powered” CD to your destination system and add it by entering the command apt-cdrom add. Apt-cdrom will respond:


Using CD-ROM mount point /mnt/cdrom/
Unmounting CD-ROM
Please insert a Disc in the drive and press enter

Do as requested, and apt-cdrom continues:


Mounting CD-ROM
Identifying.. [1aea5c5cda13d3c588453e284d23061d-2]
Scanning Disc for index files.. Found 3 package indexes and 0 source indexes,
This Disc is called:
 'SuSE Linux 9.1 Unofficial Add-on CD i386 20040722'
Reading Indexes... Done
Writing new source list
Source List entries for this Disc are:
rpm cdrom:[SuSE Linux 9.1 Unofficial Add-on CD i386 20040722]/ SuSE-add-on packman packman-i686 suser-rbos

If you take a look at your /etc/apt/sources.list you’ll find the entry for your CD. Now you have all the RPMs from the CD available for installation by the APT-RPM tools. You can remove this collection by simply deleting the line from your sources.list. To re-add the CD at a later time, just repeat the apt-cdrom add commands above.

Have fun.