Add emerge --with-test-deps option for bug #520652

For packages matched by arguments, this option will pull in dependencies
that are conditional on the "test" USE flag, even if FEATURES=test is not
enabled for the matched packages. The state of the "test" USE flag is not
affected by this option. It only changes the effective dependencies
which are processed by the depgraph._add_pkg_deps method.

X-Gentoo-Bug: 520652
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=520652
Acked-by: Alexander Berntsen <bernalex@gentoo.org>
emerge: check for writable PKGDIR (490732)

If there are packages to be merged and "buildpkg" or "buildsyspkg" is
enabled, then bail out early if PKGDIR is not writable (in order to
avoid a fatal EROFS error which would otherwise occur later on).
Behavior remains unchanged for --pretend, --fetchonly and
--fetch-all-uri. For --ask, it will bail out just after the last
relevant --ask prompt.

X-Gentoo-Bug: 490732
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=490732
Acked-by: Alexander Berntsen <bernalex@gentoo.org>
_slot_operator_update_probe: memoize use_reduce (529660)

Memoize the results of use_reduce calls inside
_slot_operator_update_probe, in order to improve performance. With
memoization, 'emerge -puvDN @world' on one of my computers takes
22.4% less time, and results in 13.5% fewer use_reduce calls.

X-Gentoo-Bug: 529660
X-Gentoo-Url: https://bugs.gentoo.org/show_bug.cgi?id=529660
Acked-by: Brian Dolbec <dolsen@gentoo.org>
_select_pkg_highest_available: selective cache invalidation (530010)

Implement selective invalidation of cache for the
depgraph._select_pkg_highest_available method, so that the entire cache
is not discarded whenever a package is added to the graph. On one of my
computers with this patch, 'emerge -puvDN @world' takes 15% less time,
and results in 58% fewer _select_pkg_highest_available_imp calls.

X-Gentoo-Bug: 530010
X-Gentoo-Url: https://bugs.gentoo.org/show_bug.cgi?id=530010
Acked-by: Alexander Berntsen <bernalex@gentoo.org>
Force the SELinux user during relabel operation (530192)

When Portage relabels the files of the package, it currently calls
setfiles (which is correct) but does not use the -F option (force). As a
result, the files only get assigned the right SELinux type, but not the
right SELinux user and SELinux role.

By using "setfiles -F", the SELinux user (and role, but role almost
always remains "object_r") is set to the right one (system_u mostly).

Without this, a multi-user system with different SELinux users and with
User Based Access Control (UBAC) enabled (the local "ubac" USE flag)
might find that some software fails to work for different SELinux users
than the one used to install the software, until a full forced relabel
operation is done.

X-Gentoo-Bug: 530192
X-Gentoo-Url: https://bugs.gentoo.org/show_bug.cgi?id=530192
Acked-by: Zac Medico <zmedico@gentoo.org>
make.defaults: incremental USE_EXPAND (530222)