Skip to content

Instantly share code, notes, and snippets.

@srkiNZ84
Last active March 11, 2022 04:48
Show Gist options
  • Save srkiNZ84/57f22d256be87f59b7575a5584239ef8 to your computer and use it in GitHub Desktop.
Save srkiNZ84/57f22d256be87f59b7575a5584239ef8 to your computer and use it in GitHub Desktop.

Revisions

  1. srkiNZ84 revised this gist Mar 11, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions list-upgradable.py
    Original file line number Diff line number Diff line change
    @@ -14,6 +14,9 @@
    if dep_cache.is_upgradable(pkg) and pkg.current_state == apt_pkg.CURSTATE_INSTALLED:
    #print(" ", pkg.name)
    need_upgrade.append(pkg.name)
    print(pkg.name, " needs upgrade. Current version is: ", pkg.current_ver.ver_str, "\n latest is: ", \
    dep_cache.get_candidate_ver(pkg).ver_str)

    print(json.dumps(need_upgrade))


  2. srkiNZ84 revised this gist Mar 11, 2022. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion list-upgradable.py
    Original file line number Diff line number Diff line change
    @@ -4,9 +4,16 @@

    import apt
    import apt_pkg
    import json

    need_upgrade = []

    cache = apt.apt_pkg.Cache()
    dep_cache = apt.apt_pkg.DepCache(cache)
    for pkg in cache.packages:
    if dep_cache.is_upgradable(pkg) and pkg.current_state == apt_pkg.CURSTATE_INSTALLED:
    print(" ", pkg.name)
    #print(" ", pkg.name)
    need_upgrade.append(pkg.name)

    print(json.dumps(need_upgrade))

  3. srkiNZ84 created this gist Mar 11, 2022.
    12 changes: 12 additions & 0 deletions list-upgradable.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    #!/usr/bin/python3

    # NOTE: Requires the python3-apt package

    import apt
    import apt_pkg

    cache = apt.apt_pkg.Cache()
    dep_cache = apt.apt_pkg.DepCache(cache)
    for pkg in cache.packages:
    if dep_cache.is_upgradable(pkg) and pkg.current_state == apt_pkg.CURSTATE_INSTALLED:
    print(" ", pkg.name)