示例#1
0
    def clean(self):
        pkg = self.package_file()
        log('removing %s' % pkg)
        if os.path.exists(pkg):
            os.remove(pkg)

        stamp_dir = os.path.join(paths.STAMP_DIR, self.NAME)
        log('removing %s' % stamp_dir)
        util.remove_tree(stamp_dir)
示例#2
0
  def clean(self):
    pkg = self.package_file()
    log('removing %s' % pkg)
    if os.path.exists(pkg):
      os.remove(pkg)

    stamp_dir = os.path.join(paths.STAMP_DIR, self.NAME)
    log('removing %s' % stamp_dir)
    util.remove_tree(stamp_dir)
示例#3
0
    def extract(self):
        """Extract the package archive into its build location.

    This method assumes the package has already been downloaded.
    """
        if self.is_git_upstream():
            self.git_clone()
            return

        archive = self.download_location()
        if not archive:
            self.log('Skipping extract; No upstream archive')
            return

        dest = self.get_build_location()
        output_path, new_foldername = os.path.split(dest)
        util.makedirs(output_path)

        # Check existing stamp file contents
        stamp_file = self.get_extract_stamp()
        stamp_contents = self.get_extract_stamp_content()
        if os.path.exists(dest):
            if stamp_contents_match(stamp_file, stamp_contents):
                log('Already up-to-date: %s' % util.rel_path(dest))
                return

            raise Error("Upstream archive or patch has changed.\n" +
                        "Please remove existing checkout and try again: '%s'" %
                        dest)

        util.log_heading('Extracting')
        util.makedirs(paths.OUT_DIR)
        tmp_output_path = tempfile.mkdtemp(dir=paths.OUT_DIR)
        try:
            extract_archive(archive, tmp_output_path)
            src = os.path.join(tmp_output_path, new_foldername)
            if not os.path.isdir(src):
                raise Error('Archive contents not found: %s' % src)
            log_verbose("renaming '%s' -> '%s'" % (src, dest))
            os.rename(src, dest)
        finally:
            util.remove_tree(tmp_output_path)

        self.remove_stamps()
        write_stamp(stamp_file, stamp_contents)
示例#4
0
  def extract(self):
    """Extract the package archive into its build location.

    This method assumes the package has already been downloaded.
    """
    if self.is_git_upstream():
      self.git_clone()
      return

    archive = self.download_location()
    if not archive:
      self.log('Skipping extract; No upstream archive')
      return

    dest = self.get_build_location()
    output_path, new_foldername = os.path.split(dest)
    util.makedirs(output_path)

    # Check existing stamp file contents
    stamp_file = self.get_extract_stamp()
    stamp_contents = self.get_extract_stamp_content()
    if os.path.exists(dest):
      if stamp_contents_match(stamp_file, stamp_contents):
        log('Already up-to-date: %s' % util.rel_path(dest))
        return

      raise Error("Upstream archive or patch has changed.\n" +
                  "Please remove existing checkout and try again: '%s'" % dest)

    util.log_heading('Extracting')
    util.makedirs(paths.OUT_DIR)
    tmp_output_path = tempfile.mkdtemp(dir=paths.OUT_DIR)
    try:
      extract_archive(archive, tmp_output_path)
      src = os.path.join(tmp_output_path, new_foldername)
      if not os.path.isdir(src):
        raise Error('Archive contents not found: %s' % src)
      log_verbose("renaming '%s' -> '%s'" % (src, dest))
      os.rename(src, dest)
    finally:
      util.remove_tree(tmp_output_path)

    self.remove_stamps()
    write_stamp(stamp_file, stamp_contents)
示例#5
0
def init_git_repo(directory):
    """Initialize the source git repository for a given package directory.

  This function works for unpacked tar files as well as cloned git
  repositories.  It sets up an 'upstream' branch pointing and the
  pristine upstream sources and a 'master' branch will contain changes
  specific to webports (normally the result of applying nacl.patch).

  Args:
    directory: Directory containing unpacked package sources.
  """
    git_dir = os.path.join(directory, '.git')

    # If the upstream ref exists then we've already initialized this repo
    if os.path.exists(os.path.join(git_dir, 'refs', 'heads', 'upstream')):
        return

    if os.path.exists(git_dir):
        log('Init existing git repo: %s' % directory)
        run_git_cmd(directory, ['checkout', '-b', 'placeholder'])
        run_git_cmd(directory, ['branch', '-D', 'upstream'], error_ok=True)
        run_git_cmd(directory, ['branch', '-D', 'master'], error_ok=True)
        run_git_cmd(directory, ['checkout', '-b', 'upstream'])
        run_git_cmd(directory, ['checkout', '-b', 'master'])
        run_git_cmd(directory, ['branch', '-D', 'placeholder'])
    else:
        log('Init new git repo: %s' % directory)
        run_git_cmd(directory, ['init'])
        try:
            # Setup a bogus identity on the buildbots.
            if os.environ.get('BUILDBOT_BUILDERNAME'):
                run_git_cmd(directory, ['config', 'user.name', 'Naclports'])
                run_git_cmd(directory,
                            ['config', 'user.email', '*****@*****.**'])
            run_git_cmd(directory, ['add', '-f', '.'])
            run_git_cmd(directory, ['commit', '-m', 'Upstream version'])
            run_git_cmd(directory, ['checkout', '-b', 'upstream'])
            run_git_cmd(directory, ['checkout', 'master'])
        except:  # pylint: disable=bare-except
            # If git setup fails or is interrupted then remove the partially
            # initialized repository.
            util.remove_tree(os.path.join(git_dir))
示例#6
0
def init_git_repo(directory):
  """Initialize the source git repository for a given package directory.

  This function works for unpacked tar files as well as cloned git
  repositories.  It sets up an 'upstream' branch pointing and the
  pristine upstream sources and a 'master' branch will contain changes
  specific to webports (normally the result of applying nacl.patch).

  Args:
    directory: Directory containing unpacked package sources.
  """
  git_dir = os.path.join(directory, '.git')

  # If the upstream ref exists then we've already initialized this repo
  if os.path.exists(os.path.join(git_dir, 'refs', 'heads', 'upstream')):
    return

  if os.path.exists(git_dir):
    log('Init existing git repo: %s' % directory)
    run_git_cmd(directory, ['checkout', '-b', 'placeholder'])
    run_git_cmd(directory, ['branch', '-D', 'upstream'], error_ok=True)
    run_git_cmd(directory, ['branch', '-D', 'master'], error_ok=True)
    run_git_cmd(directory, ['checkout', '-b', 'upstream'])
    run_git_cmd(directory, ['checkout', '-b', 'master'])
    run_git_cmd(directory, ['branch', '-D', 'placeholder'])
  else:
    log('Init new git repo: %s' % directory)
    run_git_cmd(directory, ['init'])
    try:
      # Setup a bogus identity on the buildbots.
      if os.environ.get('BUILDBOT_BUILDERNAME'):
        run_git_cmd(directory, ['config', 'user.name', 'Naclports'])
        run_git_cmd(directory, ['config', 'user.email', '*****@*****.**'])
      run_git_cmd(directory, ['add', '-f', '.'])
      run_git_cmd(directory, ['commit', '-m', 'Upstream version'])
      run_git_cmd(directory, ['checkout', '-b', 'upstream'])
      run_git_cmd(directory, ['checkout', 'master'])
    except:  # pylint: disable=bare-except
      # If git setup fails or is interrupted then remove the partially
      # initialized repository.
      util.remove_tree(os.path.join(git_dir))
示例#7
0
 def remove_stamps(self):
     util.remove_tree(self.get_stamp_dir())
示例#8
0
 def rmtree(path):
     util.log('removing %s' % path)
     util.remove_tree(path)
示例#9
0
 def rmtree(path):
   util.log('removing %s' % path)
   util.remove_tree(path)
示例#10
0
 def remove_stamps(self):
   util.remove_tree(self.get_stamp_dir())