Exemple #1
0
def cmd_pkg_contents(package, options):
    """List contents of an installed package"""
    install_root = util.get_install_root(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')
Exemple #2
0
def cmd_pkg_contents(package, options):
  """List contents of an installed package"""
  install_root = util.get_install_root(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')
Exemple #3
0
  def test_get_install_root(self):
    expected = '/sdk/root/toolchain/linux_pnacl/le32-nacl/usr'
    self.assertEqual(util.get_install_root(Configuration()), expected)

    expected = '/sdk/root/toolchain/linux_x86_glibc/x86_64-nacl/usr'
    self.assertEqual(util.get_install_root(Configuration(toolchain='glibc')),
                     expected)

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

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

    expected = '/sdk/root/toolchain/linux_pnacl/x86_64-nacl/usr'
    self.assertEqual(
        util.get_install_root(Configuration(toolchain='clang-newlib')),
        expected)
Exemple #4
0
def clean_all(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.remove_tree(path)

    rmtree(paths.STAMP_DIR)
    rmtree(paths.BUILD_ROOT)
    rmtree(paths.PUBLISH_ROOT)
    rmtree(paths.PACKAGES_ROOT)
    rmtree(util.get_install_stamp_root(config))
    rmtree(util.get_install_root(config))
Exemple #5
0
    def _install_files(self, force):
        dest = util.get_install_root(self.config)
        dest_tmp = os.path.join(dest, 'install_tmp')
        if os.path.exists(dest_tmp):
            shutil.rmtree(dest_tmp)

        if self.is_any_version_installed():
            raise error.Error('package already installed: %s' %
                              self.info_string())

        self.log_status('Installing')
        util.log_verbose('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 = filter_out_executables(names, payload_tree)

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

        for name in names:
            relocate_file(name, dest)

        self.write_file_list(names)
Exemple #6
0
def clean_all(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.remove_tree(path)

  rmtree(paths.STAMP_DIR)
  rmtree(paths.BUILD_ROOT)
  rmtree(paths.PUBLISH_ROOT)
  rmtree(paths.PACKAGES_ROOT)
  rmtree(util.get_install_stamp_root(config))
  rmtree(util.get_install_root(config))
Exemple #7
0
  def _install_files(self, force):
    dest = util.get_install_root(self.config)
    dest_tmp = os.path.join(dest, 'install_tmp')
    if os.path.exists(dest_tmp):
      shutil.rmtree(dest_tmp)

    if self.is_any_version_installed():
      raise error.Error('package already installed: %s' % self.info_string())

    self.log_status('Installing')
    util.log_verbose('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 = filter_out_executables(names, payload_tree)

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

    for name in names:
      relocate_file(name, dest)

    self.write_file_list(names)
Exemple #8
0
  def do_uninstall(self, force):
    with util.InstallLock(self.config):
      if not force:
        for pkg in installed_package_iterator(self.config):
          if self.NAME in pkg.DEPENDS:
            raise error.Error("Unable to uninstall '%s' (depended on by '%s')" %
                              (self.NAME, pkg.NAME))
      remove_file(self.get_install_stamp())

      root = util.get_install_root(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.log_verbose('uninstall: %s' % filename)
        remove_file(fullname)

      if os.path.exists(self.get_list_file()):
        remove_file(self.get_list_file())
Exemple #9
0
    def do_uninstall(self, force):
        with util.InstallLock(self.config):
            if not force:
                for pkg in installed_package_iterator(self.config):
                    if self.NAME in pkg.DEPENDS:
                        raise error.Error(
                            "Unable to uninstall '%s' (depended on by '%s')" %
                            (self.NAME, pkg.NAME))
            remove_file(self.get_install_stamp())

            root = util.get_install_root(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.log_verbose('uninstall: %s' % filename)
                remove_file(fullname)

            if os.path.exists(self.get_list_file()):
                remove_file(self.get_list_file())