Created
May 14, 2021 04:45
-
-
Save khalid151/cc7084966781d94a56335a0701c6f430 to your computer and use it in GitHub Desktop.
Print a list of old package versions of pacman cache
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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