packager: refactorized duplicated code
packager: refactorized duplicated code

Former-commit-id: f0496be3ef9dc686a8d8e94a842741b93541ad04
gem/oq-engine,gem/oq-engine,gem/oq-engine,gem/oq-engine,gem/oq-engine