Issue 414:

Response to PR ports/175249:

Perhaps the variables could be better named: euid, egid here are the
expected user and group ownership of the various files and
directories.  I've changed them to fileowner and filegroup.

In normal use both /var/db/pkg and all the .sqlite files pkg uses
within it should be owned by root:wheel and only writeable by root.
Allowing non-root to modify the pkg DB would be a security debacle
just waiting to happen.

The change as you have it would mean that an ordinary user could not
run pkg info on a standard system.

The install_as_user flag specifically changes the requirement on
ownership so that a (non-root) user can have a personally owned copy
of a pkgng database.  Implicit in that is the assumption that they're
going to set PKG_DBDIR to put their private DB in other than the
default location.

I found and fixed a different bug to do with creating repo.sqlite the
first time ever 'pkg update' was run for a new $PKG_DBDIR, and I have
shamelessly stolen your additions to the error message in
file_mode_insecure().
Add new case insensitive match capability.

Add boolean flag to pkg_is_installed() to allow case insensitve
matching there.

Use pkg_is_installed() instead of duplicating the code in several
places.
Fix typo: the option for 'exact match' is -e
Revise pkg-set.8 to use better English.  Sort option descriptions
alphabetically, add description of '-e' for exact match.
Add '-e' option to pkg-set.  Sort options. Delete unused 'k' from
getopts() string.  Make handling of 'yes' more like other programs.
On second thoughts: '-e' for exact search is pointless, as exact is
already the default.
Think again.  Add a global case_sensitive flag which defaults to true
(case sensitive), plus accessor and mutator functions.

Adjust MATCH_EXACT and MATCH_REGEX code to abide by the case
sensitivity flag.
Generally add a -i option meaning 'case insensitive' which affects
MATCH_EXACT and MATCH_REGEX match types.
Update document dates
Removing trailing whitespace
Makes default path for ports directory a build time configuration
When reseting a package reset the associated flags
Fix conversion logic
Do not assert on NULL sbuf in sbuf_get but return an empty string, that allows
pkg_is_valid to show the missing fields
Fix loading +CONTENTS files
Set a default arch when loading from old format and set an unknown maintainer
Fix the package has no prefix, first time @cwd it will become the default pkg prefix
Allow pkg_set_from_file to trimcr, this allows pkg convert to 100% work
Keep pkg2ng to not break existing documentation, make it use pkg convert
pkg convert -r now creates the +REQUIRED_BY files