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>
Merge pull request #440 from euanh/parallel-make

Parallel make