+src=$d.tar.bz2
+
+v() {
+ echo ">" "$@"
+ "$@"
+}
+
+# Execute a command in the build environment
+remote() {
+ local h=$1
+ local cmd="$2"
+ target=${h#*:}
+ case $h in
+ ssh:* )
+ v ssh ${target} "$cmd"
+ ;;
+ chroot:* )
+ v schroot -c${target} -- bash -c "cd && $cmd"
+ ;;
+ local:* )
+ cd
+ v bash -c "cd && $cmd"
+ cd -
+ ;;
+ esac
+}
+
+# Put files into the build environment
+put() {
+ local src="$1"
+ local h=$2
+ local dst="$3"
+ target=${h#*:}
+ case $h in
+ ssh:* )
+ v scp $src ${target}:$dst
+ ;;
+ chroot:* )
+ v cp $src ${chroots}/${target}/home/${LOGNAME}/$dst
+ ;;
+ local:* )
+ v cp $src $HOME/$dst
+ ;;
+ esac
+}
+
+# Retrieve files form the build environment
+get() {
+ local h=$1
+ local src="$2"
+ local dst="$3"
+ target=${h#*:}
+ case $h in
+ ssh:* )
+ v scp ${target}:$src $dst
+ ;;
+ chroot:* )
+ v cp ${chroots}/${target}/home/${LOGNAME}/$src $dst
+ ;;
+ local:* )
+ v cp $HOME/$src $dst
+ ;;
+ esac
+}
+
+# Build a .deb in some build environment, and copy it to the distribution
+# location
+build() {
+ local h=$1 # build host
+ local f=$2 # distribution directory ("for")
+ local vs=$3 # version suffix
+ local dist=$4 # distribution (stable/oldstable)
+
+ remote $h "mkdir -p _builds"
+ remote $h "rm -rf _builds/*.deb _builds/$d"
+ put $src $h _builds/$src
+ remote $h "cd _builds && tar xfj $src"
+ if [ "$vs" != "" ]; then
+ remote $h "cd _builds/$d && scripts/setversion $v~$vs 'Backport to $vs' $dist"
+ fi
+ remote $h "cd _builds/$d && fakeroot debian/rules binary"
+ mkdir -p $web/$f
+ get $h _builds/\*.deb $web/$f/.
+}
+
+# Build various debs
+build local:araminta wheezy "" sid
+build chroot:wheezy32 wheezy "" sid
+
+# Update the web
+cp $src README README.developers CHANGES.html $web