chrome/updater/win/installer/create_installer_archive.py
def CreateArchiveFile(options, staging_dir, timestamp):
  """Creates a new installer archive file after deleting any existing old file.
  """
  # First create an uncompressed archive file for the current build (updater.7z)
  lzma_exec = GetLZMAExec(options.build_dir)
  archive_file = os.path.join(options.output_dir,
                              options.output_name + ARCHIVE_SUFFIX)

  if options.depfile:
    # If a depfile was requested, do the glob of the staging dir and generate
    # a list of dependencies in .d format. We list the files that were copied
    # into the staging dir, not the files that are actually in the staging dir
    # because the ones in the staging dir will never be edited, and we want
    # to have the build be triggered when the thing-that-was-copied-there
    # changes.

    def PathFixup(path):
      """Fixes path for depfile format: backslash to forward slash, and
      backslash escaping for spaces."""
      return path.replace('\\', '/').replace(' ', '\\ ')

    # Gather the list of files in the staging dir that will be zipped up. We
    # only gather this list to make sure that g_archive_inputs is complete (i.e.
    # that there's not file copies that got missed).
    staging_contents = []
    for root, files in os.walk(os.path.join(staging_dir, UPDATER_DIR)):
      for filename in files:
        staging_contents.append(PathFixup(os.path.join(root, filename)))

    # Make sure there's an archive_input for each staging dir file.
    for staging_file in staging_contents:
      for archive_input in g_archive_inputs:
        archive_rel = PathFixup(archive_input)
        if (os.path.basename(staging_file).lower() ==
            os.path.basename(archive_rel).lower()):
          break
      else:
        raise Exception('Did not find an archive input file for "%s"' %
                        staging_file)

    # Finally, write the depfile referencing the inputs.
    with open(options.depfile, 'wb') as f:
      f.write(PathFixup(os.path.relpath(archive_file, options.build_dir)) +
              ': \\\n')
      f.write('  ' + ' \\\n  '.join(PathFixup(x) for x in g_archive_inputs))

  # It is important to use abspath to create the path to the directory because
  # if you use a relative path without any .. sequences then 7za.exe uses the
  # entire relative path as part of the file paths in the archive. If you have
  # a .. sequence or an absolute path then only the last directory is stored as
  # part of the file paths in the archive, which is what we want.
  cmd = [lzma_exec,
         'a',
         '-t7z',
         archive_file,
         os.path.abspath(os.path.join(staging_dir, UPDATER_DIR)),
         '-mx0',]
  # There does not seem to be any way in 7za.exe to override existing file so
  # we always delete before creating a new one.
  if not os.path.exists(archive_file):
    RunSystemCommand(cmd, options.verbose)
  elif options.skip_rebuild_archive != "true":
    os.remove(archive_file)
    RunSystemCommand(cmd, options.verbose)

  # Do not compress the archive when skip_archive_compression is specified.
  if options.skip_archive_compression:
    compressed_file = os.path.join(
        options.output_dir, options.output_name + COMPRESSED_ARCHIVE_SUFFIX)
    if os.path.exists(compressed_file):
      os.remove(compressed_file)
    return os.path.basename(archive_file)

  compressed_archive_file = options.output_name + COMPRESSED_ARCHIVE_SUFFIX
  compressed_archive_file_path = os.path.join(options.output_dir,
                                              compressed_archive_file)
  os.utime(archive_file, (os.stat(archive_file).st_atime, timestamp))
  CompressUsingLZMA(options.build_dir, compressed_archive_file_path,
                    archive_file, options.verbose)

  return compressed_archive_file
Creates a new installer archive file after deleting any existing old file.
  
Creates a new installer archive file after deleting any existing old file.
Creates a new installer archive file after deleting any existing old file .
def CreateArchiveFile(options, staging_dir, timestamp):
  lzma_exec = GetLZMAExec(options.build_dir)
  archive_file = os.path.join(options.output_dir,
                              options.output_name + ARCHIVE_SUFFIX)
  if options.depfile:
    def PathFixup(path):
      return path.replace('\\', '/').replace(' ', '\\ ')
    staging_contents = []
    for root, files in os.walk(os.path.join(staging_dir, UPDATER_DIR)):
      for filename in files:
        staging_contents.append(PathFixup(os.path.join(root, filename)))
    for staging_file in staging_contents:
      for archive_input in g_archive_inputs:
        archive_rel = PathFixup(archive_input)
        if (os.path.basename(staging_file).lower() ==
            os.path.basename(archive_rel).lower()):
          break
      else:
        raise Exception('Did not find an archive input file for "%s"' %
                        staging_file)
    with open(options.depfile, 'wb') as f:
      f.write(PathFixup(os.path.relpath(archive_file, options.build_dir)) +
              ': \\\n')
      f.write('  ' + ' \\\n  '.join(PathFixup(x) for x in g_archive_inputs))
  cmd = [lzma_exec,
         'a',
         '-t7z',
         archive_file,
         os.path.abspath(os.path.join(staging_dir, UPDATER_DIR)),
         '-mx0',]
  if not os.path.exists(archive_file):
    RunSystemCommand(cmd, options.verbose)
  elif options.skip_rebuild_archive != "true":
    os.remove(archive_file)
    RunSystemCommand(cmd, options.verbose)
  if options.skip_archive_compression:
    compressed_file = os.path.join(
        options.output_dir, options.output_name + COMPRESSED_ARCHIVE_SUFFIX)
    if os.path.exists(compressed_file):
      os.remove(compressed_file)
    return os.path.basename(archive_file)
  compressed_archive_file = options.output_name + COMPRESSED_ARCHIVE_SUFFIX
  compressed_archive_file_path = os.path.join(options.output_dir,
                                              compressed_archive_file)
  os.utime(archive_file, (os.stat(archive_file).st_atime, timestamp))
  CompressUsingLZMA(options.build_dir, compressed_archive_file_path,
                    archive_file, options.verbose)
  return compressed_archive_file
def CreateArchiveFile ( options , staging_dir , timestamp ) : lzma_exec = GetLZMAExec ( options . build_dir ) archive_file = os . path . join ( options . output_dir , options . output_name + ARCHIVE_SUFFIX ) if options . depfile : def PathFixup ( path ) : """Fixes path for depfile format: backslash to forward slash, and
      backslash escaping for spaces.""" return path . replace ( '\\' , '/' ) . replace ( ' ' , '\\ ' ) staging_contents = [ ] for root , files in os . walk ( os . path . join ( staging_dir , UPDATER_DIR ) ) : for filename in files : staging_contents . append ( PathFixup ( os . path . join ( root , filename ) ) ) for staging_file in staging_contents : for archive_input in g_archive_inputs : archive_rel = PathFixup ( archive_input ) if ( os . path . basename ( staging_file ) . lower ( ) == os . path . basename ( archive_rel ) . lower ( ) ) : break else : raise Exception ( 'Did not find an archive input file for "%s"' % staging_file ) with open ( options . depfile , 'wb' ) as f : f . write ( PathFixup ( os . path . relpath ( archive_file , options . build_dir ) ) + ': \\\n' ) f . write ( '  ' + ' \\\n  ' . join ( PathFixup ( x ) for x in g_archive_inputs ) ) cmd = [ lzma_exec , 'a' , '-t7z' , archive_file , os . path . abspath ( os . path . join ( staging_dir , UPDATER_DIR ) ) , '-mx0' , ] if not os . path . exists ( archive_file ) : RunSystemCommand ( cmd , options . verbose ) elif options . skip_rebuild_archive != "true" : os . remove ( archive_file ) RunSystemCommand ( cmd , options . verbose ) if options . skip_archive_compression : compressed_file = os . path . join ( options . output_dir , options . output_name + COMPRESSED_ARCHIVE_SUFFIX ) if os . path . exists ( compressed_file ) : os . remove ( compressed_file ) return os . path . basename ( archive_file ) compressed_archive_file = options . output_name + COMPRESSED_ARCHIVE_SUFFIX compressed_archive_file_path = os . path . join ( options . output_dir , compressed_archive_file ) os . utime ( archive_file , ( os . stat ( archive_file ) . st_atime , timestamp ) ) CompressUsingLZMA ( options . build_dir , compressed_archive_file_path , archive_file , options . verbose ) return compressed_archive_file
Creates a new installer archive file after deleting any existing old file.
Creates a new installer archive file after deleting any existing old file .
"""Creates a new installer archive file after deleting any existing old file.
  """ # First create an uncompressed archive file for the current build (updater.7z) # If a depfile was requested, do the glob of the staging dir and generate # a list of dependencies in .d format. We list the files that were copied # into the staging dir, not the files that are actually in the staging dir # because the ones in the staging dir will never be edited, and we want # to have the build be triggered when the thing-that-was-copied-there # changes. """Fixes path for depfile format: backslash to forward slash, and
      backslash escaping for spaces.""" # Gather the list of files in the staging dir that will be zipped up. We # only gather this list to make sure that g_archive_inputs is complete (i.e. # that there's not file copies that got missed). # Make sure there's an archive_input for each staging dir file. # Finally, write the depfile referencing the inputs. # It is important to use abspath to create the path to the directory because # if you use a relative path without any .. sequences then 7za.exe uses the # entire relative path as part of the file paths in the archive. If you have # a .. sequence or an absolute path then only the last directory is stored as # part of the file paths in the archive, which is what we want. # There does not seem to be any way in 7za.exe to override existing file so # we always delete before creating a new one. # Do not compress the archive when skip_archive_compression is specified.
options
staging_dir
timestamp