add script for generating removal instructions for NSI

This commit is contained in:
Moritz Bunkus 2015-11-04 14:46:31 +01:00
parent 53c954056e
commit 51b57c8659
3 changed files with 43 additions and 0 deletions

10
tools/windows/conf.rb Executable file
View File

@ -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

View File

@ -1,2 +1,3 @@
mxe_dir=${HOME}/prog/video/mingw/cross mxe_dir=${HOME}/prog/video/mingw/cross
saxon_dir=${HOME}/opt/saxon-he saxon_dir=${HOME}/opt/saxon-he
file_list_dir=${HOME}/prog/video/mingw/src/uc/file-lists

View File

@ -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}") }