parameters: (self, package_paths)
docstring: Installs a package and it's dependencies on the device. If the package is
      already installed then it will be updated to the new version.
  
      package_paths: Paths to the .far files to install.
docstring_summary: Installs a package and it's dependencies on the device. If the package is
      already installed then it will be updated to the new version.
docstring_tokens: Installs a package and it s dependencies on the device . If the package is already installed then it will be updated to the new version .
function: def InstallPackage(self, package_paths):
      """Installs a package and it's dependencies on the device. If the package is
      already installed then it will be updated to the new version.
  
      package_paths: Paths to the .far files to install.
      """
      with self.GetPkgRepo() as pkg_repo:
        # Publish all packages to the serving TUF repository under |tuf_root|.
        for package_path in package_paths:
          pkg_repo.PublishPackage(package_path)
  
        # Resolve all packages, to have them pulled into the device/VM cache.
        for package_path in package_paths:
          package_name, package_version = _GetPackageInfo(package_path)
          logging.info('Installing %s...', package_name)
          return_code = self.RunCommand(
              ['pkgctl', 'resolve',
               _GetPackageUri(package_name), '>/dev/null'],
              timeout_secs=_INSTALL_TIMEOUT_SECS)
          if return_code != 0:
            raise Exception(
                'Error {} while resolving {}.'.format(return_code, package_name))
  
        # Verify that the newly resolved versions of packages are reported.
        for package_path in package_paths:
          # Use pkgctl get-hash to determine which version will be resolved.
          package_name, package_version = _GetPackageInfo(package_path)
          pkgctl = self.RunCommandPiped(
              ['pkgctl', 'get-hash',
               _GetPackageUri(package_name)],
              stdout=subprocess.PIPE,
              stderr=subprocess.PIPE)
          pkgctl_out, pkgctl_err = pkgctl.communicate()
  
          # Read the expected version from the meta.far Merkel hash file alongside
          # the package's FAR.
          meta_far_path = os.path.join(os.path.dirname(package_path), 'meta.far')
          meta_far_merkel = subprocess.check_output(
              [common.GetHostToolPathFromPlatform('merkleroot'),
               meta_far_path]).split()[0]
          if pkgctl_out != meta_far_merkel:
            raise Exception('Hash mismatch for %s after resolve (%s vs %s).' %
                            (package_name, pkgctl_out, meta_far_merkel))
function_tokens: def InstallPackage ( self , package_paths ) : with self . GetPkgRepo ( ) as pkg_repo : # Publish all packages to the serving TUF repository under |tuf_root|. for package_path in package_paths : pkg_repo . PublishPackage ( package_path ) # Resolve all packages, to have them pulled into the device/VM cache. for package_path in package_paths : package_name , package_version = _GetPackageInfo ( package_path ) logging . info ( 'Installing %s...' , package_name ) return_code = self . RunCommand ( [ 'pkgctl' , 'resolve' , _GetPackageUri ( package_name ) , '>/dev/null' ] , timeout_secs = _INSTALL_TIMEOUT_SECS ) if return_code != 0 : raise Exception ( 'Error {} while resolving {}.' . format ( return_code , package_name ) ) # Verify that the newly resolved versions of packages are reported. for package_path in package_paths : # Use pkgctl get-hash to determine which version will be resolved. package_name , package_version = _GetPackageInfo ( package_path ) pkgctl = self . RunCommandPiped ( [ 'pkgctl' , 'get-hash' , _GetPackageUri ( package_name ) ] , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) pkgctl_out , pkgctl_err = pkgctl . communicate ( ) # Read the expected version from the meta.far Merkel hash file alongside # the package's FAR. meta_far_path = os . path . join ( os . path . dirname ( package_path ) , 'meta.far' ) meta_far_merkel = subprocess . check_output ( [ common . GetHostToolPathFromPlatform ( 'merkleroot' ) , meta_far_path ] ) . split ( ) [ 0 ] if pkgctl_out != meta_far_merkel : raise Exception ( 'Hash mismatch for %s after resolve (%s vs %s).' % ( package_name , pkgctl_out , meta_far_merkel ) )