def nsi_file_commands(self, install=True): def wpath(path): if path.endswith('/') or path.endswith(os.path.sep): path = path[:-1] path = path.replace('/', '\\') return path result = "" dest_files = [ pair[1] for pair in self.file_list if pair[0] and os.path.isfile(pair[1]) ] dest_files = list(set(dest_files)) # remove duplicates # sort deepest hierarchy first dest_files.sort(lambda a, b: cmp(a.count(os.path.sep), b.count(os.path.sep)) or cmp(a, b)) dest_files.reverse() out_path = None for pkg_file in dest_files: rel_file = os.path.normpath( pkg_file.replace(self.get_dst_prefix() + os.path.sep, '')) installed_dir = wpath( os.path.join('$INSTDIR', os.path.dirname(rel_file))) pkg_file = wpath( os.path.join(os.pardir, os.path.normpath(pkg_file))) if installed_dir != out_path: if install: out_path = installed_dir result += 'SetOutPath "' + out_path + '"\n' if install: result += 'File "' + pkg_file + '"\n' else: result += 'Delete "' + wpath(os.path.join( '$INSTDIR', rel_file)) + '"\n' # at the end of a delete, just rmdir all the directories if not install: deleted_file_dirs = [ os.path.dirname(pair[1].replace( self.get_dst_prefix() + os.path.sep, '')) for pair in self.file_list ] # find all ancestors so that we don't skip any dirs that happened to have no non-dir children deleted_dirs = [] for d in deleted_file_dirs: deleted_dirs.extend(path_ancestors(d)) # sort deepest hierarchy first deleted_dirs.sort(lambda a, b: cmp(a.count( os.path.sep), b.count(os.path.sep)) or cmp(a, b)) deleted_dirs.reverse() prev = None for d in deleted_dirs: if d != prev: # skip duplicates result += 'RMDir ' + wpath( os.path.join('$INSTDIR', os.path.normpath(d))) + '\n' prev = d return result
def nsi_file_commands(self, install=True): def wpath(path): if path.endswith('/') or path.endswith(os.path.sep): path = path[:-1] path = path.replace('/', '\\') return path result = "" dest_files = [ pair[1] for pair in self.file_list if pair[0] and os.path.isfile(pair[1]) ] # sort deepest hierarchy first dest_files.sort(lambda a,b: cmp(a.count(os.path.sep),b.count(os.path.sep)) or cmp(a,b)) dest_files.reverse() out_path = None for pkg_file in dest_files: rel_file = os.path.normpath( pkg_file.replace(self.get_dst_prefix() + os.path.sep, '')) installed_dir = wpath( os.path.join('$INSTDIR', os.path.dirname(rel_file))) pkg_file = wpath(os.path.normpath(pkg_file)) if installed_dir != out_path: if install: out_path = installed_dir result += 'SetOutPath ' + out_path + '\n' if install: result += 'File ' + pkg_file + '\n' else: result += 'Delete ' + wpath( os.path.join('$INSTDIR', rel_file)) + '\n' # at the end of a delete, just rmdir all the directories if not install: deleted_file_dirs = [ os.path.dirname(pair[1].replace( self.get_dst_prefix() + os.path.sep, '')) for pair in self.file_list ] # find all ancestors so that we don't skip any dirs that happened to have no non-dir children deleted_dirs = [] for d in deleted_file_dirs: deleted_dirs.extend(path_ancestors(d)) # sort deepest hierarchy first deleted_dirs.sort(lambda a,b: cmp(a.count(os.path.sep),b.count(os.path.sep)) or cmp(a,b)) deleted_dirs.reverse() prev = None for d in deleted_dirs: if d != prev: # skip duplicates result += 'RMDir ' + wpath( os.path.join('$INSTDIR', os.path.normpath(d))) + '\n' prev = d return result