Remove 2 variables not used and which are wrong
Make the 'Invalid port origin' error a little more clear
Rever logic so that is does not get catched up by set -e
Exclude /proc and /compat/linux/proc from mtree, this reduces (eliminates?)
leftovers false positives after mtree encounters an error.
In my tests, before patch: 7 false positives on 3200 ports tested
after patch: 0 false positives on 3200 ports tested
Make check_leftovers work with new mtree (from NetBSD)
Go back to returning 0 which is more clear and avoids future issues

This was accidentally removed in [3c1d20df13]
Ignore error on last freebsd-update install, when you do minor release
upgrades this step is not needed.
pkg_cache_data(): No need to mkdir -p, pkg_cache_dir() already does
Use a shadow directory with hard links during build

This keeps the repository untouched until the very end. It is not quite
atomic yet, but is better than having the repository broken for several
hours or days while a build is running, or has failed.

The repository is only 'committed' if the build does not crash. Failing
packages still will not be in the new repository yet. Keeping old packages
may come later.
Implement fully atomic package repository updating.

This builds on the previous commit which runs the build in a shadow
directory of hardlinks.

The new format entails moving all top-level package files and dirs,
such as repo.txz, All/ and Latest, to a .real_TS directory.

There is a .latest symlink that just points to the .real_TS directory.

Then all top-level files/dirs point to .latest/FILE

This allows the completion of package building to just update the .latest
symlink to point to the new repository location atomically.

On first run, the repository will be updated to the new format.
Add ATOMIC_PACKAGE_REPOSITORY option to allow disabling
bulk: Add -n for dry-run mode.

No packages will actually be deleted or built. Show what would
be done. Requires ATOMIC_PACKAGE_REPOSITORY to be enabled
bulk -c: Move cleaning so that it supports -n
Add KEEP_OLD_PACKAGES which will keep KEEP_OLD_PACKAGES_COUNT number of old repositories.

This can be useful for rollbacks or bisecting. Requires
ATOMIC_PACKAGE_REPOSITORY

Default: no

Suggested by:	will
Ticket:		[a69b25cefd]
When committing packages, symlink new top-level dirs
When committing packages, delete broken top-level links
ln(1) is not atomic, but mv(1)->rename(2) is
Fix creating initial package repository
Atomic repo: If the build fails, keep the packages for the next build

Ticket:	[5ca5cc78fc]
Set defaults for global vars once in common.sh