Skip to content

Instantly share code, notes, and snippets.

@sjp38
Created October 22, 2013 06:20
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 sjp38/7095984 to your computer and use it in GitHub Desktop.
Save sjp38/7095984 to your computer and use it in GitHub Desktop.
Extract all SRPMs in current path to source level
#!/usr/bin/env python
import os
import sys
for filename in os.listdir('./'):
if not filename.endswith('.rpm'):
continue
if sys.argv[1][-1] == '/':
sys.argv[1] = sys.argv[1][0:-1]
topdir = "%s/%s" % (sys.argv[1], filename[0:-4])
cmd = "rpm --define '_topdir %s' -i %s" % (
topdir, filename)
print cmd
os.system(cmd)
os.chdir('%s/SPECS' % topdir)
for specfile in os.listdir('./'):
if not specfile.endswith('.spec'):
continue
cmd = "rpmbuild --define '_topdir %s' -bp %s" % (
topdir, specfile)
print cmd
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment