MFH: Fix race between next_in_queue and balance_pool

  mv: rename /poudriere/data/build/91amd64-pkgng/ref/poudriere/pool/unbalanced/p5-Role-Tiny-1.003.002 to /poudriere/data/build/91amd64-pkgng/ref/poudriere/building/p5-Role-Tiny-1.003.002

Reported by:	mat
MFH: Fix race between queue_empty and balance_pool.

This may have been resulting in stuck queue crashes.

Reported by:	many
MFH: Fix usage of cpdup -X/-x.

-X only accepts 1 file containing a list of files/dirs to ignore.
Use -x with .cpignore in each subdir to properly only exclude
/usr/src and /poudriere.

Note that this does not change any behavior as it worked by
accident before. /usr/src was ignore since it was null-mounted
and /poudriere was ignored since it was listed 2nd as -X
which is ignored itself.

Reported by:	John Hein
MFH: bulk: Avoid doing a rollbackfs on first builds on a fresh mount
MFH: Fix sanity checks not properly recursively deleting packages

This was manifest as missing dependencies during package building
due to out-of-order builds caused by the queue not having
the proper dependency list because of not rebuilding some
packages when their dependencies were deleted.

This was mostly due to using || on commands which disabled the
set -e handling. By properly recording return statuses and returning
and checking on them sanity_check_pkgs again works.

(This commit on 3.0.x does not fix the issue mentioned, but does make
 the code proper.)

Reported by:	antoine, mat, bdrewery
With help from:	antoine
MFH: Reuse _wait by allowing it to take multiple pids
MFH: Fix hang sometimes in parallel_run/sanity check when reap_children
returns early.
MFH: Add kill_and_wait().

This will gracefully kill all pids passed in and wait
the specified time before force killing them with
SIGKILL.
MFH: Use kill_and_wait() 30 in parallel_shutdown.

This fixes all of the 'Killed' and 'Error getting PKGNAME'
spam when an error is encountered looking up dependencies
or origins are being parsed.
MFH: parallel_shutdown: Avoid 2nd wait() in parallel_stop()
MFH: Ignore home directory of users created by ports during leftover check.
Tested with databases/cego, databases/mariadb-client and new version of security/maia provided by feld@
Fixes ticket [9e7fbf2c6d]
MFT: Add gsub() from Shell Scripting Recipes - Chris F.A. Johnson (c) 2005
MFT: Load MOVED when starting build into tmpfs /poudriere/MOVED/cat_port file containing new origin
MFT: Fix packages returning old origins by checking MOVED.

This fixes a recent package build failure with qt4 where dependencies
were not properly determined due to partial sanity checks. By tracking
MOVED, the dependencies are again proper.
MFT: Also track MOVED origins of package dependencies for the 'new dependency' incremental rebuild
3.0.14 Release
MFH: Fix ipv6 only poudriere usage

Fixes:		[9b1232e5e4]
Reported by:	Mark.Martinec@ijs.si
MFH: Ensure /sbin and /usr/sbin are in PATH when running the script

Fixes:	[142f0e2b6a]
MFH: Remove trailing slashes from listed_ports.
This fixes get_porttesting on ports submitted by user with trailing slashes.
Reported by:	miwi
MFH: kill_and_wait: Fix logic, only sleep if pid still running