Simplify pkg rquery to make the work in one pass

This should reduce a lot of overhead and make jail creation faster.

Ticket:	#2457
Merge:	releng/9.1.0
(cherry picked from commit efcc06ed2db9e839318ad7d657f11a27124d0e82)