Am Sat, 1 Mar 2014 17:56:01 -0500
schrieb "Michael K. Johnson" <[email protected]>:

> On Sat, Mar 01, 2014 at 10:38:20PM +0100, Foresight wrote:
> > Will try tomorrow to create a group recipe that extracts groups
> > from comp-f20.xml I played a bit with etree. Looks doable even for
> > me.
> 
> Wonderful!  Thanks Mark!
> 
> Don't worry about writing a recipe, really.
> 
> We're using GroupSetRecipe, and all that we need is something that
> gives us mappings from group name to list of package names.  A
> dictionary would make sense:
> 
> mapping = {
>     'groupname1': ('packagenameA', 'packagenameB', ...),
>     'groupname2': ('packagenameB', 'packagenameC', ...),
>     'groupname3': ('packagenameD', 'packagenameE', ...),
>     ...
> }
> 
> In the group, we'll be doing something like:
> 
>     ...
>     allPkgs = ... # load data from an XML file mirrorball writes
>     subGroups = []
>     for groupname in sorted(mapping.keys()):
>         pkgs = allPkgs.findByName('(%s)'
> %('|'.join(mapping[groupname]))) pkgGrp = pks.createGroup('group-' +
> groupname) subGroups.append(pkgGrp)
> 
>     # likely add group-standard based on those since it is a
> consistent # name in conary-wrapped OSes
> 
>     r.Group(subGroups)
I came up with something like
the attached group, but it fails with 
error: /home/mark/conary/src/fedora-20/group-fedora/group-fedora.recipe:26:
 AttributeError: 'list' object has no attribute '_createGroup'

Any hints?
the comps-f20.xml file I got from 
http://dl.fedoraproject.org/pub/fedora/linux/releases/20/Everything/x86_64/os/repodata/

recipe looks like that:

import xml.etree.ElementTree as ET
class GroupFedora(GroupSetRecipe):
    name = 'group-fedora'
    version = '20'

    def setup(r):
        r.dumpAll()

        repo = r.Repository('f20s1.flnx.org@f:20sbeta', r.flavor)

        latest = repo.latestPackages()

        # xml magic here
        comps = ET.parse('comps-f20.xml')
        root = comps.getroot()
        groups = []
        for g in root.findall('group'):
            pkglist = set()
            for pkg in g.find ('packagelist'):
                pkglist.add(pkg.text)
            group = latest.findByName('(' + '|'.join(pkglist) + ')')
            group += group.depsNeeded(latest)
            groups.append(group.createGroup('group-' +
        g.find('id').text)) 
        r.Group(groups)
_______________________________________________
Foresight-devel mailing list
[email protected]
https://lists.foresightlinux.org/mailman/listinfo/foresight-devel

Reply via email to