diff --git a/lib/ocran/inno_setup_builder.rb b/lib/ocran/inno_setup_builder.rb index effc933..720d7a6 100644 --- a/lib/ocran/inno_setup_builder.rb +++ b/lib/ocran/inno_setup_builder.rb @@ -40,10 +40,14 @@ def initialize(path, inno_setup_script, chdir_before: nil, icon_path: nil, title end def compile + # To make ISSC output installer files relative to the working directory, + # it is necessary to provide the ISS file via standard input. + type_cmd = "type #{quote_and_escape(convert_path_to_windows(@iss.to_path))}" iscc_cmd = ["ISCC"] iscc_cmd << "/Q" unless Ocran.verbose - iscc_cmd << @iss.to_path - unless system(*iscc_cmd) + iscc_cmd << "-" + cmd = "#{type_cmd} | #{iscc_cmd.join(" ")}" + unless system(cmd) case $?.exitstatus when 0 then raise "ISCC reported success, but system reported error?" when 1 then raise "ISCC reports invalid command line parameters" diff --git a/lib/ocran/inno_setup_script_builder.rb b/lib/ocran/inno_setup_script_builder.rb index 63fec2a..c996bbc 100644 --- a/lib/ocran/inno_setup_script_builder.rb +++ b/lib/ocran/inno_setup_script_builder.rb @@ -13,10 +13,7 @@ def initialize(inno_setup_script, files: [], dirs: []) end def build - # ISSC generates the installer files relative to the directory of the - # ISS file. Therefore, it is necessary to create Tempfiles in the - # working directory. - @file = Tempfile.open("", Dir.pwd) do |f| + @file = Tempfile.open do |f| IO.copy_stream(@inno_setup_script, f) if @inno_setup_script unless @dirs.empty? diff --git a/lib/ocran/windows_command_escaping.rb b/lib/ocran/windows_command_escaping.rb index f0248ed..5057ef2 100644 --- a/lib/ocran/windows_command_escaping.rb +++ b/lib/ocran/windows_command_escaping.rb @@ -11,5 +11,9 @@ def escape_double_quotes(s) def quote_and_escape(s) "\"#{escape_double_quotes(s)}\"" end + + def convert_path_to_windows(s) + s.to_s.gsub(File::SEPARATOR, "\\") + end end end