def populate(comps='comps-f16', do_dependencies=True): from yum.comps import Comps session = DBSession() c = Comps() c.add('comps/%s.xml' % comps) for group in c.groups: g = Group(id=group.groupid, name=group.name, description=group.description) session.add(g) for package in group.packages: p = session.query(Package).filter_by( name=to_unicode(package)).first() if not p: p = Package(name=package) session.add(p) p.group = g session.flush() root = Root(name=u'Fedora') session.add(root) session.flush() for category in c.categories: c = Category(id=category.categoryid, name=category.name, description=category.description) session.add(c) root.categories.append(c) for group in category.groups: g = session.query(Group).filter_by( group_id=to_unicode(group)).first() if not g: print "Cannot find group: %s" % group else: g.category = c session.flush() if do_dependencies: for package in session.query(Package).all(): add_dependencies(package, session) session.commit()
def _expand_package_groups(self, filters): if not self.groupsfile: return filters comps = Comps() comps.add(self.groupsfile) groups = comps.get_groups() if hasattr(comps, 'get_environments'): # First expand environment groups, then regular groups environments = comps.get_environments() filters = self._expand_comps_type("environment", environments, groups, filters) else: environments = [] filters = self._expand_comps_type("group", environments, groups, filters) return filters
def populate(comps='comps-f16', do_dependencies=True): from yum.comps import Comps session = DBSession() c = Comps() c.add('comps/%s.xml' % comps) for group in c.groups: g = Group(id=group.groupid, name=group.name, description=group.description) session.add(g) for package in group.packages: p = session.query(Package).filter_by(name=to_unicode(package)).first() if not p: p = Package(name=package) session.add(p) p.group = g session.flush() root = Root(name=u'Fedora') session.add(root) session.flush() for category in c.categories: c = Category(id=category.categoryid, name=category.name, description=category.description) session.add(c) root.categories.append(c) for group in category.groups: g = session.query(Group).filter_by(group_id=to_unicode(group)).first() if not g: print "Cannot find group: %s" % group else: g.category = c session.flush() if do_dependencies: for package in session.query(Package).all(): add_dependencies(package, session) session.commit()
def setup_comps_groups(self, compsxml): """ Utility method for parsing comps.xml. @param compsxml: the location of comps.xml @type compsxml: str @rtype: void """ from yum.comps import Comps self.say('Parsing comps.xml...') comps = Comps() comps.add(compsxml) for group in comps.groups: if not group.user_visible or not group.packages: continue group_filename = _mkid(GRPFILE % group.groupid) self.groups.append([group.name, group_filename, group.description, group.packages]) self.say('done\n')
def setup_comps_groups(self, compsxml): """ Utility method for parsing comps.xml. @param compsxml: the location of comps.xml @type compsxml: str @rtype: void """ from yum.comps import Comps self.say('Parsing comps.xml...') comps = Comps() comps.add(compsxml) for group in comps.groups: if not group.user_visible or not group.packages: continue group_filename = _mkid(GRPFILE % group.groupid) self.groups.append([ group.name, group_filename, group.description, group.packages ]) self.say('done\n')
my._getSacks() for repo in my.repos.listEnabled(): try: my.repos.populateSack(which=[repo.id], mdtype='otherdata') except yum.Errors.RepoError, e: print >> sys.stderr, 'otherdata not available for repo: %s' % repo print >> sys.stderr, 'run as root to get changelog data' sys.exit(1) recent = my.getRecent(days=days) recent.sort(key=lambda pkg: pkg.returnSimple('filetime')) recent.reverse() if options.groups: comps = Comps() for repo in my.repos.listEnabled(): try: groupsfn = repo.getGroups() except RepoMDError: # no comps.xml file groupsfn = None if not groupsfn: continue try: comps.add(groupsfn) except (AttributeError, CompsException): print 'Error parsing comps file %s !' % groupsfn print 'Multiple feed generation impossible.' sys.exit(1) for group in comps.groups: grouppkgs = group.optional_packages.keys(
my._getSacks(archlist=options.arches) else: my._getSacks() for repo in my.repos.listEnabled(): try: my.repos.populateSack(which=[repo.id], mdtype='otherdata') except yum.Errors.RepoError, e: print >> sys.stderr, 'otherdata not available for repo: %s' % repo print >> sys.stderr, 'run as root to get changelog data' sys.exit(1) recent = my.getRecent(days=days) if options.groups: comps = Comps() for repo in my.repos.listEnabled(): try: groupsfn = repo.getGroups() except RepoMDError: # no comps.xml file groupsfn = None if not groupsfn: continue try: comps.add(groupsfn) except (AttributeError, CompsException): print 'Error parsing comps file %s !' % groupsfn print 'Multiple feed generation impossible.' sys.exit(1) for group in comps.groups: grouppkgs = group.optional_packages.keys() + group.default_packages.keys() + group.conditional_packages.keys()