#!/usr/bin/python -tt #I need a script which will go through Rawhide and make a list of #packages where: #* The source package generates a subpackage that does NOT depend (either #implicitly or explicitly) on another binary package/subpackage generated #from that same source package. #E.g. #libfoo-1.2.3.src.rpm generates libfoo, libfoo-devel, and libfoo-utils. #libfoo-devel depends on libfoo, but libfoo-utils doesn't depend on #either libfoo or libfoo-devel. #So, the results would flag libfoo-utils as an independent subpackage #(source: libfoo). #I don't really need the script as much as I need the results, but the #script might be useful in the future. # written by seth vidal # copyright 2010 Red Hat, Inc # GPLv2+ import yum import re import os license_match = re.compile('(copying)|(license).*$').match def has_likely_license_file(pkg): for fn in pkg.filelist: test = os.path.basename(fn).lower() if license_match(test): return True return False my = yum.YumBase() my.preconf.debuglevel = 1 my.preconf.disabled_plugins = ['auto-update-debuginfo', 'addl-history-info'] #my.arch.archlist = ['x86_64', 'noarch'] my.setCacheDir() my.repos.disableRepo('*') my.repos.enableRepo('rawhide') pkgs_by_sourcerpm = {} for pkg in my.pkgSack.returnNewestByNameArch(): if not pkg.base_package_name in pkgs_by_sourcerpm: pkgs_by_sourcerpm[pkg.base_package_name] = set() pkgs_by_sourcerpm[pkg.base_package_name].add(pkg) bases = pkgs_by_sourcerpm.keys() for basepkg in bases: if len(pkgs_by_sourcerpm[basepkg]) < 2: del pkgs_by_sourcerpm[basepkg] indy_rockers = {} for basepkg in pkgs_by_sourcerpm: #print basepkg siblings = pkgs_by_sourcerpm[basepkg] for pkg in siblings: if pkg.name == basepkg: # if our name is the same as the basepkg then ignore us continue #print ' %s' % pkg still_indy = True # assume it is indy until proven otherwise for brother in siblings: # look at each sibling pkg if pkg == brother: continue #print brother for req in pkg.requires: if brother.provides_for(req): still_indy = False # if the sibling provides something the pkg requires break # then we're not indy #print 'end' #print 'no more sibs' if still_indy: # if we're here and still indy then add us to the indy_rockers. if not basepkg in indy_rockers: indy_rockers[basepkg] = set() indy_rockers[basepkg].add(pkg) # go through all the indyrockers and if their filelists includes a file named COPYING or LICENSE then toss them out # of the list for basepkg in sorted(indy_rockers.keys()): print '%s:' % basepkg for pkg in indy_rockers[basepkg]: if has_likely_license_file(pkg): print ' %s - has license or copying file' % pkg else: print ' %s' % pkg