def copy(self): """ Copy files from source to staging Only files that are included by the configuration yaml file (in the ``files:`` section) are copied. * Symlinks are turned into relative symlinks * File modification times are preserved * File are searched for hardcoded paths and any matches are is recorded. * Directories are recreated, even if empty """ shutil.rmtree(self.root, ignore_errors=True) mkdir_p(self.root) marker = self.source.encode('utf-8') for src in self.package_config.files(): assert src.startswith(self.source) relative = src[len(self.source) + 1:] assert not os.path.isabs(relative) dst = os.path.join(self.staging, self.config.name, relative) if os.path.islink(src): log.debug('Symlink {0}'.format(relative)) mkdir_p(os.path.dirname(dst)) linkto = os.readlink(src) if not os.path.isabs(linkto): # make linkto absolute path linkto = os.path.join(os.path.dirname(src), linkto) relative_dir = os.path.relpath(os.path.dirname(linkto), os.path.dirname(src)) relative_file = os.path.join(relative_dir, os.path.basename(linkto)) os.symlink(relative_file, dst) elif os.path.isdir(src): log.debug('Directory {0}'.format(relative)) mkdir_p(dst) self.copy_mtime(src, dst) elif os.path.isfile(src): f = InstallFile(src, dst) f.copy() if self.package_config.rewrite_path_filter.match( relative) == True: log.debug('Copying {0}, checking path'.format(relative)) patch = f.find_patch(marker) if patch: self._patch[relative] = patch else: log.debug('Copying {0}, ignoring path'.format(relative)) self.copy_mtime(src, dst) else: raise ValueError( '{0} is not a file, symlink, or directory'.format( relative)) self.print_patch_summary() return self
def copy(self): """ Copy files from source to staging Only files that are included by the configuration yaml file (in the ``files:`` section) are copied. * Symlinks are turned into relative symlinks * File modification times are preserved * File are searched for hardcoded paths and any matches are is recorded. * Directories are recreated, even if empty """ shutil.rmtree(self.root, ignore_errors=True) mkdir_p(self.root) marker = self.source.encode('utf-8') for src in self.package_config.files(): assert src.startswith(self.source) relative = src[len(self.source)+1:] assert not os.path.isabs(relative) dst = os.path.join(self.staging, self.config.name, relative) if os.path.islink(src): log.debug('Symlink {0}'.format(relative)) mkdir_p(os.path.dirname(dst)) linkto = os.readlink(src) if not os.path.isabs(linkto): # make linkto absolute path linkto = os.path.join(os.path.dirname(src), linkto) relative_dir = os.path.relpath( os.path.dirname(linkto), os.path.dirname(src) ) relative_file = os.path.join(relative_dir, os.path.basename(linkto)) os.symlink(relative_file, dst) elif os.path.isdir(src): log.debug('Directory {0}'.format(relative)) mkdir_p(dst) self.copy_mtime(src, dst) elif os.path.isfile(src): f = InstallFile(src, dst) f.copy() if self.package_config.rewrite_path_filter.match(relative) == True: log.debug('Copying {0}, checking path'.format(relative)) patch = f.find_patch(marker) if patch: self._patch[relative] = patch else: log.debug('Copying {0}, ignoring path'.format(relative)) self.copy_mtime(src, dst) else: raise ValueError('{0} is not a file, symlink, or directory'.format(relative)) self.print_patch_summary() return self
def staging_path(self): name = filename_escape(self.name) path = os.path.join(self._config.root_path, 'staging', name) mkdir_p(path) return os.path.realpath(path)
def tmp_path(self): path = os.path.join(self.root_path, 'tmp', filename_escape(self.name)) mkdir_p(path) return os.path.realpath(path)
def source_path(self): path = make_path(self.root_path, 'source', filename_escape(self.name)) mkdir_p(path) return os.path.realpath(path)
def dist_path(self): path = os.path.join(self.root_path, 'dist') mkdir_p(path) return os.path.realpath(path)