Programmatically check if there is a new Debian OS release

Question:

I was wondering if there was a way of finding out programmatically (e.g., a command that I can run from a Python script) if there is a new Debian OS release. I know that apt get update gives me info about upgradable packages, but I’m unsure if packages also imply os releases. Thanks in advance.

I’m trying to write a python script that sends notifications whenever there is a new OS release. I have a working version using the subprocess function and the sudo apt update command. But I’m unsure if that command also provides info about new OS releases, or "just" about new upgradable packages.

Asked By: jl20

||

Answers:

You can check the release name in your mirror, e.g.: http://ftp.fi.debian.org/debian/dists/stable/Release . Check e.g. for the line codename (if you care just release, or the Version if you care about point releases), and if it has changed from last time, you have a new release. Note: you may see a new release before official announcement or later (by few days), but that is due for practical reasons during release.

Check carefully a mirror near you, and do not ask too many time per day about release. And better: ask if the file is changed and download it only in such case.

Answered By: Giacomo Catenazzi