#!/usr/bin/python -tt import os import sys import yum import yum.comps import readline # prompt for group name (if not given) # prompt for list of packages (space separated) for each type (m, d, o) (if not given) # groupid = group_name w/_ for spaces # If --from_package is specified then take the deps of that package resolve them # and make those the 'mandatory' pkgs # optionally take a --group-only so it only dumps out the group stanza, not # the full xml file. def get_group_info(): group = yum.comps.Group() print "Group ID (one word): ", group.groupid = raw_input() if not group.groupid: return None while group.name == '': print "Group Name: ", group.name = raw_input() print "mandatory packages, space separated:" pkg_input = raw_input() for pkg in pkg_input.split(): group.mandatory_packages[pkg]=1 print "default packages, space separated:" pkg_input = raw_input() for pkg in pkg_input.split(): group.default_packages[pkg]=1 print "optional packages, space separated:" pkg_input = raw_input() for pkg in pkg_input.split(): group.optional_packages[pkg]=1 return group def main(): my_comps = yum.comps.Comps() while True: thisgroup = get_group_info() if thisgroup is None: print "ending group addition" break if hasattr(my_comps, 'add_group'): my_comps.add_group(thisgroup) else: if my_comps._groups.has_key(group.groupid): thatgroup = my_comps._groups[group.groupid] thatgroup.add(group) else: my_comps._groups[group.groupid] = group if len(my_comps_groups.keys()) > 0: print my_comps.xml() else: print "No groups added to comps, nothing to do" # parse args... # prompt for input for whatever is remaining if __name__ == "__main__": main()