Created
August 3, 2019 07:43
-
-
Save lilydjwg/0d54a2fce675725884d51c838d3f76a4 to your computer and use it in GitHub Desktop.
Find files not managed by pacman (for Arch Linux and derivatives)
This file contains 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
#!/usr/bin/python3 | |
import os | |
def allrepofiles(): | |
repo = '/var/lib/pacman/local' | |
files = set() | |
for dirpath, dirnames, filenames in os.walk(repo): | |
for file in filenames: | |
if file != 'files': | |
continue | |
with open(os.path.join(dirpath, file)) as f: | |
files.update('/' + l.rstrip() for l in f) | |
return files | |
def main(startdir): | |
managed = allrepofiles() | |
for dirpath, dirnames, filenames in os.walk(startdir, topdown=False): | |
for f in filenames: | |
p = os.path.join(dirpath, f) | |
if p not in managed: | |
print(p, 'not managed') | |
if __name__ == '__main__': | |
main('/usr') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment