--- /dev/null
+#! /bin/sh -e
+###
+### Wrapper around `sbuild' builds
+###
+### (c) 2018 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the distorted.org.uk chroot maintenance tools.
+###
+### distorted-chroot is free software: you can redistribute it and/or
+### modify it under the terms of the GNU General Public License as
+### published by the Free Software Foundation; either version 2 of the
+### License, or (at your option) any later version.
+###
+### distorted-chroot is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+### General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with distorted-chroot. If not, write to the Free Software
+### Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+### USA.
+
+## Set up compiler caching. This makes a big difference to build times.
+PATH=/usr/lib/ccache:$PATH; export PATH
+CCACHE_DIR=/build/.ccache; export CCACHE_DIR
+unset CCACHE_HARDLINK
+CCACHE_COMPRESS=t; export CCACHE_COMPRESS
+CCACHE_UMASK=002; export CCACHE_UMASK
+
+## Hack the build options. `sbuild' tries to turn off testing for
+## cross-builds, which is exactly wrong. Turn them back on unless I really
+## want them off.
+old=$DEB_BUILD_OPTIONS new= force_nocheck=nil
+for o in $old; do
+ case $o in x-mdw-nocheck) force_nocheck=t ;; esac
+done
+for o in $old; do
+ include=t
+ case $o in
+ x-mdw-nocheck) include=nil ;;
+ nocheck) include=$force_nocheck ;;
+ esac
+ case $include in
+ t) new=${new:+$new }$o ;;
+ esac
+done
+DEB_BUILD_OPTIONS=$new; export DEB_BUILD_OPTIONS
+
+## Preset the library search path to find the tools version of `fakeroot'.
+for i in /usr/lib/*/libfakeroot; do
+ LD_LIBRARY_PATH=${LD_LIBRARY_PATH+$LD_LIBRARY_PATH:}$i
+done
+export LD_LIBRARY_PATH
+
+## We're ready to go.
+exec "$@"