Add public API for pkgdb transactions.
Use transactions for pkg-set.

Speed up can reach 10 or even 100 times comparing to the naive version.
Allow directories to be symlinks to directories

In that case we do not set the credential and perms on the directory
considering the user making those symlinks knows what he is doing.