Skip to content

Instantly share code, notes, and snippets.

@ralphbean
Created July 11, 2012 19:25
Show Gist options
  • Select an option

  • Save ralphbean/3092599 to your computer and use it in GitHub Desktop.

Select an option

Save ralphbean/3092599 to your computer and use it in GitHub Desktop.
Reduce a list of packages down to only the root packages.. no dependencies.
#!/usr/bin/env python
""" Use like:
cat list-of-packages.txt | ./reduced-list.py
You're going to need python-sh for this to work.
sudo yum -y install python-sh
"""
# We renamed this to 'sh' in fedora
#import pbs
import sh
import sys
lines = sys.stdin.readlines()
deps = ""
for line in lines:
try:
deps += str(sh.rpm('-qR', line.strip()))
except:
# This package doesn't exist in fedora17
pass
topmost = [line for line in lines if line not in deps]
for package in topmost:
print package
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment