-#!/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]
- [--upload]
- [--concurrency=N]
-EOF
- exit $1
-}
-
-# things that might be set by options
-upload=false
-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
- ;;
- --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
-fi
-if test ! -e "$PKG"; then
- echo "${PKG} does not exist"
- exit 1
-fi
-PBUILDER=/usr/sbin/pbuilder
-PRODUCT=`echo *.dsc|sed 's/_.*//g'`
-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
- scp ${dist}-*/* ftp.indexdata.dk:/home/ftp/pub/${PRODUCT}/debian/${dist}
- 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
- 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}-${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: