From 8e02411beadd0f2f2cbf5a9f90b05dd6dd5693db Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 2 Sep 2011 15:04:26 +0200 Subject: [PATCH 1/1] Search .pbuilderrc in calling users $HOME. --- id-deb-build/id-pbuild-root.sh | 17 ++++++++++++++++- id-deb-build/id-pbuild.sh | 17 +++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/id-deb-build/id-pbuild-root.sh b/id-deb-build/id-pbuild-root.sh index 3eeb85e..1707786 100755 --- a/id-deb-build/id-pbuild-root.sh +++ b/id-deb-build/id-pbuild-root.sh @@ -8,6 +8,10 @@ Options: [--dsc=dscfile] [--dist=distribution] [--arch=architecture] + [--home=home] + +This script is should be called with root privilege. It is meant to be +called by id-pbuild.sh. EOF exit $1 } @@ -28,8 +32,11 @@ while test $# -gt 0; do --dsc=*) dsc=$optarg ;; + --home=*) + HOME=$optarg + ;; -*) - do_help=yes + usage 1 ;; esac shift @@ -37,8 +44,16 @@ done PBUILDER=/usr/sbin/pbuilder +if test -z "$dist" -o -z "$arch"; then + echo "dist and arch must be given" + usage 1 +fi rm -fr ${dist}-${arch} +if test ! -f $HOME/.pbuilderrc; then + echo "$HOME/.pbuilderrc missing" + exit 1 +fi if test "$dsc"; then if test ! -f /var/cache/pbuilder/${dist}-${arch}-base.tgz; then DIST=$dist ARCH=$arch $PBUILDER --create diff --git a/id-deb-build/id-pbuild.sh b/id-deb-build/id-pbuild.sh index 501eb6c..10b6578 100755 --- a/id-deb-build/id-pbuild.sh +++ b/id-deb-build/id-pbuild.sh @@ -105,6 +105,19 @@ fi echo "Dsc $PKG . Product $PRODUCT" echo "Ubuntu distros: $UBUNTU_DIST" echo "Debian distros: $DEBIAN_DIST" +if test "${SUDO_USER}"; then + echo "Running as sudo." + echo "You can avoid it by adding the following in /etc/sudoers" + echo "${SUDO_USER} ALL=NOPASSWD: /home/${SUDO_USER}/proj/git-tools/id-deb-build/id-pbuild-root.sh" + HOME_EXPORT=/home/${SUDO_USER} +else + HOME_EXPORT=$HOME +fi +if test ! -f ${HOME_EXPORT}/.pbuilderrc; then + echo "${HOME_EXPORT}/.pbuilderrc missing" + exit 1 +fi + if $upload; then for dist in ${UBUNTU_DIST}; do scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist} @@ -128,7 +141,7 @@ rm -f *.log # call our privileged wrapper to clean the directories, no --dsc option for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do for arch in ${USE_ARCHS}; do - sudo -n $PBUILDROOT --dist=$dist --arch=$arch + sudo -n $PBUILDROOT --home=${HOME_EXPORT} --dist=$dist --arch=$arch done done @@ -137,7 +150,7 @@ i=0 date for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do for arch in ${USE_ARCHS}; do - sudo -n $PBUILDROOT \ + sudo -n $PBUILDROOT --home=${HOME_EXPORT} \ --dist=$dist --arch=$arch --dsc=$PKG >${dist}-${arch}.log 2>&1 & i=`expr $i + 1` if test $i -eq $concurrency; then -- 1.7.10.4