Bootstrap a debian build environment and build source packages with no root privileges

Posted by Erwan Queffélec on Server Fault See other posts from Server Fault or by Erwan Queffélec
Published on 2012-11-10T23:46:33Z Indexed on 2012/11/11 5:04 UTC
Read the original article Hit count: 442

On debian squeeze, I am trying to do the following :

  • fetch sources package from the wheezy source repository
  • bootstrap a squeeze chroot for several architectures
  • build the packages for several architectures (i386, amd64 + all and any)

I want both the fetching, bootstrapping and build operation to be scriptable, repeatable, and run as a normal user. For the environment setup, I want to make as little use of the root account as possible (install the necessary dependencies, and maybe some visudo stuff). If possible I would like to avoid using a VM (pbuilder with user mode linux)

So far I have tried several things with pbuilder (require root), debootstrap (require root) with little success.

Here is an example script of what I want to do (does not work):

#/bin/bash

set -e
set -x

this=`readlink -f $0`
this_dir=`dirname $this`

archs='i386 amd64 any all'
pushd $this_dir/src
# I actually want the following line to work with a repo that 
# is not in /etc/apt/sources.list but that is another question
apt-get source cyrus-imapd-2.4
popd

for arch in $archs
do
  build_dir=$this_dir/build/$arch/
  pbuilder --create --configfile $build_dir/pbuilderrc --buildresult $build_dir/
  pbuilder --build --configfile $build_dir/pbuilderrc --buildresult \ 
    $build_dir/ $this_dir/src/*.dsc

  # of course I want to use the .dput.cf in /home/myuser/ 
  # and not in /root/

  dput $build_dir/$arch/*.changes
done

© Server Fault or respective owner

Related posts about debian

Related posts about bash