Goal

Create a script to automate creation of a Debian (stable/unstable) template for OpenVZ.

Existing tools

There is  vzpkg2 which does most of what I wanted to accomplish - but it needs root access.

Snippets

Create a tar ball of the packages for a base system of Debian unstable.

/usr/sbin/debootstrap --make-tarball unstable-pkgs.tgz sid foobar http://ftp.de.debian.org/debian

Run debootstrap for template creation (currently just wraps debootstrap):

./make-openvz-template -x "options"

where the quotes contain options to pass to debootstrap (incl. suite, target, etc.).

If you created a tar ball before, a matching command is

./make-openvz-template -x "--unpack-tarball $(pwd)/unstable-pkgs.tgz sid sid-root http://ftp.de.debian.org/debian"

Source is in source:openvz-template/trunk.