ig-pbuild.sh more clear on warnings and tips
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 25 Oct 2011 11:49:30 +0000 (13:49 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 25 Oct 2011 11:49:53 +0000 (13:49 +0200)
If running as regular user check exit code of first sudo -n invocation.

id-deb-build/id-pbuild.sh

index b1d586a..c04e2d7 100755 (executable)
@@ -81,8 +81,11 @@ else
        fi
     else
        if test -d deb-src; then
-           echo "Remove deb-src"
-           exit 1
+           rm -rf deb-src
+           if test $? -ne 0; then
+               echo "deb-src could not be removed. Remove deb-src manually"
+               exit 1
+           fi
        fi
        $MKDEBSRC
     fi
@@ -116,10 +119,11 @@ 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 "Tip: You can avoid it by adding the following in /etc/sudoers"
     echo "${SUDO_USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
     HOME_EXPORT=/home/${SUDO_USER}
 else
+    sudo -k
     HOME_EXPORT=$HOME
 fi
 if test ! -f ${HOME_EXPORT}/.pbuilderrc; then
@@ -151,6 +155,12 @@ rm -f *.log
 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
     for arch in ${USE_ARCHS}; do
        sudo -n $PBUILDROOT --home=${HOME_EXPORT} --dist=$dist --arch=$arch
+       if test $? -ne 0; then
+           echo "FAILED"
+           echo "Run id-pbuild.sh using sudo or add yourself to /etc/sudoers:"
+           echo "${USER} ALL=NOPASSWD: ${ID_DEB_BUILD}/id-pbuild-root.sh"
+           exit 1
+       fi
     done
 done
 
@@ -168,7 +178,7 @@ for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
            if test -f ${dist}-${arch}/*.dsc; then
                :
            else
-               echo "No .dsc file for ${dist}-${arch}"
+               echo "FAILED: No .dsc file for ${dist}-${arch}"
                exit 1
            fi
        fi
@@ -180,7 +190,7 @@ for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
        if test -f ${dist}-${arch}/*.dsc; then
            :
        else
-           echo "No .dsc file for ${dist}-${arch}"
+           echo "FAILED: No .dsc file for ${dist}-${arch}"
            exit 1
        fi
     done