Deduplicate dependency checks

Some code that I also used for https://github.com/owncloud/administration/pull/11