Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import apt_pkg
import debian.deb822
import gzip
import sys
from io import BytesIO
from ubuntutools.lp.lpapicache import Distribution
from urllib.request import urlopen
COMPONENTS = ["main", "restricted", "universe", "multiverse"]
POCKETS = ["", "-security", "-updates"]
def merge_versions(version_dicts):
out = {}
for d in version_dicts:
for p, v in d.items():
if p not in out or apt_pkg.version_compare(v, out[p]) > 0:
out[p] = v
return out
def get_pocket_component_versions(pocket, component):
url = (
print(f"Reading {url}", file=sys.stderr)
with urlopen(url) as fz, as f:
return {
src["Package"]: src["Version"]
for src in debian.deb822.Sources.iter_paragraphs(BytesIO(
def get_release_versions(release):
return merge_versions(
get_pocket_component_versions(release + pocket, component)
for pocket in POCKETS
for component in COMPONENTS
dist = Distribution("ubuntu")
releases = [ for series in dist.series if]
versions = {release: get_release_versions(release) for release in releases}
for new, old in zip(releases[:-1], releases[1:]):
print(f"Comparing {new}, {old}:")
for p in sorted(set(versions[new]) & set(versions[old])):
if apt_pkg.version_compare(versions[new][p], versions[old][p]) < 0:
print(f"{p} {versions[new][p]} < {versions[old][p]}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.