migrations library in installer: fix install() for non-core migrations

Copy this regression fix to the installer.
roles permission_matrix(): remove unused 'roles' variable
Don't show deleted roles (issue #764)
users auth library: remove duplicate field in $selects

Pointed out in issue #773.
permission model: remove no-op $purge parameter

The permissions model does not have soft_deletes enabled, there is no
deleted column, and nothing uses the state "deleted" either.  So this
parameter has never worked, and in fact was never used.

Remove the parameter so it doesn't give a false impression.
install: update copies of models

This looks like a lot but it's mainly changes in the style of function
comments.  It shouldn't change the installer's behaviour at all.
Don't disable username validation when !auth.use_usernames (issue #759)

This would have allowed e.g. duplicating a username someone else had
created, which could break logins (if auth.login_type was not
set specifically to 'email').

Also fix the username field to be required when
auth.login_type == 'username' (even if auth.use_usernames is disabled).
install: populate user table *before* running custom migrations

Requested in issue #770
user template
Merge remote-tracking branch 'upstream/develop' into develop
Revert "user template"

This reverts commit fe5280fd1d661f1ccb3fddf2485c84ba9cebf208.