pacman-db-upgrade: do not mangle file lists

grep'ing out blank lines and sorting output thoroughly breaks any file
lists with %BACKUP% entries which must be separated from the file list
by a blank line.  Adds a custom function to ensure that all paths
printed are non-empty and unique.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>