I want to upgrade a Linux package to a specific version on a CentOS system.
The Linux package I am trying to upgrade is giblab-ce
. The gitlab-ce
supports a list of upgrade paths and if the installed gitlab-ce
is too old, we cannot upgrade it via dnf upgrade
or yum upgrade
because the said commands always attempt to upgrade the application to the latest one, which may not be permitted because the upgrade path is not in the list of the supported ones. The following is an example where such a scenario arises,
$ yum upgrade gitlab-ce
......
Running transaction
gitlab preinstall: It seems you are upgrading from major version 13 to major version 14.
gitlab preinstall: It is required to upgrade to the latest 14.0.x version first before proceeding.
gitlab preinstall: Please follow the upgrade documentation at https://docs.gitlab.com/ee/update/index.html#upgrade-paths
error: %pre(gitlab-ce-14.4.1-ce.0.el7.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package gitlab-ce-14.4.1-ce.0.el7.x86_64
Verifying : gitlab-ce-14.4.1-ce.0.el7.x86_64 1/2
gitlab-ce-13.9.4-ce.0.el7.x86_64 was supposed to be removed but is not!
Verifying : gitlab-ce-13.9.4-ce.0.el7.x86_64 2/2
Failed:
gitlab-ce.x86_64 0:13.9.4-ce.0.el7 gitlab-ce.x86_64 0:14.4.1-ce.0.el7
To resolve this issue, we need to upgrade it to the most recent version we can upgrade according to the upgrade paths. The question becomes, how?
First, we need to find out the available versions of the pacakge. The following commands can answer this question,
yum list PACKAGE_NAME --showduplicates
or
dnf list PACKAGE_NAME --showduplicates
For instance, we can know the list of the available versions of the gitlab-ce
dnf list gitlab-ce --showduplicates
......
Available Packages
gitlab-ce.x86_64 12.8.1-ce.0.el8 gitlab_gitlab-ce
......
gitlab-ce.x86_64 13.9.4-ce.0.el8 gitlab_gitlab-ce
gitlab-ce.x86_64 13.9.5-ce.0.el8 gitlab_gitlab-ce
......
gitlab-ce.x86_64 14.0.12-ce.0.el8 gitlab_gitlab-ce
......
gitlab-ce.x86_64 14.4.1-ce.0.el8 gitlab_gitlab-ce
Since gitlab-ce
has the following upgrade path 13.8.8 -> latest 13.12.Z -> latest 14.0.Z -> latest 14.Y.Z
, we will upgrade
gitlab-ce
to 13.12.5
, then to 14.0.12
, and finally to 14.4.1
. To upgrade the specific version, we
use either a yum
or a dnf
command in the following format,
dnf upgrade PACKAGE_NAME-PACKAGE_VERSION
or
yum upgrade PACKAGE_NAME-PACKAGE_VERSION
For instance, to upgrade gitlab-ce
to version 13.12.5
, we run
dnf upgrade gitlab-ce-14.0.12-ce.0.el8
We repeat the dnf upgrade
command on more recent versions until we reach the latest one. If we don't know the list of the permitted upgrade paths, we can always take the trial and error approach to try to upgrade to a newer version until we success and finally reach the latest version.