Skip to content

Instantly share code, notes, and snippets.

@apocalyptech
Created July 11, 2021 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apocalyptech/4445c591824a8d0bbc7f7501ca43226b to your computer and use it in GitHub Desktop.
Save apocalyptech/4445c591824a8d0bbc7f7501ca43226b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# vim: set expandtab tabstop=4 shiftwidth=4:
from __future__ import print_function
import os
import sys
import subprocess
rpmd_files = set()
print('Getting list of installed RPMs...', file=sys.stderr)
proc = subprocess.Popen(['/bin/rpm', '-qa'], stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
for idx, rpm in enumerate(stdout.splitlines()):
if idx != 0 and idx % 50 == 0:
print('Indexed {} RPMs...'.format(idx), file=sys.stderr)
proc = subprocess.Popen(['/bin/rpm', '-ql', rpm], stdout=subprocess.PIPE)
stdout, _ = proc.communicate()
for filename in stdout.splitlines():
if filename.startswith('/usr/'):
rpmd_files.add(filename)
for dirpath, _, filenames in os.walk('/usr'):
for filename in filenames:
full_path = os.path.join(dirpath, filename)
if full_path not in rpmd_files:
print(full_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment