actually, it is not that easy (or complicated, depending on where you look at it) as you describe.

you can use any version of any library (even 30 years old ones) as long as their dependencies do not contradict what the current OS uses, provided they work with the architecture.

Ubuntu 22.x is called “jammy” and installs packages with that name. but you can still install packages from older (bionic, focal, trusty etc.) repositories if you need them. You just need to add their repository url to the apt source list file. the same also goes for independent packages like MongoDB: they have their own repository urls you need to add to apt source list.

Here in this topic, installing MongoDB 6.0 on Ubuntu 22.x, we have two options:

  • add one of older ubuntu repositories to your apt list (then follow remaining steps):

    • echo "deb http://security.ubuntu.com/ubuntu focal-security main" | sudo tee /etc/apt/sources.list.d/focal-security.list
  • wait for a new build (which is already here) and use it (@chris mentioned this many times)

    • echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list

The first method uses MongoDB built for “ubuntu/focal” and the second one uses “ubuntu/jammy” build. The only thing missing is the official installation page does not yet have this on it.

One can easily see which versions have been built for which ubuntu here: MongoDB Repositories. If you follow “Parent Directory” link, you can even find builds for other Linux distros there.