====== Setup a CentOS schroot on Debian ======
Inspired by the setup of Debian chroot for sbuild:
* http://wiki.debian.org/sbuild?rev=19
* http://wiki.debian.org/mk-sbuild
$ apt-get install schroot sbuild btrfs-tools
We will use the btrfs flavor of schroot.
Since btrfs is still experimental, I choose to create loopback device formated with btrfs and mounted as follows:
$ cat > /etc/fstab
/home/schroot-btrfs /srv/chroot btrfs defaults 0 0
EOF
/home/schroot-btrfs is a 20G file (to created if, please help yourself)
Create the centos6 schroot configuration file:
$ cat < 'EOF' > /etc/schroot/chroot.d/centos6-amd64
[centos6-amd64]
type=btrfs-snapshot
description=CentOS 6/amd64 autobuilder
groups=root,sbuild
root-groups=root,sbuild
profile=sbuildrpm
btrfs-source-subvolume=/srv/chroot/centos6-amd64
btrfs-snapshot-directory=/srv/chroot/snapshots
EOF
Setup the filesystem subvolume and snapshots
$ btrfs subvolume create /srv/chroot/centos6-amd64
$ mkdir -p /srv/chroot/snapshots
Bootstrap the centos system:
$ cat EOF >> /etc/rinse/rinse.conf
[centos-6]
mirror = http://ftp.ciril.fr/pub/linux/centos/6/os/i386/Packages/
mirror.amd64 = http://ftp.ciril.fr/pub/linux/centos/6/os/x86_64/Packages/
EOF
$ rinse --distribution centos-6 --arch amd64 --directory /srv/chroot/centos6-amd64/
We copy the /dev from a Debian schroot (rinse's one one is buggy)
$ cp -a /srv/chroot/sid-amd64-sbuild/dev /srv/chroot/centos6-amd64/
Finally, we do some customizations to make the centos system schroot friendly
$ echo centos6-amd64 > /srv/chroot/centos6-amd64/etc/debian_chroot
$ cat << 'EOF' > /srv/chroot/centos6-amd64/etc/profile.d/debian_chroot.sh
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
EOF
Test
$ sudo adduser sbuild
(logout and login again)
Enter the snapshoted chroot:
$ schroot -c chroot:centos6-amd64 ...
Enter the source chroot (to upgrade the base system for instance)
$ sudo schroot -c source:centos6-amd64 ..
You can then use sbuildrpm or any other test in the CentOS schroot environement...