1

Everybody knows that to check if there are newer versions of software available, we need to do apt-get update.

but in order to reduce bandwidth, I only want to check if there is an updated version of a specific package. How to achieve this? notice that I don't want to install the newer version, just retrieve information about the newer package.

(Please focus on the feasibility of this task rather than the sanity of it..)

Zanna
  • 70,465
Sajuuk
  • 252
  • 2
  • 11
  • sorry about that,but I felt like you should keep your answer. – Sajuuk Aug 08 '17 at 14:36
  • 1
    So am I getting you right that you only want to do a "partial sudo apt update, fetching only information about a specific package (if possible) without fetching all other changed software lists? I really don't see any sense in this, as apt already reduces the consumed bandwidth a lot by only downloading and comparing hashes or timestamps of each repository to determine which of them have changed and to only download those. You will probably not get much cheaper than that, at least not without much effort and maybe risking the stability of your package system. – Byte Commander Aug 08 '17 at 15:11
  • 2
    apt update can be modified for a single repository containing the package but not for a single package. but For a single package you need go to the repo and manually check the package file names. Or check in packages.ubuntu.com or launchpad – Anwar Aug 08 '17 at 15:14
  • OK, I am still confused, but I think I got it. You are not looking to download the package, but just get the version of the package itself, correct? Won't apt-cache policy <packagename> do that for you? – Terrance Aug 08 '17 at 16:37
  • @Terrance, isn't this apt-cache querying the local cache of package list? hence if there is a newer version in the remote repository, I wouldn't know. – Sajuuk Aug 09 '17 at 02:31
  • Did you try the apt-cache command to see? The candidate version would be the one to be updated to. But without running apt update I couldn't tell you. You might really be looking at configuring the apt update to look at a specific repo all the time, or just visiting the web sites that Anwar put in his comment here. – Terrance Aug 09 '17 at 02:56
  • 1

1 Answers1

1

I believe that apt-get update cannot do this.

However, you can use the Launchpad API to retrieve the current version of the package.

From https://help.launchpad.net/API/Examples:

Listing the current package versions in a particular distroseries (Python)

from launchpadlib.launchpad import Launchpad

launchpad = Launchpad.login_with('hello-world', 'production')
ubuntu = launchpad.distributions["ubuntu"]
archive = ubuntu.main_archive
series = ubuntu.current_series
archive.getPublishedSources(exact_match=True, source_name="apport", distro_series=series)[0].source_package_version
### ==> should return u'0.123'

I'm sure you can do the same with curl if you prefer.

Related Question: Does packages.ubuntu.com provide a search API?

pLumo
  • 26,947