Improve install_command test
https://github.com/jonasbb/podman-gitlab-runner/blob/02d3f9e85004ceb169e15ea0acbb12c38bfd27ab/prepare.sh#L71-L76
I think the install_command test could be improved as the packages listed under the dependencies don't all contain binaries that are equal to the name of the package.
The ca-certificates package for example does not contain any binary called ca-certificates (at least not on archlinux/debian/redhat) which causes the ca-certificates package to be installed in every job.
This can count for a significant amount of time, especially on yum based distros that have a lot of repos enabled.
Possible solutions:
- Adding a second argument to install_command for a file to check (or perhaps a command to run).
- Check if a package is installed instead of relying on the existence of a certain file/binary. This would need to be distro specific but it would be possible to use dpkg/rpm/etc. instead of apt/yum/dnf (using rpm is significantly faster than relying on yum/dnf).
It is indeed unfortunate that this always tries to install the package, but I am not aware how to check these things properly in a distro-agnostic version. Another problem I see is that the install command gets executed multiple times instead of installing all missing packages at once. If someone wants to improve the situation, I am happy to merge that.