Debian: Move repository metadata generation into Makefile

Debian package-building documents suggest that the chroot (pbuilder
or cowbuilder) should contain a startup script which regenerates the
package repository metadata.   In our case, the D05deps script runs
apt-ftparchive on the source and binary package directories.

This approach has the advantage that the repository metadata is guaranteed
to be up to date before the build starts.   In contrast, when building
RPMs we have to remember to call createrepo after building each package.
However the disadvantage is that regenerating the package metadata is
a side effect of building the package.   This will make it more difficult
to add a cache around Debian package building.

For this reason, we will move the metadata regeneration step out of the
chroot startup sequence and into the Makefile, mirroring the way we
build RPMs.

Signed-off-by: Euan Harris <euan.harris@citrix.com>
Makefile: Enable concurrent RPM builds

Two problems prevent us from building RPMs concurrently:

 * By default, mock can only run one instance of a given
   chroot environment at a time.   This is easily fixed
   by using the --uniqueext option to name instances
   uniquely.

 * Createrepo needs to update the repository database
   files in SRPMS and RPMS after each package is built.
   It's not clear whether it's safe to run two instances
   of createrepo against the same database concurrently.
   To prevent this, we wrap the call to createrepo with
   flock.

Copying build products back to the RPMS and SRPMS directories
concurrently should be safe because each job builds a different
package with a different filename.  An exception to this is
the build log file, which is common to all jobs.   We should
switch to separate logging for each package.

Signed-off-by: Euan Harris <euan.harris@citrix.com>
pbuilder: Enable concurrent Deb builds

Unlike mock, multiple instances of pbuilder or cowbuilder seem to be able
to coexist peacefully.   The main point of contention in a concurrent
Debian build comes when updating the repository metadata file, which
also occurs in the RPM build.  The solution for Debian is slightly more
complicated because of the way the Debian repository metadata tools work.

apt-ftparchive writes the new metadata to standard output, which is then
redirected to the appropriate file.   This causes problems for concurrent
builds because the script takes time to print the new metadata, but the
executing shell truncates the old metadata file immediately.  This means
there is a short period of time during which the metadata file is empty,
and if a concurrently-running build tries to run apt during that period
it will fail.

To avoid this problem, we add a wrapper script which writes the new
metadata file to a temporary file, then moves that into the correct place.
The wrapper script is run under flock, which prevents concurrent update
runs from interfering with each other.

Signed-off-by: Euan Harris <euan.harris@citrix.com>