build: Ensure packages wont depend on themselves

In some instances a package may end up depending on itself due to
differences in lib64 and lib resolving of dependencies. This commit
ensures lib and lib64 are both checked if required and ensures any
part of the package cannot depend on itself (causing circular dependencies)