From 51b57c8659f22189dec20941225e3ae7a8e32443 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 4 Nov 2015 14:46:31 +0100 Subject: [PATCH] add script for generating removal instructions for NSI --- tools/windows/conf.rb | 10 ++++++ tools/windows/conf.sh | 1 + ...le_list_to_nsi_uninstaller_instructions.rb | 32 +++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100755 tools/windows/conf.rb create mode 100755 tools/windows/file_list_to_nsi_uninstaller_instructions.rb diff --git a/tools/windows/conf.rb b/tools/windows/conf.rb new file mode 100755 index 000000000..fd0b111db --- /dev/null +++ b/tools/windows/conf.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +def read_config + IO.readlines("#{File.dirname(__FILE__)}/conf.sh"). + map { |line| line.chomp.gsub(%r{\$HOME|\$\{HOME\}}, ENV['HOME']) }. + reject { |line| %r{^#|^\s*$}.match line }. + select { |line| %r{=}.match line }. + map { |line| line.split %r{=} }. + to_h +end diff --git a/tools/windows/conf.sh b/tools/windows/conf.sh index f732e0b59..f92df7b15 100644 --- a/tools/windows/conf.sh +++ b/tools/windows/conf.sh @@ -1,2 +1,3 @@ mxe_dir=${HOME}/prog/video/mingw/cross saxon_dir=${HOME}/opt/saxon-he +file_list_dir=${HOME}/prog/video/mingw/src/uc/file-lists diff --git a/tools/windows/file_list_to_nsi_uninstaller_instructions.rb b/tools/windows/file_list_to_nsi_uninstaller_instructions.rb new file mode 100755 index 000000000..045f59aca --- /dev/null +++ b/tools/windows/file_list_to_nsi_uninstaller_instructions.rb @@ -0,0 +1,32 @@ +#!/usr/bin/env ruby + +require "pp" +require_relative "conf" + +fail "Missing file list name" if ARGV.empty? + +config = read_config +file_name = ARGV[0] +file_name = "#{config['file_list_dir']}/#{file_name}.txt" if !FileTest.exists?(file_name) +files = IO.readlines(file_name).map { |file| file.chomp.gsub(%r{^\.}, '').gsub(%r{^/}, '').gsub(%r{/}, '\\') } +dirs = {} + +files.each do |file| + puts %Q( Delete "$INSTDIR\\#{file}") + + dir = file + while true + break unless %r{\\}.match(file) + + dir.gsub!(%r{\\[^\\]+$}, '') + dirs[dir] = true + end +end + +puts + +dirs. + keys. + sort_by { |dir| [ dir.gsub(%r{[^\\]+}, '').length, dir ] }. + reverse. + each { |dir| puts %Q( RMDir "$INSTDIR\\#{dir}") }