Ubuntu – How to use Firefox from 18.04 repositories in Ubuntu 20.04


Firefox in Ubuntu 18.04 had a special patch to enable global menu, which was dropped in subsequent versions.
I want to install that version in 20.04. One way to do this is to grab the .deb file and run sudo apt-mark hold firefox. But then, I will have to manually apply an update when a new version is released.

Is there a way to configure apt so that only firefox will be installed (and updated) from 18.04 repositories, while all other software will be installed from 20.04 repositories?

(Although the global menu patch was dropped when Unity was discontinued, global menu is very much alive due to KDE Plasma's global menu feature).

Best Answer

In /etc/apt/sources.list.d/ add bionic sources, so it will be easier to remove it. To do this, create the file /etc/apt/sources.list.d/bionic.list with the following contents.

deb http://archive.ubuntu.com/ubuntu/ bionic main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe multiverse

create /etc/apt/preferences.d/bionic.pref

#preference for firefox from bionic
Explanation: Allow installing firefox from bionic
Package: firefox
Pin: release a=bionic-updates
Pin-Priority: 1101

Explanation: Avoid other packages from the bionic repo.
Package: *
Pin: release a=bionic
Pin-Priority: 1

Proceed with

sudo apt update

first simulation, because I don't no if some ppa's included in your system.

apt -s full-upgrade
NOTE: This is only a simulation!
      apt needs root privileges for real execution.
      Keep also in mind that locking is deactivated,
      so don't depend on the relevance to the real current situation!
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be DOWNGRADED:
0 upgraded, 0 newly installed, 1 downgraded, 0 to remove and 0 not upgraded.
Inst firefox [84.0+build3-0ubuntu0.20.04.1] (84.0+build3-0ubuntu0.18.04.1 Ubuntu:18.04/bionic [amd64])
Conf firefox (84.0+build3-0ubuntu0.18.04.1 Ubuntu:18.04/bionic [amd64])

Then run sudo apt full-upgrade to install firefox from Ubuntu 18.04.