Skip to content

Instantly share code, notes, and snippets.

@lmacken
Created March 24, 2012 21:00
Show Gist options
  • Save lmacken/2187726 to your computer and use it in GitHub Desktop.
Save lmacken/2187726 to your computer and use it in GitHub Desktop.
Generate a list of all Fedora packages and their license
#!/usr/bin/env python
# Writes a file called 'rawhide-pkg-licenses.txt' containing a list of all
# packages in Fedora with their corresponding license.
#
# Before running, you must first warm up the yum cache:
#
# sudo yum --disablerepo=\* --enablerepo=rawhide-source makecache
#
# Author: Luke Macken <[email protected]>
import yum, operator
yb = yum.YumBase()
for repo in yb.repos.findRepos('*'):
if repo.id == 'rawhide-source': repo.enable()
else: repo.disable()
open('rawhide-pkg-licenses.txt', 'w').writelines(('%s %s\n' % (n, l)
for n, l in sorted(((p.name, p.license)
for p in yb._getSacks(['src']).returnPackages()),
key=operator.itemgetter(0))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment