示例#1
0
    def testGetInstallRoot(self):
        expected = '/sdk/root/toolchain/linux_x86_newlib/x86_64-nacl/usr'
        self.assertEqual(util.GetInstallRoot(Configuration()), expected)

        expected = '/sdk/root/toolchain/linux_pnacl/le32-nacl/usr'
        self.assertEqual(util.GetInstallRoot(Configuration('pnacl')), expected)

        expected = '/emscripten/root/system/local'
        self.assertEqual(util.GetInstallRoot(Configuration('emscripten')),
                         expected)

        expected = '/sdk/root/toolchain/linux_pnacl/x86_64-nacl/usr'
        self.assertEqual(
            util.GetInstallRoot(Configuration(toolchain='clang-newlib')),
            expected)
示例#2
0
def CmdPkgContents(package, options):
    """List contents of an installed package"""
    install_root = util.GetInstallRoot(package.config)
    for filename in package.Files():
        if util.log_level > util.LOG_INFO:
            filename = os.path.join(install_root, filename)
        if options.all:
            filename = package.NAME + ': ' + filename
        sys.stdout.write(filename + '\n')
示例#3
0
def CleanAll(config):
    """Remove all build directories and all pre-built packages as well
  as all installed packages for the given configuration."""
    def rmtree(path):
        util.Log('removing %s' % path)
        util.RemoveTree(path)

    rmtree(paths.STAMP_DIR)
    rmtree(paths.BUILD_ROOT)
    rmtree(paths.PUBLISH_ROOT)
    rmtree(paths.PACKAGES_ROOT)
    rmtree(util.GetInstallStampRoot(config))
    rmtree(util.GetInstallRoot(config))
示例#4
0
    def _InstallFiles(self, force):
        dest = util.GetInstallRoot(self.config)
        dest_tmp = os.path.join(dest, 'install_tmp')
        if os.path.exists(dest_tmp):
            shutil.rmtree(dest_tmp)

        if self.IsAnyVersionInstalled():
            raise error.Error('package already installed: %s' %
                              self.InfoString())

        self.LogStatus('Installing')
        util.LogVerbose('installing from: %s' % self.filename)
        util.Makedirs(dest_tmp)

        names = []
        try:
            with tarfile.open(self.filename) as tar:
                for info in tar:
                    if info.isdir():
                        continue
                    name = posixpath.normpath(info.name)
                    if name == 'pkg_info':
                        continue
                    if not name.startswith(PAYLOAD_DIR + '/'):
                        raise error.PkgFormatError(
                            'invalid file in package: %s' % name)

                    name = name[len(PAYLOAD_DIR) + 1:]
                    names.append(name)

                if not force:
                    for name in names:
                        full_name = os.path.join(dest, name)
                        if os.path.exists(full_name):
                            raise error.Error('file already exists: %s' %
                                              full_name)

                tar.extractall(dest_tmp)
                payload_tree = os.path.join(dest_tmp, PAYLOAD_DIR)

                names = FilterOutExecutables(names, payload_tree)

                for name in names:
                    InstallFile(name, payload_tree, dest)
        finally:
            shutil.rmtree(dest_tmp)

        for name in names:
            RelocateFile(name, dest)

        self.WriteFileList(names)
示例#5
0
    def DoUninstall(self):
        with util.InstallLock(self.config):
            RemoveFile(self.GetInstallStamp())

            root = util.GetInstallRoot(self.config)
            for filename in self.Files():
                filename = os.path.join(root, filename)
                if not os.path.lexists(filename):
                    Warn('File not found while uninstalling: %s' % filename)
                    continue
                Trace('rm %s' % filename)
                RemoveFile(filename)

            RemoveFile(self.GetListFile())
示例#6
0
  def DoUninstall(self, force):
    with util.InstallLock(self.config):
      if not force:
        for pkg in InstalledPackageIterator(self.config):
          if self.NAME in pkg.DEPENDS:
            raise error.Error("Unable to uninstall '%s' (depended on by '%s')" %
                (self.NAME, pkg.NAME))
      RemoveFile(self.GetInstallStamp())

      root = util.GetInstallRoot(self.config)
      for filename in self.Files():
        fullname = os.path.join(root, filename)
        if not os.path.lexists(fullname):
          util.Warn('File not found while uninstalling: %s' % fullname)
          continue
        util.LogVerbose('uninstall: %s' % filename)
        RemoveFile(fullname)

      if os.path.exists(self.GetListFile()):
        RemoveFile(self.GetListFile())
示例#7
0
    def testGetInstallRoot(self):
        expected = '/sdk/root/toolchain/linux_x86_newlib/x86_64-nacl/usr'
        self.assertEqual(util.GetInstallRoot(Configuration()), expected)

        expected = '/sdk/root/toolchain/linux_pnacl/usr/local'
        self.assertEqual(util.GetInstallRoot(Configuration('pnacl')), expected)