Package: mkschroot
A simple script for makingschrootenvironments from a JSON
configuration file. The idea is to let you set up multipleschrootimages simply and quickly and to be able to check in the configuration
that makes this repeatable across many machines easily.This first version isn’t so smart. It assumes that you’re using a 64 bit
host machine, and doesn’t check that you’re on Debian as it should (it
only usesdebootstrapto build the chroot environment). It’s
probably also highly Ubuntu specific right now. To add to the fun it’s
not been very thoroughly tested yet either.To use it you must install a couple of things:apt-get install debootstrap schroot
pip install mkschrootUsing mkschrootYou just need to passmkschroota configuration file:mkschroot ~/chroots/example.jsonDon’t run with root privileges. If root access is required thensudorights will be requested.If theschrootconfiguration has been changed then a new
configuration file will be generated. If the image doesn’t exist it will
be created and have the packages installed on it, if it does exist it
will be updated to the latest package list and package versions.You really want to have a localapt-cacherif you’re going to be
making a lot of images.Configuring mkschrootThe configuration file needs to be JSON. A configuration file might look
like the below:{
    "root": "/mnt/files2/chroot",
    "source": "http://th.archive.ubuntu.com/ubuntu/",
    "http-proxy": "http://angelo:3142/",
    "base-packages": ["lsb-release", "openssh-client"],
    "defaults": {
        "sources": {
            "universe": {}
        },
        "conf": {
            "root-users": ["kirit"],
            "users": ["kirit"]
        }
    },
    "schroot": {
        "build-lucid64": {
            "release": "lucid",
            "packages": [
                "g++", "libbz2-dev", "libssl-dev", "python-dev", "uuid-dev",
                "libboost-dev", "subversion", "git-core"
            ]
        },
        "root-ca-kirit": {
            "release": "precise",
            "packages": ["openssl"],
            "conf": {
                "personality": "linux32"
            }
        }
    }
}The base options are:base-packages: Packages that are to be installed in all chroots.defaults: Default values for individual chroot configurations.http-proxy: A HTTP proxy (probably an apt-cache) that should be
used bydebootstrapto fetch packages.root: The directory where you want the chroots to be created in
by default (override this using thedirectorysetting within a
chroot).schroot: The schroot environments to be created.source: Where the packages can be installed from. This is
required.A chroot configuration is described by a structure like the following:{
    "release": "lucid",
    "variant": "buildd",
    "packages": ["g++"],
    "sources": {
        "universe": {}
    },
    "conf": {
        "root-users": ["kirit'"],
        "users": ["kirit"]
    }
}release: The operating system version you wish to make use of.variant: If specified then the variant is passed todebootstrapso that the right base image options are used. The
variant name is also used in theschrootconfiguration file so
that the right start up options are used when the chroot is started.
Note that someschrootoptions (notably fstab for buildd) won’t
work until they’re configured to match your system.conf: The fields used for the schroot configuration file (in/etc/schroot/chroot.d/). All fields are optional. The fieldsroot-usersanduserswill have values created from the
currently logged in user. The other fields that can be here are:description,type,personality,directory. Do read
the part about common fields though (below).sources: Extra sources that are to be added to the chroot. See
sources below.packages: Packages that need to be installed into the chroot
usingapt-get. These are combined with the base-packages.Note that if you change the variant of an existing image no attempt is
made to correct the packages that are installed.Common configuration itemsGenerally many of the chroots that you want will share a good deal of
configuration between machines. To help with this a defaultschrootconfiguration can be given which will then have values overridden by the
specificschroots that you request be made.This means that the values in thedefaultskey will be used, then
any values in the specificschrootskey will be added in, and
finally a few defaults will be generated bymkschroot.description: The release name together with personality name.directory: Therootglobal option will have the schroot name
added to it.type: Alwaysdirectory.personality: The same as the host personality (currently hard
coded to 64 bits)‘root-users’: A list of user names. Defaults to the currently logged
in user.‘users’: A list of user names. Defaults to the currently logged in
user./etc/apt/apt.confIf the host environment has an/etc/apt/apt.conffile then it is
assumed that this should also be in the schroot environments. If the
file contents differ then the host file is copied into the schroot andapt-getupdateis run within the chroot.SourcesIf other sources are needed then they can be specified at either the
defaults level or for an individual schroot. The name is used as the
component name, and this will generate a file in/etc/apt/sources.list.d/with the component pointing at the source.
If a source field is given than that is used, otherwise the global
source is used.For example:sources: {
    "universe": {},
    "private-example": {"source": "http://example.com/"}
}Will generate two files,universe.list:deb http://th.archive.ubuntu.com/ubuntu/ universeAnd private-example.list`:deb http://example.com/ private-exampleNote that the value for a source component must be a JSON object, even
if empty.