-2

I know how to install a specific version of a package. Now I want to upgrade all packages of my system with:

sudo apt upgrade

But for a specific package, I do not want it to upgrade to the latest version, but to a specific one. E. g., currently installed version is 1. Latest available via apt is 3. I want to upgrade to 2. Is it possible with apt?

  • You can hold a package, and then control the version manually. – Artur Meinild Feb 23 '24 at 17:55
  • 1
    Currently there is no upgrade available for gitlab-runner for any release of Ubuntu in the Ubuntu repositories. If you are using Ubuntu sources, apt upgrade won't change that package no matter how hard you try. To see for yourself, examine the output of apt policy gitlab-runner – user535733 Feb 23 '24 at 18:30
  • @ArturMeinild If I hold it, it won't upgrade at all, right? Do you know what I have to tell apt afterwards to upgrade it to a specific version? – stackprotector Feb 23 '24 at 19:01
  • @stackprotector if you use aptitude and search for the package, down at the bottom of the description it shows the available versions. If you highlight the version you want and press +, it will set that version to be installed. – Organic Marble Feb 23 '24 at 19:21
  • Yes then you unhold, upgrade manually, and hold again to prevent apt from upgrading. – Artur Meinild Feb 23 '24 at 20:27
  • 1
    If this Version you wish is available through apt you can pin It with apt-pinning. – nobody Feb 23 '24 at 22:16

1 Answers1

0

With nobody's helpful comment, pointing to apt-pinning, I was able to come up with the following solution:

You can pin a package to a specific version by creating a preference file for it (e. g. /etc/apt/preferences.d/my-package) with the following content:

Package: my-package
Pin: version 2
Pin-Priority: 1000

This will tell apt to not upgrade package my-package to a greater version than 2.