Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 1 down vote accepted

So, the working solution uses pbuilder and sudo.

  • After installing both, one has to edit the /etc/sudoers file (using visudo) and allow users in the group pbuilder to run pbuilder without a password.

    %pbuilder ALL=(ALL) NOPASSWD: /usr/sbin/pbuilder
  • Add the pbuilder group and your build user name builduser to it

    root@debian# groupadd pbuilder
    root@debian# gpasswd -a builduser pbuilder

You will now be able to bootstrap a Debian chroot and build packages using pbuilder as non-root.

Here is an example script that

  • fetches the source package given as the first parameter (as builduser, using the answer to that question)

  • build packages from sources, for both i386 and amd64 architectures

  • upload them with dput to an external repositories given by the second parameter of the script


set -e
set -x

THIS=`readlink -f ${0}`
THIS_DIR=`dirname ${THIS}`


ARCHS='i386 amd64'

pushd ${THIS_DIR}/src
apt-get update -c ${APT_CONF}
apt-get source ${PACKAGE} -c ${APT_CONF}

for ARCH in ${ARCHS}
  sudo pbuilder --create --configfile ${BUILD_DIR}/pbuilderrc \ 
                --buildresult ${BUILD_DIR}/
  sudo pbuilder --build --configfile ${BUILD_DIR}/pbuilderrc \
                --buildresult ${BUILD_DIR}/ ${THIS_DIR}/src/${PACKAGE}*.dsc
  dput ${TARGET_CODENAME} ${BUILD_DIR}/*.changes
share|improve this answer

Try to use 'fakeroot' program. Usage of this program - just use instead sudo.

Fakeroot exists in the debian repo, try to sudo apt-get install fakeroot

share|improve this answer
usage of fakeroot is quite cool, however the build product still is owned by root after compilation and I can't change de packages as a normal user. – Erwan Queffélec Nov 15 '12 at 5:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.