Created
July 11, 2012 19:25
-
-
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.
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
| #!/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