The French version was originally written for linuxembedded.fr : Crée un CD d’installation d’une debian spécialisée.
The goal is to build a debian install CD suitable for the distribution of a complete system including the operating system and applications.
Debian already has a tool for that purpose: simple-cdd. Simple-cdd is a set of scripts wrapping debian-cd which is the tool used to build official CDs.
In our case, we will include some “non-free” packages (firmwares for instance) and application specific packages in the system.
Using simple-cdd
Simple-cdd gets some of its configuration from your host computer, so it’s recommended to work on a machine similar to your target (in particular the machine should use the same architecture: i386 or amd64).
All the following actions should be done in a working directory that will contain the downloads and configurations for our system.
We will start by creting a configuration file “my-cdd.conf” stating the mirror and components to use:
debian_mirror="http://ftp2.fr.debian.org/debian/" mirror_components="main contrib non-free"
Then we will launch the build-simple-cdd tool once. This will build a local mirror of the needed packages that we will reused later. So be patient this can be a bit long.
build-simple-cdd --conf ./my-cdd.conf
Once done, you should get a CD iso in the “images” subfolder.
Customizing the image
To customize our image we will create a profile “my-profile” that will define which package to install and which extra package to include on the CD (dev packages for instance).
Create a “profiles” folder:
mkdir profiles
Selecting the packages
If you’ve got an already installed machine (the one you used to test your application) you can ask dpkg to list the installed packages from that machine and use that as a basis.
dpkg --get-selections >package-list
In this file only the names of packages in the “install” state are needed:
grep -e '\<install$' package-list | awk '{print $1};' >profiles/my-profile.downloads
The file “my-profile.downloads” is a list of packages to include on the CD-ROM. The list of program to install is “my-profile.packages”. The tool will resolve dependencies, so we don’t need to track down all dependencies add add them to these files.
Specific packages
We want to add some custom packages that we built ourselves to the CD, those packages not present in the debian archive.
Let’s create a “local_pkg” folder and fill it with all of our packages.
We now can update the configuration to use all those files and make the profile “my-profile” the default profile.
debian_mirror="http://ftp2.fr.debian.org/debian/" mirror_components="main contrib non-free" simple_cdd_dir=$(pwd) profiles="my-profile" auto_profiles="my-profile" local_packages="$simple_cdd_dir/local_pkg/"
If you now run the tool again, you’ll get a full custom install CD!
build-simple-cdd --conf ./my-cdd.conf
However you might have missed some specific packages or their dependencies, in that case they will be missing on the CD. To find this out, check the messages for a line like:
WARNING: missing optional packages from profile my-profile: libevent-2.0-5 [...]
In that case libevent from squeeze-backports was missing. Simple-cdd is not able to download packages from backports, so I just added the packages to “local_pkg”.
Customizing the installer
Simple-cdd automatically uses a “default” profile. This profile might not suite your needs. To override it you just have to place modified file in the “profiles” folder.
To do so, first copy the desired file from “/usr/share/simple-cdd/profiles/” and update it. For instance the “default.pressed” file:
cp /usr/share/simple-cdd/profiles/default.pressed profiles
Then update the wanted options in this file. For example the partitioning options.
Also as we enabled “contrib” and “non-free” you should uncomment the following lines:
d-i apt-setup/non-free boolean true d-i apt-setup/contrib boolean true
Adding extra files to the CD
Finally we want to add the documentation, sources and other files to the CD.
Simple-cdd can add files to the “simple-cdd” folder but there is no way to add a complete directory structure.
However, as we can override the profiles, we can also override some scripts, especially “tools/build/debian-cd” that builds the CD.
mkdir -p tools/build cp /usr/share/simple-cdd/tools/build/debian-cd tools/build
Then add the following lines after the “$extras_base_dir” cleanup:
if [ -d "$cd_extras" ]; then mkdir -p "$extras_base_dir" cp -a "$cd_extras/." "$extras_base_dir" fi
Finally let’s add the “cd_extras” variable to our configuration file :
cd_extras="$simple_cdd_dir/local_extras/"
Be careful to not create files conflicting with the CD content, nothing would warn you about that!
Conclusion
We now have a way of building a debian install CD including any files we might want to deliver with our system: sources and documentation for example.
live-build is another great tool to generate Live CD that can embed also a Debian Installer.