libpacman: Move _pacman_db_write to _pacman_localdb_write, writing is only allowed there.
libpacman: Simplify _pacman_localdb_write since it can only be called for a localdb.