From 5f5f1b1a7bcd2697aea396898178e28f82006697 Mon Sep 17 00:00:00 2001 From: shinokaro Date: Tue, 4 Jun 2024 04:57:02 +0900 Subject: [PATCH] Add touch method to Builder class and update handling of empty files - Add a touch method to the Builder class for writing empty files to the installation package. - Rename the existing empty file to a more explicit name and move it to the Builder class's definition folder. - This change abstracts the touch-equivalent operation, replacing the previous method of writing empty files using the copy_file method. --- bin/ocran | 2 +- lib/ocran/inno_setup_builder.rb | 5 +++++ lib/ocran/stub_builder.rb | 5 +++++ .../ocran/empty-msys-2.0.dll => lib/ocran/touch_placeholder | 0 4 files changed, 11 insertions(+), 1 deletion(-) rename share/ocran/empty-msys-2.0.dll => lib/ocran/touch_placeholder (100%) diff --git a/bin/ocran b/bin/ocran index dfa0338f..89906211 100644 --- a/bin/ocran +++ b/bin/ocran @@ -753,7 +753,7 @@ EOF # Workaround: RubyInstaller cannot find the msys folder if ../msys64/usr/bin/msys-2.0.dll is not present (since RubyInstaller-2.4.1 rubyinstaller 2 issue 23) # Add an empty file to /msys64/usr/bin/msys-2.0.dll if the dll was not required otherwise unless builder.files.values.any? { |entry, _src| entry.to_s.include?("msys-2.0.dll") } - builder.copy(Pathname(File.dirname(__FILE__)) / "../share/ocran/empty-msys-2.0.dll", 'msys64/usr/bin/msys-2.0.dll') + builder.touch('msys64/usr/bin/msys-2.0.dll') end # Set environment variable diff --git a/lib/ocran/inno_setup_builder.rb b/lib/ocran/inno_setup_builder.rb index a9bfddcf..1abb4f53 100644 --- a/lib/ocran/inno_setup_builder.rb +++ b/lib/ocran/inno_setup_builder.rb @@ -197,6 +197,11 @@ def copy_file(src, tgt, dest_name: nil) alias copy copy_file alias cp copy_file + def touch(tgt) + src = Pathname.new(File.expand_path("touch_placeholder", __dir__)) + copy_file(src, tgt) + end + # Specifies the final application script to be launched, which can be called # from any position in the data stream. It cannot be specified more than once. def set_script(image, script, *argv) diff --git a/lib/ocran/stub_builder.rb b/lib/ocran/stub_builder.rb index a0ac401c..fa4829c0 100644 --- a/lib/ocran/stub_builder.rb +++ b/lib/ocran/stub_builder.rb @@ -129,6 +129,11 @@ def copy_file(src, tgt) alias copy copy_file alias cp copy_file + def touch(tgt) + src = Pathname.new(File.expand_path("touch_placeholder", __dir__)) + copy_file(src, tgt) + end + # Specifies the final application script to be launched, which can be called # from any position in the data stream. It cannot be specified more than once. # diff --git a/share/ocran/empty-msys-2.0.dll b/lib/ocran/touch_placeholder similarity index 100% rename from share/ocran/empty-msys-2.0.dll rename to lib/ocran/touch_placeholder