docs: def install(name=None,
              refresh=False,
              fromrepo=None,
              pkgs=None,
              sources=None,
              **kwargs):
      '''
      Install package(s) using ``pkg_add(1)``
  
      name
          The name of the package to be installed.
  
      refresh
          Whether or not to refresh the package database before installing.
  
      fromrepo or packageroot
          Specify a package repository from which to install. Overrides the
          system default, as well as the PACKAGEROOT environment variable.
  
      packagesite
          Specify the exact directory from which to install the remote package.
          Overrides the PACKAGESITE environment variable, if present.
  
  
      Multiple Package Installation Options:
  
      pkgs
          A list of packages to install from a software repository. Must be
          passed as a python list.
  
          CLI Example:
  
          .. code-block:: bash
  
              salt '*' pkg.install pkgs='["foo", "bar"]'
  
      sources
          A list of packages to install. Must be passed as a list of dicts,
          with the keys being package names, and the values being the source URI
          or local path to the package.
  
          CLI Example:
  
          .. code-block:: bash
  
              salt '*' pkg.install sources='[{"foo": "salt://foo.deb"}, {"bar": "salt://bar.deb"}]'
  
      Return a dict containing the new package names and versions::
  
          {'<package>': {'old': '<old-version>',
                         'new': '<new-version>'}}
  
      CLI Example:
  
      .. code-block:: bash
  
          salt '*' pkg.install <package name>
      '''
      try:
          pkg_params, pkg_type = __salt__['pkg_resource.parse_targets'](
              name, pkgs, sources, **kwargs
          )
      except MinionError as exc:
          raise CommandExecutionError(exc)
  
      if not pkg_params:
          return {}
  
      packageroot = kwargs.get('packageroot')
      if not fromrepo and packageroot:
          fromrepo = packageroot
  
      env = _get_repo_options(fromrepo, kwargs.get('packagesite'))
      args = []
  
      if pkg_type == 'repository':
          args.append('-r')  # use remote repo
  
      args.extend(pkg_params)
  
      old = list_pkgs()
      out = __salt__['cmd.run_all'](
          ['pkg_add'] + args,
          env=env,
          output_loglevel='trace',
          python_shell=False
      )
      if out['retcode'] != 0 and out['stderr']:
          errors = [out['stderr']]
      else:
          errors = []
  
      __context__.pop('pkg.list_pkgs', None)
      new = list_pkgs()
      _rehash()
      ret = salt.utils.data.compare_dicts(old, new)
  
      if errors:
          raise CommandExecutionError(
              'Problem encountered installing package(s)',
              info={'errors': errors, 'changes': ret}
          )
  
      return ret