Skip to content

Instantly share code, notes, and snippets.

@lilydjwg
Created August 3, 2019 07:43
Embed
What would you like to do?
Find files not managed by pacman (for Arch Linux and derivatives)
#!/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