Architecture-any packages only built once
[git-tools-moved-to-github.git] / id-deb-build / id-pbuild.sh
index cde1dc5..cab6efa 100755 (executable)
@@ -1,12 +1,7 @@
 #!/bin/sh
 # This script builds Debian packages for one or more distributions
 # in i386/amd64 architectures. It uses pbuilder. pbuilder requires root
-# privilege and is invoked with sudo.
-#
-# In order to avoid having to type-in the password for it, you might
-# use something like this in sudoers 
-#  user ALL=NOPASSWD,SETENV: /usr/sbin/pbuilder
-# where user is your username.
+# privilege and so this script should be invoked with sudo.
 
 usage()
 {
@@ -78,6 +73,11 @@ fi
 PBUILDER=/usr/sbin/pbuilder
 PRODUCT=`echo *.dsc|sed 's/_.*//g'`
 ARCHS="i386 amd64"
+if grep "Architecture: all" $PKG >/dev/null; then
+    USE_ARCHS=i386
+else
+    USE_ARCHS=$ARCHS
+fi
 echo "Dsc $PKG . Product $PRODUCT"
 echo "Ubuntu distros: $UBUNTU_DIST"
 echo "Debian distros: $DEBIAN_DIST"
@@ -96,17 +96,16 @@ if $upload; then
 fi
 i=0
 date
+
 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
-    for arch in ${ARCHS}; do
+    for arch in ${USE_ARCHS}; do
         rm -fr ${dist}-${arch}
        (
            if test ! -f /var/cache/pbuilder/${dist}-${arch}-base.tgz; then
-               sudo DIST=$dist ARCH=$arch $PBUILDER create
+               DIST=$dist ARCH=$arch $PBUILDER create
            fi
-           for f in `find /var/cache/pbuilder/${dist}-${arch}-base.tgz -ctime +7`; do
-               sudo DIST=$dist ARCH=$arch $PBUILDER update --override-config
-           done
-           sudo DIST=$dist ARCH=$arch $PBUILDER --build $PKG
+           DIST=$dist ARCH=$arch $PBUILDER update --override-config
+           DIST=$dist ARCH=$arch $PBUILDER --build $PKG
            ) >${dist}-${arch}.log 2>&1 &
        i=`expr $i + 1`
        if test $i -eq $concurrency; then
@@ -117,7 +116,7 @@ for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
 done
 wait
 for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
-    for arch in ${ARCHS}; do
+    for arch in ${USE_ARCHS}; do
        if test -f ${dist}-${arch}/*.dsc; then
            :
        else