Exemplo n.º 1
0
    def Install(self, build_deps, force=None, from_source=False):
        self.CheckInstallable()

        if force is None and self.IsInstalled():
            self.LogStatus('Already installed')
            return

        if build_deps:
            self.InstallDeps(force, from_source)

        if force:
            from_source = True

        package_file = self.PackageFile()
        if not self.IsBuilt() and not from_source:
            index = package_index.GetCurrentIndex()
            if index.Installable(self.NAME, self.config):
                package_file = index.Download(self.NAME, self.config)
            else:
                from_source = True

        if from_source:
            self.Build(build_deps, force)

        if self.IsAnyVersionInstalled():
            installed_pkg = self.GetInstalledPackage()
            installed_pkg.LogStatus('Uninstalling existing')
            installed_pkg.DoUninstall(force=True)

        binary_package.BinaryPackage(package_file).Install(force)
Exemplo n.º 2
0
    def install(self, build_deps, force=None, from_source=False):
        self.check_installable()

        if force is None and self.is_installed():
            self.log_status('Already installed')
            return

        if build_deps:
            self.install_deps(force, from_source)

        if force:
            from_source = True

        package_file = self.package_file()
        if not self.is_built() and not from_source:
            index = package_index.get_current_index()
            if index.installable(self.NAME, self.config):
                package_file = index.download(self.NAME, self.config)
            else:
                from_source = True

        if from_source:
            self.build(build_deps, force)

        if self.is_any_version_installed():
            installed_pkg = self.get_installed_package()
            installed_pkg.log_status('Uninstalling existing')
            installed_pkg.do_uninstall(force=True)

        binary_package.BinaryPackage(package_file).install(force)
Exemplo n.º 3
0
 def IsBuilt(self):
     package_file = self.PackageFile()
     if not os.path.exists(package_file):
         return False
     try:
         pkg = binary_package.BinaryPackage(package_file)
     except PkgFormatError:
         # If the package is malformed in some way or in some old format
         # then treat it as not built.
         return False
     return pkg.IsInstallable()
Exemplo n.º 4
0
 def test_write_stamp(self, mock_get_info):
   fake_binary_pkg_info = textwrap.dedent('''\
     NAME=foo
     VERSION=1.0
     BUILD_CONFIG=release
     BUILD_ARCH=arm
     BUILD_TOOLCHAIN=glibc
     BUILD_SDK_VERSION=38
     BUILD_NACLPORTS_REVISION=1414
     ''')
   mock_get_info.return_value = fake_binary_pkg_info
   pkg = binary_package.BinaryPackage('foo')
   mock_stamp_file = common.mock_file_object()
   with patch('__builtin__.open', Mock(return_value=mock_stamp_file),
              create=True):
     pkg.write_stamp()
   mock_stamp_file.write.assert_called_once_with(fake_binary_pkg_info)
Exemplo n.º 5
0
def extract_pkg_info(filename):
  """Return the pkg_info contents from a binary package."""
  pkg = binary_package.BinaryPackage(filename)
  return pkg.get_pkg_info()
Exemplo n.º 6
0
def ExtractPkgInfo(filename):
  """Return the pkg_info contents from a binary package."""
  pkg = binary_package.BinaryPackage(filename)
  return pkg.GetPkgInfo()