Create local database directory if it is missing

This means that a missing local database becomes an error (as it
should be immediately created).  Note this only creates the "local"
directory and not its parent, which is check for during locking.

Signed-off-by: Allan McRae <allan@archlinux.org>
Add version file when creating local database directory

The version of the local pacman database is stored in its root in the file
.alpm_db_version.  The version is starting at 9, corresponding to the
next libalpm library version.

Signed-off-by: Allan McRae <allan@archlinux.org>
Add version file to empty local database

If a user manually creates the local database directory, or has an empty
local database for some other reason, we silently add a version file

Signed-off-by: Allan McRae <allan@archlinux.org>
Check the version of the local database during validation

Signed-off-by: Allan McRae <allan@archlinux.org>
FIXME: Extend database upgrade script to handle alpm db version 9

Signed-off-by: Allan McRae <allan@archlinux.org>