1

How do I force apt/apt-get to update to the latest version of a package that is available on the package server even if this means a downgrade but without specifying the version I want to install.

For example I have foo_0.2 locally installed and the server only has foo_0.1. In that case I want to get foo_0.1 installed.

I know I can manually find out the version available on the package server via apt policy foo and then run apt install foo=0.1.
But is there a command that just installs the latest version that is on the package server without me explicitly specifying the version?

Note: A similar question was asked in How to downgrade a package via apt-get?, but this question here is about downgrading without manually specifying a version.

apbr
  • 13
  • similar question was already answered https://askubuntu.com/questions/138284/how-to-downgrade-a-package-via-apt-get answer – mipolak Jul 25 '23 at 11:55
  • Is it better to ask the question like this? How can I get a list of all packages that are installed on my system and are with a higher version than the ones available on the package server? – FedKad Jul 25 '23 at 13:44
  • @mipolak Not exactly I don't want to specify the version to install. I edited my question to make it a bit more clear. – apbr Jul 26 '23 at 08:01
  • @FedKad Good idea, but in this case not really as I already know the package I want to downgrade/update. – apbr Jul 26 '23 at 08:02

1 Answers1

1

You can try using apt_preferences to accomplish this.

For example, if the "package server" containing the foo package is archive.ubuntu.com then you can configure a preference for this server

cat <<EOF > /etc/apt/preferences.d/50my
Package: *
Pin: origin archive.ubuntu.com
Pin-Priority: 1001
EOF

The Pin-Priority value must be 1000 or higher. From the apt_preferences man page

   P >= 1000
       causes a version to be installed even if this constitutes a downgrade of the package

If you were to run apt-get install foo then the foo package should be downgraded without having to specify the specific version.

I have not tested this setup to verify it works.