#!/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.
+
+usage()
+{
+ cat <<EOF
+Usage: id-pbuild-all.sh [OPTIONS]
+Options:
+ [--debian=distros]
+ [--ubuntu=distros]
+ [--update=true|false]
+ [--upload]
+ [--concurrency=N]
+EOF
+ exit $1
+}
+
+# things that might be set by options
+upload=false
update=true
-PKG="$1"
+do_help=false
+concurrency=4
+
+if test -f IDMETA; then
+ . ./IDMETA
+fi
+while test $# -gt 0; do
+ case "$1" in
+ -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) optarg= ;;
+ esac
+
+ case $1 in
+ --ubuntu=*)
+ UBUNTU_DIST=$optarg
+ ;;
+ --debian=*)
+ DEBIAN_DIST=$optarg
+ ;;
+ --update=*)
+ update=$optarg
+ ;;
+ --concurrency=*)
+ concurrency=$optarg
+ ;;
+ --upload)
+ upload=true
+ ;;
+ -*)
+ do_help=yes
+ ;;
+ esac
+ shift
+done
+
+if test "$do_help" = "yes"; then
+ usage 1 1>&2
+fi
+
+if test -d deb-src; then
+ cd deb-src
+fi
+for f in *.dsc; do
+ if test -f "$f"; then
+ PKG=$f
+ fi
+done
if test -z "$PKG"; then
- echo "Specify .dsc file"
- exit 1
+ echo "Specify .dsc file"
+ exit 1
fi
if test ! -e "$PKG"; then
- echo "${PKG} does not exist"
- exit 1
+ echo "${PKG} does not exist"
+ exit 1
fi
+PBUILDER=/usr/sbin/pbuilder
PRODUCT=`echo *.dsc|sed 's/_.*//g'`
-DEBIAN_DIST="etch lenny"
-UBUNTU_DIST="jaunty intrepid hardy"
-
-for dist in ${UBUNTU_DIST} ${DEBIAN_DIST}; do
- for arch in i386 amd64; do
- if test ! -f /var/cache/pbuilder/${dist}-${arch}-base.tgz; then
- DIST=$dist ARCH=$arch pbuilder create
- fi
- if $update; then
- DIST=$dist ARCH=$arch pbuilder update --override-config
- fi
- DIST=$dist ARCH=$arch pbuilder --build $PKG
- if test -f ${dist}-${arch}/*.dsc; then
- :
- else
- echo "No .dsc file for ${dist}-${arch}"
- exit 1
- fi
- done
-done
-
-if false; then
-for dist in ${UBUNTU_DIST}; do
+ARCHS="i386 amd64"
+echo "Dsc $PKG . Product $PRODUCT"
+echo "Ubuntu distros: $UBUNTU_DIST"
+echo "Debian distros: $DEBIAN_DIST"
+if $upload; then
+ for dist in ${UBUNTU_DIST}; do
scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/ubuntu/${dist}
-done
-for dist in ${DEBIAN_DIST}; do
+ done
+ for dist in ${DEBIAN_DIST}; do
scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
-done
+ done
+ echo "Remember to update APT on ftp.indexdata.dk"
+ echo "cd git-tools/update-archive"
+ echo "sudo su"
+ echo "./update-archive.sh"
+ exit 0
fi
+i=0
+date
+for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
+ for arch in ${ARCHS}; do
+ rm -fr ${dist}-${arch}
+ (
+ if test ! -f /var/cache/pbuilder/${dist}-${arch}-base.tgz; then
+ sudo DIST=$dist ARCH=$arch $PBUILDER create
+ fi
+ if $update; then
+ sudo DIST=$dist ARCH=$arch $PBUILDER update --override-config
+ fi
+ sudo DIST=$dist ARCH=$arch $PBUILDER --build $PKG
+ ) >${dist}-${arch}.log 2>&1 &
+ i=`expr $i + 1`
+ if test $i -eq $concurrency; then
+ i=0
+ wait
+ fi
+ done
+done
+wait
+for dist in ${DEBIAN_DIST} ${UBUNTU_DIST}; do
+ for arch in ${ARCHS}; do
+ if test -f ${dist}-${arch}/*.dsc; then
+ :
+ else
+ echo "No .dsc file for ${dist}-${arch}"
+ exit 1
+ fi
+ done
+done
+date
+echo "Done"
+# Local Variables:
+# mode:shell-script
+# sh-indentation: 2
+# sh-basic-offset: 4
+# End: