Skip to content

Commit

Permalink
Refactor ISS file building and input handling
Browse files Browse the repository at this point in the history
- Changed the creation of temporary files for building ISS files from the
  working directory to the temporary directory.
- Modified the installer build process to provide ISS files to ISCC via
  standard input instead of direct file referencing.
- Added a convert_path_to_windows method to the WindowsCommandEscaping module
  to properly format paths for the type command.
  • Loading branch information
shinokaro committed Jun 12, 2024
1 parent 4b59151 commit 2722748
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
8 changes: 6 additions & 2 deletions lib/ocran/inno_setup_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 1 addition & 4 deletions lib/ocran/inno_setup_script_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 4 additions & 0 deletions lib/ocran/windows_command_escaping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2722748

Please sign in to comment.