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?
1 Answer
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
.
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.
- Note that this, along with many Ubuntu releases, is a symbolic link to
Around line 22, find the line beginning with
variants
and add your custom variant at the end:variants - buildd fakechroot minbase allmybase
Find the
work_out_debs()
function around line 34, and look at the default settings for thebase
variable for your "base" variant (here,minbase
):elif doing_variant fakechroot || doing_variant minbase; then base="apt"
Append your own variant with custom packages at the end of the function:
elif doing_variant allmybase; then base="apt htop traceroute"
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
andtraceroute
packages will be included in the allmybase chroot.
- In this example, the output will show that the
-
Wow, I guess this seems almost as dirty as just installing a variant and mounting the chroot + apt-get. Thanks for the information! Jul 26, 2012 at 2:20
-
Well, a little pain once will gain you a lot if you install the same variant repeatedly ;)– ishJul 26, 2012 at 2:45
-
Maybe that option did not exist at the time of the question, but the same effect can be achieved with
debootstrap --include=htop,traceroute
without any modifications to debootstrap scripts.– raimueNov 6, 2019 at 15:56