apt – Prevent Firefox Downgrade in Ubuntu 22.04

22.04aptfirefox

I was mind blown when after fresh installing 22.04 I saw firefox taking 10 seconds to cold start on my state of the art rig – Intel Core i9 12900K / G.Skill 64 GB DDR5 5600 Mhz / Samsung 980 PRO M.2 PCI4 / Nvidia RTX 3080.

So I did what many people recommended – uninstalled snap firefox, completely exterminated snap and installed it using the mozillateam ppa:

sudo add-apt-repository ppa:mozillateam/ppa
sudo apt install -t 'o=LP-PPA-mozillateam' firefox

All good, Firefox 99 is installed.

But now I have a problem. There's still an older version 98 lurking in the apt:

$ sudo apt list --upgradable -a
Listing... Done
firefox/jammy 1:98.0.2+build1-1~xtradeb3 amd64 [upgradable from: 99.0.1+build1-0ubuntu0.22.04.1~mt1]
firefox/jammy 1:1snap1-0ubuntu2 amd64
firefox/jammy,now 99.0.1+build1-0ubuntu0.22.04.1~mt1 amd64 [installed,upgradable to: 1:98.0.2+build1-1~xtradeb3]

And as soon as I do

$ sudo apt dist-upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  firefox
1 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
Need to get 62.8 MB of archives.
After this operation, 555 kB disk space will be freed.
Do you want to continue? [Y/n] 

This actually downgrades the current version 99 to version 98. Then firefox refuses to start and demands creating a new profile because the version was downgraded. WTF? How do I prevent firefox being "upgraded" from anywhere else but the mozillateam repository it was installed from?

EDIT:

$ sudo apt cache policy firefox
E: Invalid operation cache

EDIT2:

$ apt policy firefox
firefox:
  Installed: 99.0.1+build1-0ubuntu0.22.04.1~mt1
  Candidate: 1:98.0.2+build1-1~xtradeb3
  Version table:
     1:98.0.2+build1-1~xtradeb3 500
        500 https://ppa.launchpadcontent.net/xtradeb/apps/ubuntu jammy/main amd64 Packages
     1:1snap1-0ubuntu2 500
        500 http://gb.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
 *** 99.0.1+build1-0ubuntu0.22.04.1~mt1 500
        500 https://ppa.launchpadcontent.net/mozillateam/ppa/ubuntu jammy/main amd64 Packages
        100 /var/lib/dpkg/status

EDIT3: Fix, I think

Thanks to @Henning Kockerbeck suggestion I've realized that adding ppa priority is the fix.

sudo vim /etc/apt/preferences.d/mozillateamppa

File contents:

Package: firefox*
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 501

Best Answer

To have the PPA of mozillateam take precedence over the Ubuntu software sources, add a rule:

cat <<EOF | sudo tee /etc/apt/preferences.d/mozillateam.pref
# To prevent repository packages from triggering the installation of Ubuntus snap
# version of firefox, this file prioritizes the packages of mozillateam

Package: firefox*
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001
EOF

Now, a sudo apt install firefox will install the package from the mozillateam PPA instead.

Related Question