Version 28 (modified by allison, 5 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 Karmic, and directions are provided for building chroots for Debian Sid and Ubuntu Lucid.

(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 install it:
     $ sudo dpkg --install debootstrap_1.0.20_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 dialog
     # aptitude install locales # for locales
     # dpkg-reconfigure locales # select your preferred locale
     # aptitude install build-essential dh-make pbuilder lintian \
     wget debconf devscripts sudo patch perl file debootstrap
    
    
  • (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. (Copying the whole files for /etc/passwd, /etc/shadow, /etc/group, /etc/gshadow works between similar distributions. It doesn't work when hosting a Debian chroot on a Ubuntu box, so copy only your username and user group directly.)
 $ 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 Lucid

  • Manually install it:
     $ sudo dpkg --install debootstrap_1.0.20_all.deb
    
  • Edit /etc/schroot/schroot.conf and add the following lines:
     [lucid]
     description=Ubuntu lucid
     location=/var/chroot/lucid
     priority=3
     users=<your user>
     groups=sbuild
     root-groups=root
    
  • Set up a chroot environment using debootstrap:
     $ sudo debootstrap --variant=buildd lucid /var/chroot/lucid http://archive.ubuntu.com/ubuntu/
    

To create a 32bit chroot on a 64bit install, add the option "--arch i386":

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

To create an lpia (Ubuntu Mobile) chroot, add the option "--arch lpia", and change the archive URL to 'ports.ubuntu.com':

 $ sudo debootstrap --arch lpia --variant=buildd intrepid /var/chroot/intrepid-lpia http://ports.ubuntu.com/
  • Run a diff comparing some configuration files from the base install to the chroot environment, you may want to copy some lines from them, or copy them over entirely (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
    
  • Manually mount system directories:
     $ sudo mount -t proc proc-chroot /var/chroot/lucid/proc
     $ sudo mount -t devpts devpts-chroot /var/chroot/lucid/dev/pts
    

Or, if you prefer to have them always mounted (I don't), add the following entries to your main /etc/fstab:

proc-chroot /var/chroot/lucid/proc proc defaults 0 0
devpts-chroot /var/chroot/lucid/dev/pts devpts defaults 0 0 
  • Start up the chroot environment:
     $ sudo chroot /var/chroot/lucid
    
  • Get the latest versions of the package list and some core packages:
     # apt-get update
     # apt-get install language-pack-en # for locales
     # apt-get install dialog # must have 'universe' enabled in /etc/apt/sources.list
     # apt-get install dh-make automake pbuilder lintian \
     wget devscripts sudo dput
     # apt-get update
     # apt-get install vim
    
  • (optional) Setup text for the command-line prompt, to display when running in chroot:
     # echo lucid > /etc/debian_chroot
    
  • Leave the chroot environment:
     # exit
    
  • (optional) Set up users, groups, and sudo access in chroot. Compare /etc/passwd, /etc/shadow, /etc/group, /etc/gshadow, and /etc/sudoers from the base machine to the equivalent /var/chroot/lucid/etc/* in the chroot. Copy your user and group to the chroot files. Also copy the 'admin' group for sudoers and add 'admin' access in the chroot sudoers file. Copy the hosts file from the base machine into the chroot.
     $ sudo cp /etc/hosts /var/chroot/lucid/etc/
    
  • (optional) Setup the home directory for your user:
     $ sudo chroot /var/chroot/lucid/
     # 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/lucid/home/<your user>/.
     $ cp -r ~/.gnupg /var/chroot/lucid/home/<your user>/.
    
    
  • (optional) Set up the Ubuntu PPA upload configuration in your user's account. Add a file named .dput.cf in your home directory with the following lines:
    [parrot-ppa]
    fqdn = ppa.launchpad.net
    method = ftp
    incoming = ~parrot-dev/ubuntu/
    login = anonymous
    allow_unsigned_uploads = 0
    
  • Done