Install packages using the pkgutil tool.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.install <package_name>
        salt '*' pkg.install SMClgcc346


    Multiple Package Installation Options:

    pkgs
        A list of packages to install from OpenCSW. Must be passed as a python
        list.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install pkgs='["foo", "bar"]'
            salt '*' pkg.install pkgs='["foo", {"bar": "1.2.3"}]'


    Returns a dict containing the new package names and versions::

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}

def install(name=None, refresh=False, version=None, pkgs=None, **kwargs):
    '''
    Install packages using the pkgutil tool.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.install <package_name>
        salt '*' pkg.install SMClgcc346


    Multiple Package Installation Options:

    pkgs
        A list of packages to install from OpenCSW. Must be passed as a python
        list.

        CLI Example:

        .. code-block:: bash

            salt '*' pkg.install pkgs='["foo", "bar"]'
            salt '*' pkg.install pkgs='["foo", {"bar": "1.2.3"}]'


    Returns a dict containing the new package names and versions::

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}
    '''
    if refresh:
        refresh_db()

    try:
        # Ignore 'sources' argument
        pkg_params = __salt__['pkg_resource.parse_targets'](name,
                                                            pkgs,
                                                            **kwargs)[0]
    except MinionError as exc:
        raise CommandExecutionError(exc)

    if not pkg_params:
        return {}

    if pkgs is None and version and len(pkg_params) == 1:
        pkg_params = {name: version}
    targets = []
    for param, pkgver in six.iteritems(pkg_params):
        if pkgver is None:
            targets.append(param)
        else:
            targets.append('{0}-{1}'.format(param, pkgver))

    cmd = '/opt/csw/bin/pkgutil -yu {0}'.format(' '.join(targets))
    old = list_pkgs()
    __salt__['cmd.run_all'](cmd)
    __context__.pop('pkg.list_pkgs', None)
    new = list_pkgs()
    return salt.utils.data.compare_dicts(old, new)