remoting/host/installer/build-installer-archive.py
def remapSrcFile(dst_root, src_roots, src_file):
  """Calculates destination file path and creates directory.

  Any matching |src_roots| prefix is stripped from |src_file| before
  appending to |dst_root|.

  For example, given:
    dst_root = '/output'
    src_roots = ['host/installer/mac']
    src_file = 'host/installer/mac/Scripts/keystone_install.sh'
  The final calculated path is:
    '/output/Scripts/keystone_install.sh'

  The |src_file| must match one of the |src_roots| prefixes. If there are no
  matches, then an error is reported.

  If multiple |src_roots| match, then only the first match is applied. Because
  of this, if you have roots that share a common prefix, the longest string
  should be first in this array.

  Args:
    dst_root: Target directory where files are copied.
    src_roots: Array of path prefixes which will be stripped of |src_file|
               (if they match) before appending it to the |dst_root|.
    src_file: Source file to be copied.
  Returns:
    Full path to destination file in |dst_root|.
  """
  # Strip of directory prefix.
  found_root = False
  for root in src_roots:
    root = os.path.normpath(root)
    src_file = os.path.normpath(src_file)
    if os.path.commonprefix([root, src_file]) == root:
      src_file = os.path.relpath(src_file, root)
      found_root = True
      break

  if not found_root:
    error('Unable to match prefix for %s' % src_file)

  dst_file = os.path.join(dst_root, src_file)
  # Make sure target directory exists.
  dst_dir = os.path.dirname(dst_file)
  if not os.path.exists(dst_dir):
    os.makedirs(dst_dir, 0o775)
  return dst_file
Calculates destination file path and creates directory.

  Any matching |src_roots| prefix is stripped from |src_file| before
  appending to |dst_root|.

  For example, given:
    dst_root = '/output'
    src_roots = ['host/installer/mac']
    src_file = 'host/installer/mac/Scripts/keystone_install.sh'
  The final calculated path is:
    '/output/Scripts/keystone_install.sh'

  The |src_file| must match one of the |src_roots| prefixes. If there are no
  matches, then an error is reported.

  If multiple |src_roots| match, then only the first match is applied. Because
  of this, if you have roots that share a common prefix, the longest string
  should be first in this array.

  Args:
    dst_root: Target directory where files are copied.
    src_roots: Array of path prefixes which will be stripped of |src_file|
               (if they match) before appending it to the |dst_root|.
    src_file: Source file to be copied.
  Returns:
    Full path to destination file in |dst_root|.
  
Calculates destination file path and creates directory.



The |src_file| must match one of the |src_roots| prefixes. If there are no
matches, then an error is reported.

If multiple |src_roots| match, then only the first match is applied. Because
of this, if you have roots that share a common prefix, the longest string
should be first in this array.
Calculates destination file path and creates directory . The |src_file| must match one of the |src_roots| prefixes . If there are no matches then an error is reported . If multiple |src_roots| match then only the first match is applied . Because of this if you have roots that share a common prefix the longest string should be first in this array .
def remapSrcFile(dst_root, src_roots, src_file):
  found_root = False
  for root in src_roots:
    root = os.path.normpath(root)
    src_file = os.path.normpath(src_file)
    if os.path.commonprefix([root, src_file]) == root:
      src_file = os.path.relpath(src_file, root)
      found_root = True
      break
  if not found_root:
    error('Unable to match prefix for %s' % src_file)
  dst_file = os.path.join(dst_root, src_file)
  dst_dir = os.path.dirname(dst_file)
  if not os.path.exists(dst_dir):
    os.makedirs(dst_dir, 0o775)
  return dst_file
def remapSrcFile ( dst_root , src_roots , src_file ) : found_root = False for root in src_roots : root = os . path . normpath ( root ) src_file = os . path . normpath ( src_file ) if os . path . commonprefix ( [ root , src_file ] ) == root : src_file = os . path . relpath ( src_file , root ) found_root = True break if not found_root : error ( 'Unable to match prefix for %s' % src_file ) dst_file = os . path . join ( dst_root , src_file ) dst_dir = os . path . dirname ( dst_file ) if not os . path . exists ( dst_dir ) : os . makedirs ( dst_dir , 0o775 ) return dst_file
Calculates destination file path and creates directory.
Calculates destination file path and creates directory .
"""Calculates destination file path and creates directory.

  Any matching |src_roots| prefix is stripped from |src_file| before
  appending to |dst_root|.

  For example, given:
    dst_root = '/output'
    src_roots = ['host/installer/mac']
    src_file = 'host/installer/mac/Scripts/keystone_install.sh'
  The final calculated path is:
    '/output/Scripts/keystone_install.sh'

  The |src_file| must match one of the |src_roots| prefixes. If there are no
  matches, then an error is reported.

  If multiple |src_roots| match, then only the first match is applied. Because
  of this, if you have roots that share a common prefix, the longest string
  should be first in this array.

  Args:
    dst_root: Target directory where files are copied.
    src_roots: Array of path prefixes which will be stripped of |src_file|
               (if they match) before appending it to the |dst_root|.
    src_file: Source file to be copied.
  Returns:
    Full path to destination file in |dst_root|.
  """ # Strip of directory prefix. # Make sure target directory exists.
Full path to destination file in |dst_root|.
Full path to destination file in |dst_root| .
dst_root
Target directory where files are copied.
Target directory where files are copied .
src_roots
Array of path prefixes which will be stripped of |src_file|
(if they match) before appending it to the |dst_root|.
Array of path prefixes which will be stripped of |src_file| ( if they match ) before appending it to the |dst_root| .
src_file
Source file to be copied.
Source file to be copied .