Fix runner deb package upgrade

In Move exported helper images into separate package (!5190 - merged) we separated the exported helper images into their own package. This caused the issue described in Broken debian packaging after MR !5190 (#38394 - closed).

Upgrading TO gitlab-runner 17.7.0 will fail on deb-based systems because the files previously provided by the gitlab-runner package are now provided by the gitlab-runner-helper-images package, and apt-based package managers view this as conflict.

The fix is to add a --replaces gitlab-runner option to fpm, which translates to Replaces metadata in the deb package. This options allows the gitlab-runner-helper-images packages to clobber files from the gitlab-runner package.

For rpm packages this issue does not manifest in practice. The dnf/yum package managers appear to do the right/useful thing by default. Even using rpm directly does the right thing in most cases: Upgrading to runner version 17.7.x via rpm -U works as expected 👍. However, installing (rpm -i) gitlab-runner-helper-images.rpm and gitlab-runner-17.7.0-1.x86_64.rpm on top of gitlab-runner-17.6.1-1.x86_64.rpm fails. Our upgrade docs use rpm -U so I think we are OK here.

Testing

deb

docker run -it --rm -v "$PWD":/runner registry.gitlab.com/gitlab-org/ci-cd/runner-tools/base-images/ci:0.0.1 bash
cd /runner
mage package:prepare
export PACKAGES_ITERATION="1"
mage package:helpersDeb

docker run -it --rm -v $PWD/out:/pkgs debian:latest bash
apt-get update
apt-get install curl
curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | bash
apt-get install gitlab-runner=17.6.0-1
gitlab-runner --version
cd /pkgs/deb
apt-get install gitlab-runner ./gitlab-runner-helper-images.deb 
gitlab-runner --version

rpm

docker run -it --rm fedora:latest bash
curl -s https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | bash
yum install gitlab-runner-17.6.0-1
gitlab-runner --version 
dnf/yum update # succeeds
gitlab-runner --version

and/or

microdnf install git git-lfs tar
curl -L https://packages.gitlab.com/runner/gitlab-runner/packages/el/9/gitlab-runner-17.6.0-1.x86_64.rpm/download.rpm -o gitlab-runner-17.6.0-1.x86_64.rpm
curl -L https://packages.gitlab.com/runner/gitlab-runner/packages/el/9/gitlab-runner-17.7.0-1.x86_64.rpm/download.rpm -o gitlab-runner-17.7.0-1.x86_64.rpm
curl -L https://packages.gitlab.com/runner/gitlab-runner/packages/el/9/gitlab-runner-helper-images-17.7.0-1.noarch.rpm/download.rpm -o gitlab-runner-helper-images-17.7.0-1.noarch.rpm
rpm -i gitlab-runner-17.6.0-1.x86_64.rpm
gitlab-runner --version
rpm -U gitlab-runner-helper-images-17.7.0-1.noarch.rpm gitlab-runner-17.7.0-1.x86_64.rpm
gitlab-runner --version
Edited by Axel von Bertoldi

Merge request reports

Loading