Refactoring of package metadata regex matching

Lets compile the pattern into one regex instead of calling 4 different
patterns.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Refactor resetting of uid/gid so that it is reusable

We need this for the topmost directory but we don't want to have the
pattern matching active at that time.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Fix handling of --include option

In most cases the --include option was not working correctly. Especially it
broke backward compatibility when the argument is not a pattern.

Signed-off-by: Jan Blunck <jblunck@infradead.org>
Fix handling of --exclude option

In most cases the --exclude option was not working correctly. Especially it
broke backward compatibility when the argument is not a pattern.

Signed-off-by: Jan Blunck <jblunck@infradead.org>