Version 3 (modified by allison, 6 years ago)

--

This file outlines the steps needed to set up a chroot environment for building Debian/Ubuntu packages for Parrot (so you don't need a full install of the particular distribution to build packages for it, and so you can run Parrot's tests on multiple different distributions easily). The host system used to produce this guide was Ubuntu Edgy, and directions are provided for building chroots for Debian Etch and Ubuntu Gutsy.

(Watch out for special characters in the configuration files and command-line examples. Best to view the wiki page in Advanced Edit mode.)

Initial Setup for All

  • Install the schroot package.

$ sudo aptitude install schroot

  • Create a directory for the chroot instances

$ sudo mkdir /var/chroot

Debian Sid

(I tend to use the mirror ftp.osuosl.org instead of ftp.debian.org, pick your favorite.)

  • Manually download the debootstrap package

(or the latest at < http://ftp.debian.org/debian/pool/main/d/debootstrap/>)

$ wget  http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_1.0.7_all.deb

  • Manually install it:

$ sudo dpkg --install debootstrap_1.0.7_all.deb

  • Edit /etc/schroot/schroot.conf and add the following lines:

[sid] description=Debian sid location=/var/chroot/sid priority=3 users=<your user> groups=sbuild root-groups=root

  • Set up a chroot environment using debootstrap:

$ sudo debootstrap sid /var/chroot/sid  http://ftp.debian.org/debian/

(to run a 32bit chroot on a 64bit install, add the option "--arch i386")

  • Copy over some configuration files from the base install to the chroot environment:

$ sudo cp /etc/resolv.conf /var/chroot/sid/etc/resolv.conf

  • (optional) Add the following lines to /var/chroot/sid/etc/apt/sources.list to expand the list of available packages:

deb  http://ftp.debian.org/debian sid contrib

  • Start up the chroot environment:

$ sudo chroot /var/chroot/sid

  • Get the latest versions of the package list and some core packages:

# aptitude update # aptitude install build-essential dh-make pbuilder lintian \ wget debconf devscripts sudo patch perl file debootstrap # aptitude update # aptitude install locales dialog # (optional) for locales # dpkg-reconfigure locales # select your preferred locale

  • (optional) Setup text for the command-line prompt, to display when running in chroot:

# echo sid > /etc/debian_chroot

  • Leave the chroot environment:

# exit

  • Set up users, groups, gpg, and sudo access in chroot:

$ sudo cp /etc/passwd /var/chroot/sid/etc/ $ sudo sed 's/\([:]*\):[:]*:/\1:*:/' /etc/shadow \ | sudo tee /var/chroot/sid/etc/shadow $ sudo cp /etc/group /var/chroot/sid/etc/ $ sudo cp /etc/gshadow /var/chroot/sid/etc/ $ sudo cp /etc/hosts /var/chroot/sid/etc/ $ sudo cp /etc/sudoers /var/chroot/sid/etc/

$ sudo chroot /var/chroot/sid/
# dpkg-reconfigure passwd
# passwd <your user>
# mkdir /home/<your user>
# chown <your user> /home/<your user>
# chgrp <your user> /home/<your user>
# exit

$ cp ~/.bashrc /var/chroot/sid/home/<your user>/.
$ cp -r ~/.gnupg /var/chroot/sid/home/<your user>/.

  • Set up the environment for debuild, add the following lines to

/var/chroot/sid/home/<your user>/.devscripts:

DEBUILD_DPKG_BUILDPACKAGE_OPTS="-i -I" DEBUILD_PRESERVE_ENVVARS=DH_ALWAYS_EXCLUDE

And in wherever you set environment variables for shell sessions:

export DH_ALWAYS_EXCLUDE='.svn'

  • Done

Ubuntu Intrepid

  • Manually download the debootstrap package for Intrepid

(or the latest at < http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/>)

$ wget  http://archive.ubuntu.com/ubuntu/pool/main/d/debootstrap/debootstrap_1.0.10ubuntu1~intrepid1_all.deb

  • Manually install it:

$ sudo dpkg --install debootstrap_1.0.10ubuntu1~intrepid1_all.deb

  • Edit /etc/schroot/schroot.conf and add the following lines:

[intrepid] description=Ubuntu intrepid location=/var/chroot/intrepid priority=3 users=<your user> groups=sbuild root-groups=root

  • Set up a chroot environment using debootstrap:

$ sudo debootstrap --variant=buildd intrepid /var/chroot/intrepid  http://archive.ubuntu.com/ubuntu/

(to run a 32bit chroot on a 64bit install, add the option "--arch i386")

  • (Probably skip this step for intrepid) Copy over some configuration files from the base install to the chroot environment (substituting if your install is a different release):

$ sudo cp /etc/resolv.conf /var/chroot/intrepid/etc/resolv.conf $ sudo cp /etc/apt/sources.list /var/chroot/intrepid/etc/apt/ $ sudo sed -i s/<your install>/intrepid/g /var/chroot/intrepid/etc/apt/sources.list

  • Start up the chroot environment:

$ sudo chroot /var/chroot/intrepid

  • Get the latest versions of the package list and some core packages:

# apt-get update # apt-get install dh-make automake pbuilder lintian \ wget devscripts sudo # apt-get update # apt-get install language-pack-en # for locales # apt-get install vim

  • (optional) Setup text for the command-line prompt, to display when running in chroot:

# echo intrepid > /etc/debian_chroot

  • Leave the chroot environment:

# exit

  • (optional) Set up users, groups, and sudo access in chroot:

$ sudo cp /etc/passwd /var/chroot/intrepid/etc/ $ sudo sed 's/\([:]*\):[:]*:/\1:*:/' /etc/shadow \ | sudo tee /var/chroot/intrepid/etc/shadow $ sudo cp /etc/group /var/chroot/intrepid/etc/ $ sudo cp /etc/hosts /var/chroot/intrepid/etc/ $ sudo cp /etc/sudoers /var/chroot/intrepid/etc/

$ sudo chroot /var/chroot/intrepid/ # dpkg-reconfigure passwd # passwd <your user> # mkdir /home/<your user> # chown <your user> /home/<your user> # chgrp <your user> /home/<your user> # exit

  • Done