Skip to content

Instantly share code, notes, and snippets.

@khalid151
Created May 14, 2021 04:45
Show Gist options
  • Save khalid151/cc7084966781d94a56335a0701c6f430 to your computer and use it in GitHub Desktop.
Save khalid151/cc7084966781d94a56335a0701c6f430 to your computer and use it in GitHub Desktop.
Print a list of old package versions of pacman cache
#!/bin/env python
'''
Print old package version paths of pacman cache
'''
import re
from glob import glob
pkg_name = re.compile(r'.+/(\w+)-')
def main():
packages = glob('/var/cache/pacman/pkg/*')
packages.sort()
latest_version = {}
for pkg in packages:
try:
latest_version[pkg_name.match(pkg).group(1)] = pkg
except AttributeError:
pass
for pkg in packages:
if pkg not in latest_version.values():
print(pkg)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment