How do I add more variants or custom packages to debootstrap?

I have a set of packages that I wish to install along-side the minibase variant in debootstrap. I'm having the hardest time figuring out how to customize variants so that more than just the base is installed in a chroot when debootstrap is run. Any way to achieve this?


Solution 1:

It's pretty easy to add your own variant with additional custom packages to debootstrap.

The debootstrap configuration/runtime scripts are located in /usr/share/debootstrap/scripts. Let's create an allmybase variant which includes everything in minbase along with the packages htop and traceroute.

  1. Open /usr/share/debootstrap/scripts/precise in your editor.

    • Note that this, along with many Ubuntu releases, is a symbolic link to /usr/share/debootstrap/scripts/gutsy; if you want to affect only a specific release, break the link and make it a copy of the gutsy script instead.
  2. Around line 22, find the line beginning with variants and add your custom variant at the end:

    variants - buildd fakechroot minbase allmybase
    
  3. Find the work_out_debs() function around line 34, and look at the default settings for the base variable for your "base" variant (here, minbase):

        elif doing_variant fakechroot || doing_variant minbase; then
                base="apt"
    
  4. Append your own variant with custom packages at the end of the function:

        elif doing_variant allmybase; then
                base="apt htop traceroute"
    
  5. Save, exit, and test it out with the --print-debs "simulation" flag, e.g.

    sudo debootstrap --print-debs --variant=allmybase precise /tmp/prec-chroot
    
    • In this example, the output will show that the htop and traceroute packages will be included in the allmybase chroot.