.. versionadded:: 2016.11.0

    Lists all packages in the specified group

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.group_info 'xorg'

def group_info(name):
    '''
    .. versionadded:: 2016.11.0

    Lists all packages in the specified group

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.group_info 'xorg'
    '''

    pkgtypes = ('mandatory', 'optional', 'default', 'conditional')
    ret = {}
    for pkgtype in pkgtypes:
        ret[pkgtype] = set()

    cmd = ['pacman', '-Sgg', name]
    out = __salt__['cmd.run'](cmd, output_loglevel='trace', python_shell=False)

    for line in salt.utils.itertools.split(out, '\n'):
        if not line:
            continue
        try:
            pkg = line.split()[1]
        except ValueError:
            log.error('Problem parsing pacman -Sgg: Unexpected formatting in '
                      'line: \'%s\'', line)
        else:
            ret['default'].add(pkg)

    for pkgtype in pkgtypes:
        ret[pkgtype] = sorted(ret[pkgtype])

    return ret