Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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

#/bin/bash

set -e
set -x

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

PACKAGE=${1}
TARGET_CODENAME=${2}

ARCHS='i386 amd64'
APT_CONF=${THIS_DIR}/tmp/etc/apt.conf

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

for ARCH in ${ARCHS}
do
  BUILD_DIR=${THIS_DIR}/build/${ARCH}
  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
done
share|improve this answer
add comment

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
add comment

Your Answer

 
discard

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.