Search .pbuilderrc in calling users $HOME.
authorAdam Dickmeiss <adam@indexdata.dk>
Fri, 2 Sep 2011 13:04:26 +0000 (15:04 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Fri, 2 Sep 2011 13:04:26 +0000 (15:04 +0200)
id-deb-build/id-pbuild-root.sh
id-deb-build/id-pbuild.sh

index 3eeb85e..1707786 100755 (executable)
@@ -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
index 501eb6c..10b6578 100755 (executable)
@@ -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