emerge: check for writable /var/db/pkg (490732)

If there are packages to be merged or unmerge, then bail out early
if /var/db/pkg is not writable (in order to avoid a fatal EROFS error
which would otherwise occur later on). Behavior remains unchanged for
--pretend mode. For --ask mode, it will bail out just after the last
relevant --ask prompt.

In contrast to the writeable_check module, which operates on files just
before they are merged, the new vardbapi.writable check is performed
before anything has been built (much earlier).

X-Gentoo-Bug: 490732
X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=490732