.. versionadded:: 2018.3.0

    List package provides of installed packages as a dict.
    {'<provided_name>': ['<package_name>', '<package_name>', ...]}

    root
        operate on a different root directory.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.list_provides

def list_provides(root=None, **kwargs):
    '''
    .. versionadded:: 2018.3.0

    List package provides of installed packages as a dict.
    {'<provided_name>': ['<package_name>', '<package_name>', ...]}

    root
        operate on a different root directory.

    CLI Examples:

    .. code-block:: bash

        salt '*' pkg.list_provides
    '''
    ret = __context__.get('pkg.list_provides')
    if not ret:
        cmd = ['rpm']
        if root:
            cmd.extend(['--root', root])
        cmd.extend(['-qa', '--queryformat', '%{PROVIDES}_|-%{NAME}\n'])
        ret = dict()
        for line in __salt__['cmd.run'](cmd, output_loglevel='trace', python_shell=False).splitlines():
            provide, realname = line.split('_|-')

            if provide == realname:
                continue
            if provide not in ret:
                ret[provide] = list()
            ret[provide].append(realname)

        __context__['pkg.list_provides'] = ret

    return ret