Issue
I want to install package foo
version 1234
in a docker container. I prefer this to the latest version, as it will always work the same way.
RUN apt-get update && apt-get install -y foo=1234
But the base image is mongodb:4.0.2
, which is layered on Ubuntu xenial.
When I build the image, the apt install fails because it cannot find that version. I think xenial doesn't support that version.
So how do I find the latest supported version of a package foo
on xenial? If I run apt policy foo
it shows me the latest for the ubuntu I'm using (bionic), not for xenial.
Solution
If the package at stake is, say, rlwrap
, you could just take a look at the webpage https://packages.ubuntu.com/xenial/rlwrap
But if you want a proper way to get this version info programatically, you can rely on the Launchpad API, which comes with an official API client implemented as a Python library.
Otherwise, you can directly query the API with tools such as curl
and jq
(to parse the retrieved JSON data):
$ curl -fsSL "https://api.launchpad.net/1.0/ubuntu/+archive/primary?ws.op=getPublishedSources&source_name=rlwrap&exact_match=true&distro_series=https://api.launchpad.net/1.0/ubuntu/xenial" \
| jq --raw-output ".entries | .[0] | .source_package_version"
→ 0.41-1build1
As mentioned in this Askubuntu question, a similar API exists for Debian as well.
Answered By - ErikMD Answer Checked By - Candace Johnson (WPSolving Volunteer)