Score:1

How to force apt/apt-get to update to latest version on package server without specifying the version?

dm flag

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.

mipolak avatar
de flag
similar question was already answered https://askubuntu.com/questions/138284/how-to-downgrade-a-package-via-apt-get [answer](https://askubuntu.com/a/1112347/1180244)
FedKad avatar
cn flag
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_?
apbr avatar
dm flag
@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 avatar
dm flag
@FedKad Good idea, but in this case not really as I already know the package I want to downgrade/update.
Score:1
jp flag

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.

apbr avatar
dm flag
Thank you. I tested it and it is exactly what I asked for.
Artur Meinild avatar
vn flag
This is great answer that deserves more upvotes.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.