Refactor contrib install

Reusing the current package install dynamics and converting it into a define we can reuse it to install different packages