9

I just noticed that the focal-proposed repository was included in my sources.list on ubuntu 20.04, although that doesn't seem to be recommended. After disabling it, the command

apt-show-versions | grep newer

shows around 30 packages whose installed version is newer than the one in the repository. Is there a simple way to downgrade all of them to the available version?

2 Answers 2

8

I wrote a similar answer here

To do this, first remove any lines with focal-proposed from /etc/apt/sources.list and /etc/apt/sources.list.d/*.

Second we are going to tell apt to allow downgrades. That means pinning focal, focal-updates and focal-security with priorities higher than 1000. Create /etc/apt/preferences.d/focal with this content:

Package: *
Pin: release n=focal
Pin-Priority: 1001

Package: *
Pin: release n=focal-updates
Pin-Priority: 1002

Package: *
Pin: release n=focal-security
Pin-Priority: 1003

If you don't use focal-updates or focal-security then skip those sections.

Third, run the following:

sudo apt update
sudo apt upgrade
sudo apt dist-upgrade
sudo apt --fix-broken install
sudo apt autoremove

and keep rotating between those commands until everything is stable.

Finally, delete /etc/apt/preferences.d/focal.


Alternatively, you can just delete focal-proposed. Those packages will eventually migrate to focal-updates when they pass their test and you'll be in sync again.

With your small delta, --fix-broken install and autoremove probably won't be neccessary but apt will tell you when you read the output of the previous commands.


To anyone else who comes accross this post: Downgrading is not supported. Any downgrade of significant size is likely to fail. This is a pretty trivial case, but going from focal to bionic would probably be a disaster and leave you with a broken system.

5
  • Great, thanks! In the meantime I found a similar answer here, but it uses "release o=*" in the pin. What's the difference? (Your explanation is better in any case)
    – user313032
    Oct 28, 2020 at 19:56
  • 1
    man apt_preferences describes o= as the "originator of the packages in the directory tree of the Release file". I don't honestly know what that means other than the given example is Debian. n= is the codename (bullseye, bionic, or focal-updates). a= is the suite (stable, unstable, testing)
    – Stewart
    Oct 28, 2020 at 20:53
  • 1
    I found an example in the man page where: Pin: release o=Debian Pin-Priority: -10 will uninstall any packages which are not Debian-originated.
    – Stewart
    Oct 28, 2020 at 21:04
  • The release o=* constraint means "not locally installed", that is, packages which have a known origin. If your sources contain only the repos from which you want package version installed, it's a shorter than spelling out specific names. Oct 29, 2020 at 9:31
  • Wow, that is an elegant way to do it
    – Stewart
    Oct 29, 2020 at 12:20
1

Little bit shorter.

cat /etc/apt/preferences.d/focal.pref 
Package: *
Pin: release n=focal
 
Pin-Priority: 1001

The record assigns a high priority to all package versions belonging to any distribution whose Codename is "focal".

Note works only when focal-proposed is no longer active.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .