ocran 1.3.16 → 1.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b492eb2cf2cfd017c042a349bfbed469e3916e9a04d975df067c89f2d51fb76d
4
- data.tar.gz: '019bf741312e62175926aa6ac19a7f99fc1d75041a7ec818c777b07cdce0cc37'
3
+ metadata.gz: 816bbf710efb38734ee1955a19ff5bd418b83ff1a5cf21b7a4d0bfe100b2c439
4
+ data.tar.gz: 95173c8a2bd36ea959f4dfe5ddafba5a96b891ced56e9026653e4c1b3aba32a3
5
5
  SHA512:
6
- metadata.gz: c90c2d913370f8023b41683236e4174c9d1e4174ee073f586e602bd11a84f5dea1988e97c5e023ea8d94b02e349b2539d87e4b23c6d590a84c38ad9423b5d589
7
- data.tar.gz: 2f03c794cb6bd8c9318d80927bc8c10e8445ab36aa0d344aaff31701779266ec96036f50ef1d02998e3d3487010eefd8213cdd72a169f369d3fdbf177700150b
6
+ metadata.gz: ae9bd0453f9219098542daa6e1842004cc8efa29422cd80c52a0b936065f790c994139f775a1c2dd42fe9e3ed274e60741ecfc8721692d4293ee1c9fde70a34f
7
+ data.tar.gz: e422b2ed09f116891ff82cee0d5ec29125b71c6ead67964249cdcc4ad375aacced7802f07b91ef6d9419986af4ec49c7c3c56f0e22fcf85aa6cd55a62fd238e6
data/CHANGELOG.txt ADDED
@@ -0,0 +1,292 @@
1
+ === 1.3.18
2
+ - Support shipping IRB as .exe File
3
+ - Fix SxS error 14001 when loading native extensions (e.g. openssl.so, date_core.so) at runtime. Each .so file may have a companion *.so-assembly.manifest in archdir defining its private SxS assembly; these manifests are now included alongside the .so files. All files in ruby_builtin_dlls/ (DLLs and manifest) are now included rather than the manifest alone.
4
+ - Support for Ruby 4.0.
5
+ - Include cacert.pem in the exe file to avoid SSL certificate verification issues.
6
+ - Use wide (UTF-16) Win32 APIs throughout system_utils.c (CreateFileW, CreateDirectoryW, DeleteFileW, FindFirstFileW/FindNextFileW, RemoveDirectoryW, GetFileAttributesW, MoveFileExW, GetTempPathW, CreateProcessW) to correctly handle multibyte (UTF-8) file and directory paths in the stub.
7
+ - Add Windows Authenticode code signing support. The stub now detects and skips PE security directory entries when searching for the OCRAN signature, so signed executables unpack correctly. Build time clears invalid security directory entries from PE headers to allow subsequent signing.
8
+ - Fix incorrect buffer size passed to GetModuleFileNameW in LibraryDetector (passed bytesize instead of character count).
9
+ - Fix pointer subtraction underflow in stub unpacker when a tampered offset places head past tail.
10
+ - Add bounds checking for icon file entries in edicon to prevent out-of-bounds reads from malformed .ico files.
11
+ - Support for Ruby 3.2 and above. Drop ruby 3.0 and 3.1 support.
12
+ - Suppress user notifications during stub cleanup and log errors to DEBUG output
13
+ - Fixes issue where two MessageBox dialogs appeared in GUI mode when a signature was not found.
14
+ - No longer create a marker file when the stub fails to delete the installation directory during cleanup.
15
+ - stub: During cleanup, switch to a safer working directory before removing the extraction directory.
16
+ - stub: Truncate error messages originating from the stub to a fixed maximum length.
17
+ - stub: Changed the name of the extraction directory to follow the mkdtemp style. The name is now generated using secure random numbers.
18
+ - stub: Disabled path expansion of template characters for additional options passed to the script.
19
+ - stub: Changed the script’s working directory switch to use Ruby’s `-C` option.
20
+
21
+ === 1.3.17
22
+ - Modified `rake test` to no longer build stubs during test execution. Use `rake build_stub` when stub generation is necessary.
23
+ - New `rake build` task as a unified build entry point, delegating to `build_stub`.
24
+ - Updated GitHub Actions and internal scripts to use `rake build` instead of `rake build_stub`.
25
+ - Add full support for multibyte (UTF-8) names across executables, scripts, and resources. Requires Windows 10 version 1903 or later.
26
+ - Added UTF-8 manifest to stub.exe to enable UTF-8 support in ANSI API calls.
27
+ - Update Bundler from 2.5.10 to 2.5.23. This is the last Bundler version officially supporting Ruby 3.0.
28
+ - Added `bin/setup` and `bin/console` scripts for development (both Bash and Windows .bat versions).
29
+ - `bin/setup` now installs dependencies and builds stub executables automatically.
30
+ - Improved `spec.files` to explicitly include README, LICENSE, and CHANGELOG.
31
+ - Introduced a `Development` section in the README with setup instructions and Windows shell compatibility.
32
+ - Updated copyright year in README and LICENSE.
33
+
34
+ === 1.3.16
35
+ - Support for Ruby 3.0 and above. Drop ruby 2.6 and 2.7 support.
36
+ - At startup, OCRAN no longer automatically removes directories that were previously deployed but couldn't be deleted. This change has been made to enhance security by preventing processes other than the startup process from manipulating temporary files created by them.
37
+ - The ability for the stub to launch any script during the unpacking of application files has been removed. This feature was not in use.
38
+ - The exit code from the Ruby application is now returned when the stub is terminated.
39
+ - The packed data no longer contains redundant directory information.
40
+ - Fixed errors in the --debug option.
41
+ - Upgraded LZMA decoder to version 22.01
42
+ - The directory generation for file extraction has been changed to use unique directory names created with high-resolution timestamps. Additionally, a retry limit for directory creation has been introduced, reducing the risk of infinite loops due to name collisions.
43
+ - Implemented variable-length buffer handling for path strings in stub, eliminating the risk of buffer overruns dependent on MAX_PATH.
44
+ - In order to reduce security risks during the cleanup process before application termination, we have implemented a safe current directory change from the system directory and the root of the C drive to the user's temporary directory and the directory of the app executable.
45
+ - The 'stub' executable has been enhanced for security, ensuring it prevents directory traversal attacks by verifying that path elements do not contain relative notations like '.' or '..'.
46
+ - Removed OcranBuilder and split functionality into StubBuilder and InnoSetupBuilder to introduce delayed loading and improve resource efficiency.
47
+ - InnoSetup installer now operates independently of stub, launching through its own batch file.
48
+ - Moved LibraryDetector to a separate file for modularity and implemented delayed loading with standardized Fiddle usage.
49
+ - Update Bundler from 2.4.13 to 2.5.10.
50
+ - Fixed issue where the gem.build_complete file was not included in the package due to an incorrect change.
51
+ - Changed error output from standard output to standard error (stderr).
52
+ - ocransa (Ocran-stand-alone) has been discontinued.
53
+ - The implementation of bin/ocran.rb has been refactored and split into multiple files. These files have been relocated to the lib directory.
54
+
55
+ === 1.3.15
56
+ - Support for Ruby 2.6 and above.
57
+ - Properly display errors from InnoSetup.
58
+ - Fixed errors when creating an installer using InnoSetup. Previously, installer creation was not possible due to errors related to file sharing, which occurred only on Windows.
59
+ - Retrieve the path of runtime DLLs even when the path is long. Note that stubs still do not support long paths, so creating executable files with long paths is not yet possible.
60
+ - Fixed bugs in tests. All tests can now be executed.
61
+ - Improved the speed of manifest file discovery. This manifest file is only required in the RubyInstaller environment.
62
+ - Fixed bugs in the regular expressions of GEM_EXTRA_RE. This allows excluding C source files, etc., from the ocran executable package based on command options.
63
+ - Added methods to Ocran::Pathname, making it closer to the implementation of Ruby's Pathname.
64
+ - Reimplemented certain parts to match the implementation of Ruby 2.6 era, for compatibility with older Ruby versions. Therefore, the ocran command cannot be executed on Ruby versions earlier than 2.6.
65
+
66
+ === 1.3.14
67
+ - Add option to suppress or override RUBYOPT environment variable #3 by ccorn90
68
+
69
+ === 1.3.13
70
+ - Fixed the bug why Innosetup did not run because of missing encode method
71
+ - Fix an issue where rubyinstaller did not find the msys path by putting in an empty msys-2.0.dll into msys64/usr/bin/msys-2.0.dll
72
+ - compatibility with the tiny_tds gem (see above)
73
+ - GitHub builds through github action: making sure you can trust the included binaries.
74
+ - Added some samples including the glimmer-libui GUI example. GUI that starts fast.
75
+
76
+ === 1.3.12
77
+ * Forked from Ocra
78
+ * Support Ruby up to 3.2
79
+ * Update lzma.exe to version 22.01
80
+
81
+ === 1.3.11
82
+
83
+ * Support Ruby 2.2-2.7
84
+ * Add ruby2_keywords.rb to ignored modules
85
+ * Update lzma.exe to version 19.00
86
+ * Workaround for warning about deprecated Object#=~
87
+ * Use Fiddle instead of Win32API
88
+ * Fix for invalid argument to relative_path_from
89
+
90
+ === 1.3.10
91
+
92
+ * Reduce memory usage while building & compressing (avoids out of
93
+ memory issue on really big programs).
94
+
95
+ * Compile stub.exe with 32-bit compiler again
96
+
97
+ === 1.3.9
98
+
99
+ * Support Ruby 2.4.1p111 (include manifest)
100
+
101
+ === 1.3.8
102
+
103
+ * Use GetModuleFileNameW for DLL detection
104
+
105
+ === 1.3.7
106
+
107
+ * Workaround for handling of file names and directory name with
108
+ non-ASCII characters (e.g. "invalid byte sequence in UTF-8")
109
+
110
+ === 1.3.6
111
+
112
+ * More robust cleanup of temporary files. Deletes using manual
113
+ recursive method instead of using the shell. Will mark files for
114
+ later deletion both using Windows (requires Administrator
115
+ privileges) and a custom method that will remove old temporary files
116
+ when the executable is restarted.
117
+
118
+ === 1.3.5
119
+
120
+ * Fixes for Ruby 2.2.2p95
121
+
122
+ === 1.3.4
123
+
124
+ * Workarounds for Ruby 2.1.5
125
+
126
+ === 1.3.3
127
+
128
+ * Rebuild executables with MinGW GCC 4.8.1-4.
129
+
130
+ === 1.3.2
131
+
132
+ * Refactored Gemfile handling for better compatibility with Ruby
133
+ version.
134
+
135
+ === 1.3.1
136
+
137
+ * Now includes $LOADED_FEATURES even when script is not run to check
138
+ dependencies. This fixes compatability with Ruby 1.9.3 where
139
+ rubygems is always loaded.
140
+
141
+ * Fixed compatability with Ruby 2.0.0: Temp-path alias in binary
142
+ changed to be valid UTF-8 character.
143
+
144
+ * README.txt updated related to --no-dep-run (karhatsu).
145
+
146
+ * Fixes for Bundler handling (DavidMikeSimon).
147
+
148
+ === 1.3.0
149
+
150
+ * Fixed some additional corner cases with absolute and relative
151
+ require & load paths. Extended test suite to cover a lot more
152
+ cases.
153
+
154
+ * Now provides a meaningful exit status code (1 on error, 0 on
155
+ success). (DavidMikeSimon)
156
+
157
+ * New option to _not_ run the script to detect dependencies
158
+ (--no-dep-run). (DavidMikeSimon)
159
+
160
+ * Bundler support using the --gemfile option. (DavidMikeSimon)
161
+
162
+ * Debug mode support in the stub (--debug). Also --debug-extract to
163
+ keep extracted files from executable. (DavidMikeSimon)
164
+
165
+ * New gem behaviour yet again due to changes in Rubygems. See README
166
+ file.
167
+
168
+ === 1.2.0
169
+
170
+ * Ignore console events (Ctrl-C, Ctrl-Break). Ruby process handles
171
+ them anyway and exist, allowing the stub to clean up temporary
172
+ files.
173
+
174
+ * Temporary memory used for decompression is now freed before the ruby
175
+ interpreter is launched by the stub.
176
+
177
+ * Progress dialog is no longer displayed when removing temporary
178
+ files.
179
+
180
+ * Now includes most files from any require'd Rubygem (Now works with
181
+ mime-types, oledb and other gems that load additional data files
182
+ from the Gem installation). Some files are still ignored
183
+ (e.g. Readme's). Use "--no-gem-filter" to make Ocra unconditionally
184
+ include all files listed in the Gem specification (Thanks to Jorge
185
+ L. Cangas for patch & ideas).
186
+
187
+ * NameErrors are now rescued when attempting to load autoloadable
188
+ constants. Hopefully resolves issues with ActiveRecord [#28488].
189
+
190
+ * Now works if the script changes environment or working directory
191
+ while running.
192
+
193
+ * Fixed a regression in 1.1.4 when resource files are specified;
194
+ directory layout would not be maintained, e.g. when running "ocra
195
+ bin/script share/data.dat".
196
+
197
+ * Added support for passing arguments to script. Specify argument to
198
+ your script after a "--" marker. Arguments will be passed both at
199
+ compile time and run time. (#27815)
200
+
201
+ * Now works if the source files are located beneath Ruby's
202
+ exec_prefix. (#28505)
203
+
204
+ === 1.1.4
205
+
206
+ * The tempdir marker is now pretty-printed as "<tempdir>" in the
207
+ output.
208
+
209
+ * Fixed various issues with path and filenames being handled case
210
+ sensitive.
211
+
212
+ * Now uses config settings for Ruby executable names (should now also
213
+ work with ruby installations built with --program-suffix).
214
+
215
+ * Supported invoking ocra with an absolute path to the script. Will
216
+ assume that the script is in the root of the source hierachy.
217
+
218
+ === 1.1.3
219
+
220
+ * Use Win32API (provided with Ruby) instead of win32-api (gem).
221
+
222
+ * No longer sets GEM_HOME (which would override the default gem
223
+ path). Instead sets GEM_PATH. Resolves issues with gems not loading
224
+ on Ruby 1.9.
225
+
226
+ === 1.1.2
227
+
228
+ * Warnings can be disabled using --no-warnings.
229
+
230
+ * Fixed not .exe being generated when script calls 'exit'.
231
+
232
+ * Path to the generated executable is now avilable to the running
233
+ script in the OCRA_EXECUTABLE environment variable.
234
+
235
+ * Directories on the command line will now be created.
236
+
237
+ * Supports path globs, fx. "ocra script.rb assets/**/*.png". (See
238
+ documentation for Ruby's Dir class).
239
+
240
+ * Fixed issue with spaces in temporary path (TMP environment).
241
+
242
+ * Improved path comparison to ignore case (this is Windows after all)
243
+ and be a bit more robust.
244
+
245
+ * Added support for RubyGems installed in GEM_HOME (or other part
246
+ handled by RubyGems). If not installed in the Ruby hierarchy, they
247
+ will now be installed in a directory named 'gemhome' under the
248
+ temporary directory.
249
+
250
+ === 1.1.1
251
+
252
+ * Fixed duplicate entries in the RUBYLIB environment variable.
253
+
254
+ * Another slight fix for relative load paths.
255
+
256
+ * RUBYOPT is now set to the value it had when OCRA was invoked.
257
+
258
+ === 1.1.0
259
+
260
+ * Added an icon to the executable. Can be replaced from a .ico file
261
+ using the --icon <ico> option.
262
+
263
+ * Improved handling of load paths added either from the command line
264
+ (ruby -I), RUBYLIB environment variable or during the script (by
265
+ modifying $: or $LOAD_PATH).
266
+
267
+ * Now automatically detects loaded DLLs through Win32::API. Disable
268
+ with --no-autodll.
269
+
270
+ === 1.0.3 / 2009-05-25
271
+
272
+ * Fixed invokation of executables with spaces in path names (#25966).
273
+
274
+ * Fixed inverted handling of --windows & --console (#25974)
275
+
276
+ * Fixed installation issue with RubyGems (missing "lib")
277
+
278
+ === 1.0.2 / 2009-05-10
279
+
280
+ * Added stubw.exe to gem (was missing 1.0.1)
281
+
282
+ === 1.0.1 / 2009-05-05
283
+
284
+ * Added stub with windows runtime for windowed applications
285
+ (e.g. wxRuby) and fixed issue where OCRA would use ruby.exe instead
286
+ of rubyw.exe for such programs. [#25774]
287
+
288
+ === 1.0.0 / 2009-04-05
289
+
290
+ * 1 major enhancement
291
+
292
+ * Birthday!
data/LICENSE.txt ADDED
@@ -0,0 +1,23 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009-2020 Lars Christensen
4
+ Copyright (c) 2020-2025 The OCRAN Committers Team
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining
7
+ a copy of this software and associated documentation files (the
8
+ 'Software'), to deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify, merge, publish,
10
+ distribute, sublicense, and/or sell copies of the Software, and to
11
+ permit persons to whom the Software is furnished to do so, subject to
12
+ the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,533 @@
1
+ # ocran
2
+
3
+ home :: https://github.com/largo/ocran/
4
+
5
+ issues :: http://github.com/largo/ocran/issues
6
+
7
+ ## Description
8
+
9
+ OCRAN (One-Click Ruby Application Next) builds Windows executables from Ruby
10
+ source code. The executable is a self-extracting, self-running
11
+ executable that contains the Ruby interpreter, your source code and
12
+ any additionally needed ruby libraries or DLL.
13
+
14
+ OCRAN is a fork of Ocra (https://github.com/larsch/ocra) in order to
15
+ maintain compatibility with newer Ruby versions after 3.2
16
+
17
+ ## Recommended usage
18
+ Most commonly you will needs this, when you want to ship your program to windows servers / users that don't have Ruby installed.
19
+ By default each time the .exe is opened it will extract the ruby interpeter along with the code to the temp directory.
20
+ Since this process takes time, we recommend using the innosetup edition which will install your program together with the ruby intepreter into
21
+ a directory.
22
+
23
+ ## Features
24
+
25
+ * LZMA Compression (optional, default on)
26
+ * Both windowed/console mode supported
27
+ * Includes gems based on usage, or from a Bundler Gemfile
28
+
29
+ ## Problems & Bug Reporting
30
+
31
+ * Windows support only
32
+
33
+ If you experience problems with OCRAN or have found a bug, please use
34
+ the issue tracker on GitHub (http://github.com/largo/ocran/issues).
35
+
36
+ ## Safety
37
+
38
+ As this gem comes with binary blobs, we have taken actions to insure your safety.
39
+ The gem releases are securely built on Github Actions. Feel free verify that it matches the version on rubygems.
40
+ This repository ships with LZMA.exe from [The official release of ip7z/7zip](https://github.com/ip7z/7zip/releases): Version 22.01 from lzma2201.7z
41
+ The LZMA.exe is used to compress the executable.
42
+ Other files such as stub.exe, stubw.exe and edicon.exe are built from source code in the repository.
43
+
44
+ ## Installation
45
+
46
+ Gem:
47
+
48
+ gem install ocran
49
+
50
+ Alternatively you can download the gem at either
51
+ http://rubygems.org/gems/ocran or
52
+ https://github.com/largo/ocran/releases/.
53
+
54
+ ## Synopsis
55
+
56
+ ### Building an executable:
57
+
58
+ ocran script.rb
59
+
60
+ Will package `script.rb`, the Ruby interpreter and all
61
+ dependencies (gems and DLLs) into an executable named
62
+ `script.exe`.
63
+
64
+ ### Command line:
65
+
66
+ ocran [options] script.rb [<other files> ...] [-- <script arguments> ...]
67
+
68
+ ### Options:
69
+
70
+ ocran --help
71
+
72
+ Ocran options:
73
+
74
+ --help Display this information.
75
+ --quiet Suppress output while building executable.
76
+ --verbose Show extra output while building executable.
77
+ --version Display version number and exit.
78
+
79
+ Packaging options:
80
+
81
+ --dll dllname Include additional DLLs from the Ruby bindir.
82
+ --add-all-core Add all core ruby libraries to the executable.
83
+ --gemfile <file> Add all gems and dependencies listed in a Bundler Gemfile.
84
+ --no-enc Exclude encoding support files
85
+
86
+ Gem content detection modes:
87
+
88
+ --gem-minimal[=gem1,..] Include only loaded scripts
89
+ --gem-guess=[gem1,...] Include loaded scripts & best guess (DEFAULT)
90
+ --gem-all[=gem1,..] Include all scripts & files
91
+ --gem-full[=gem1,..] Include EVERYTHING
92
+ --gem-spec[=gem1,..] Include files in gemspec (Does not work with Rubygems 1.7+)
93
+
94
+ --[no-]gem-scripts[=..] Other script files than those loaded
95
+ --[no-]gem-files[=..] Other files (e.g. data files)
96
+ --[no-]gem-extras[=..] Extra files (README, etc.)
97
+
98
+ Gem modes:
99
+
100
+ * *minimal*: loaded scripts
101
+ * *guess*: loaded scripts and other files
102
+ * *all*: loaded scripts, other scripts, other files (except extras)
103
+ * *full*: Everything found in the gem directory
104
+
105
+ File groups:
106
+
107
+ * *scripts*: .rb/.rbw files
108
+ * *extras*: C/C++ sources, object files, test, spec, README
109
+ * *files*: all other files
110
+
111
+ Auto-detection options:
112
+
113
+ --no-dep-run Don't run script.rb to check for dependencies.
114
+ --no-autoload Don't load/include script.rb's autoloads.
115
+ --no-autodll Disable detection of runtime DLL dependencies.
116
+
117
+ Output options:
118
+
119
+ --output <file> Name the exe to generate. Defaults to ./<scriptname>.exe.
120
+ --no-lzma Disable LZMA compression of the executable.
121
+ --innosetup <file> Use given Inno Setup script (.iss) to create an installer.
122
+
123
+ Executable options:
124
+
125
+ --windows Force Windows application (rubyw.exe)
126
+ --console Force console application (ruby.exe)
127
+ --chdir-first When exe starts, change working directory to app dir.
128
+ --icon <ico> Replace icon with a custom one.
129
+ --rubyopt <str> Set the RUBYOPT environment variable when running the executable
130
+ --debug Executable will be verbose.
131
+ --debug-extract Executable will unpack to local dir and not delete after.
132
+
133
+
134
+ ### Compilation:
135
+
136
+ * OCRAN will load your script (using `Kernel#load`) and build
137
+ the executable when it exits.
138
+
139
+ * Your program should 'require' all necessary files when invoked without
140
+ arguments, so OCRAN can detect all dependencies.
141
+
142
+ * DLLs are detected automatically but only those located in your Ruby
143
+ installation are included.
144
+
145
+ * .rb files will become console applications. .rbw files will become
146
+ windowed application (without a console window popping
147
+ up). Alternatively, use the `--console` or
148
+ `--windows` options.
149
+
150
+ ### Running your application:
151
+
152
+ * The 'current working directory' is not changed by OCRAN when running
153
+ your application. You must change to the installation or temporary
154
+ directory yourself. See also below.
155
+ * When the application is running, the OCRAN_EXECUTABLE environment
156
+ variable points to the .exe (with full path).
157
+ * The temporary location of the script can be obtained by inspected
158
+ the $0 variable.
159
+ * OCRAN does not set up the include path. Use `$:.unshift
160
+ File.dirname($0)` at the start of your script if you need to
161
+ 'require' additional source files from the same directory as your
162
+ main script.
163
+
164
+ ### Pitfalls:
165
+
166
+ * Avoid modifying load paths at run time. Specify load paths using -I
167
+ or RUBYLIB if you must, but don't expect OCRAN to preserve them for
168
+ runtime. OCRAN may pack sources into other directories than you
169
+ expect.
170
+ * If you use .rbw files or the `--windows` option, then check
171
+ that your application works with rubyw.exe before trying with OCRAN.
172
+ * Avoid absolute paths in your code and when invoking OCRAN.
173
+
174
+ ### Multibyte path and filename support:
175
+
176
+ * OCRAN-built executables can correctly handle multibyte paths and filenames
177
+ (e.g., Japanese or emoji) on Windows. To use this feature, the executable
178
+ must be run on Windows 10 version 1903 or later.
179
+ * When using OCRAN-built executables from the console, we recommend running
180
+ `chcp 65001` to switch the code page to UTF-8. This ensures proper
181
+ input/output of multibyte characters in Command Prompt (CMD) and
182
+ PowerShell.
183
+
184
+ ## REQUIREMENTS:
185
+
186
+ * Windows
187
+ * Working Ruby installation.
188
+ * Ruby Installation with devkit from rubyinstaller (when working with the source code only)
189
+
190
+ ## Development
191
+
192
+ ### Quick start
193
+
194
+ Quickly set up the development environment and run the full test suite:
195
+
196
+ git clone https://github.com/largo/ocran.git
197
+ cd ocran
198
+ bin/setup # install Bundler & all dev gems, generate stub for tests
199
+ bundle exec rake # run the entire Minitest suite
200
+
201
+ ### Developer Utilities (bin/ scripts)
202
+
203
+ All scripts in the `bin/` directory are designed for developers and can be executed in any standard Windows shell, including Command Prompt (CMD), PowerShell, and Git Bash.
204
+
205
+ | Script | Purpose |
206
+ |---------------|--------------------------------------------------------------------------|
207
+ | `bin/setup` | Installs Bundler and all required development gems, then builds stub.exe |
208
+ | `bin/console` | Launches an IRB console with OCRAN preloaded |
209
+
210
+
211
+ ### Rake tasks (Windows compatible)
212
+
213
+ | Task | Purpose |
214
+ |--------------|------------------------------------------------------------------------|
215
+ | `rake build` | Compile stub.exe (requires MSVC or mingw‑w64 + DevKit) |
216
+ | `rake clean` | Remove generated binaries (e.g., stub.exe); temp files are not deleted |
217
+ | `rake test` | Execute all unit & integration tests |
218
+
219
+ ## Technical details
220
+
221
+ OCRAN first runs the target script in order to detect any files that
222
+ are loaded and used at runtime (Using `Kernel#require` and
223
+ `Kernel#load`).
224
+
225
+ OCRAN embeds everything needed to run a Ruby script into a single
226
+ executable file. The file contains the .exe stub which is compiled
227
+ from C-code, and a custom opcode format containing instructions to
228
+ create directories, save files, set environment variables and run
229
+ programs. The OCRAN script generates this executable and the
230
+ instructions to be run when it is launched.
231
+
232
+ When executed, the OCRAN stub extracts the Ruby interpreter and your
233
+ scripts into a temporary directory. The directory will contains the
234
+ same directory layout as your Ruby installlation. The source files for
235
+ your application will be put in the 'src' subdirectory.
236
+
237
+ ### Libraries
238
+
239
+ Any code that is loaded through `Kernel#require` when your
240
+ script is executed will be included in the OCRAN
241
+ executable. Conditionally loaded code will not be loaded and included
242
+ in the executable unless the code is actually run when OCRAN invokes
243
+ your script. Otherwise, OCRAN won't know about it and will not include
244
+ the source files.
245
+
246
+ RubyGems are handled specially. Whenever a file from a Gem is
247
+ detected, OCRAN will attempt to include all the required files from
248
+ that specific Gem, expect some unlikely needed files such as readme's
249
+ and other documentation. This behaviour can be controlled by using the
250
+ --gem-* options. Behaviour can be changed for all gems or specific
251
+ gems using --gem-*=gemname.
252
+
253
+ Libraries found in non-standard path (for example, if you invoke OCRAN
254
+ with "ruby -I some/path") will be placed into the site dir
255
+ (lib/ruby/site_ruby). Avoid changing `$LOAD_PATH` or
256
+ `$:` from your script to include paths outside your source
257
+ tree, since OCRAN may place the files elsewhere when extracted into the
258
+ temporary directory.
259
+
260
+ In case your script (or any of its dependencies) sets up autoloaded
261
+ module using `Kernel#autoload`, OCRAN will automatically try to
262
+ load them to ensure that they are all included in the
263
+ executable. Modules that doesn't exist will be ignored (a warning will
264
+ be logged).
265
+
266
+ Dynamic link libraries (.dll files, for example WxWidgets, or other
267
+ source files) will be detected and included by OCRAN.
268
+
269
+ ### Including libraries non-automatically
270
+
271
+ If an application or framework is complicated enough that it tends
272
+ to confuse Ocran's automatic dependency resolution, then you can
273
+ use other means to specify what needs to be packaged with your app.
274
+
275
+ To disable automatic dependency resolution, use the `--no-dep-run`
276
+ option; with it, Ocran will skip executing your program during the
277
+ build process. This on the other hand requires using `--gem-full` option
278
+ (see more below); otherwise Ocran will not include all the necessary
279
+ files for the gems.
280
+
281
+ You will also probably need to use the `--add-all-core` option to
282
+ include the Ruby core libraries.
283
+
284
+ If your app uses gems, then you can specify them in a
285
+ Bundler (http://gembundler.com) Gemfile, then use the --gemfile
286
+ option to supply it to Ocran. Ocran will automatically include all
287
+ gems specified, and all their dependencies.
288
+
289
+ (Note: This assumes that the gems are installed in your system,
290
+ *not* locally packaged inside the app directory by "bundle package")
291
+
292
+ These options are particularly useful for packaging Rails
293
+ applications. For example, to package a Rails 3 app in the
294
+ directory "someapp" and create an exe named "someapp.exe", without
295
+ actually running the app during the build, you could use the
296
+ following command:
297
+
298
+ ocran someapp/script/rails someapp --output someapp.exe --add-all-core \
299
+ --gemfile someapp/Gemfile --no-dep-run --gem-full --chdir-first -- server
300
+
301
+ Note the space between `--` and `server`! It's important; `server` is
302
+ an argument to be passed to rails when the script is ran.
303
+
304
+ Rails 2 apps can be packaged similarly, though you will have to
305
+ integrate them with Bundler (http://gembundler.com/rails23.html)
306
+ first.
307
+
308
+ ### Gem handling
309
+
310
+ By default, Ocran includes all scripts that are loaded by your script
311
+ when it is run before packaging. Ocran detects which gems are using and
312
+ includes any additional non-script files from those gems, except
313
+ trivial files such as C/C++ source code, object files, READMEs, unit
314
+ tests, specs, etc.
315
+
316
+ This behaviour can be changed by using the --gem-* options. There are
317
+ four possible modes:
318
+
319
+ * *minimal*: Include only loaded scripts
320
+ * *guess*: Include loaded scripts and important files (DEFAULT)
321
+ * *all*: Include all scripts and important files
322
+ * *full*: Include all files
323
+
324
+ If you find that files are missing from the resulting executable, try
325
+ first with --gem-all=gemname for the gem that is missing, and if that
326
+ does not work, try --gem-full=gemname. The paranoid can use --gem-full
327
+ to include all files for all required gems.
328
+
329
+ ### Creating an installer for your application
330
+
331
+ To make your application start up quicker, or to allow it to
332
+ keep files in its application directory between runs, or if
333
+ you just want to make your program seem more like a "regular"
334
+ Windows application, you can have Ocran generate an installer
335
+ for your app with the free Inno Setup software.
336
+
337
+ You will first have to download and install Inno Setup 5 or
338
+ later, and also add its directory to your PATH (so that Ocran
339
+ can find the ISCC compiler program). Once you've done that,
340
+ you can use the `--innosetup` option to Ocran to supply an
341
+ Inno Setup script. Do not add any [Files] or [Dirs] sections
342
+ to the script; Ocran will figure those out itself.
343
+
344
+ To continue the Rails example above, let's package the Rails 3
345
+ app into an installer. Save the following as `someapp.iss`:
346
+
347
+ [Setup]
348
+ AppName=SomeApp
349
+ AppVersion=0.1
350
+ DefaultDirName={pf}\SomeApp
351
+ DefaultGroupName=SomeApp
352
+ OutputBaseFilename=SomeAppInstaller
353
+
354
+ [Icons]
355
+ Name: "{group}\SomeApp"; Filename: "{app}\someapp.bat"; IconFilename: "{app}\someapp.ico"; Flags: runminimized;
356
+ Name: "{group}\Uninstall SomeApp"; Filename: "{uninstallexe}"
357
+
358
+ Then, run Ocran with this command:
359
+
360
+ ocran someapp/script/rails someapp --output someapp.exe --add-all-core \
361
+ --gemfile someapp/Gemfile --no-dep-run --gem-full --chdir-first --no-lzma \
362
+ --icon someapp.ico --innosetup someapp.iss -- server
363
+
364
+ If all goes well, a file named "SomeAppInstaller.exe" will be placed
365
+ into the Output directory.
366
+
367
+ ### Environment variables
368
+
369
+ OCRAN executables clear the RUBYLIB environment variable before your
370
+ script is launched. This is done to ensure that your script does not
371
+ use load paths from the end user's Ruby installation.
372
+
373
+ OCRAN executables set the RUBYOPT environment variable to the value it
374
+ had when you invoked OCRAN. For example, if you had "RUBYOPT=rubygems"
375
+ on your build PC, OCRAN ensures that it is also set on PC's running the
376
+ executables.
377
+
378
+ OCRAN executables set OCRAN_EXECUTABLE to the full path of the
379
+ executable, for example
380
+
381
+ ENV["OCRAN_EXECUTABLE"] # => C:\Program Files\MyApp\MyApp.exe
382
+
383
+ ### Working directory
384
+
385
+ The OCRAN executable does not change the working directory when it is
386
+ launched, unless you use the `--chdir-first` option.
387
+
388
+ You should not assume that the current working directory when invoking
389
+ an executable built with .exe is the location of the source script. It
390
+ can be the directory where the executable is placed (when invoked
391
+ through the Windows Explorer), the users' current working directory
392
+ (when invoking from the Command Prompt), or even
393
+ `C:\\WINDOWS\\SYSTEM32` when the executable is invoked through
394
+ a file association.
395
+
396
+ With the `--chdir-first` option, the working directory will
397
+ always be the common parent directory of your source files. This
398
+ should be fine for most applications. However, if your application
399
+ is designed to run from the command line and take filenames as
400
+ arguments, then you cannot use this option.
401
+
402
+ If you wish to maintain the user's working directory, but need to
403
+ `require` additional Ruby scripts from the source directory, you can
404
+ add the following line to your script:
405
+
406
+ $LOAD_PATH.unshift File.dirname($0)
407
+
408
+ ### Load path mangling
409
+
410
+ Adding paths to `$LOAD_PATH` or `$:` at runtime is not
411
+ recommended. Adding relative load paths depends on the working
412
+ directory being the same as where the script is located (See
413
+ above). If you have additional library files in directories below the
414
+ directory containing your source script you can use this idiom:
415
+
416
+ $LOAD_PATH.unshift File.join(File.dirname($0), 'path/to/script')
417
+
418
+ ### Detecting
419
+
420
+ You can detect whether OCRAN is currently building your script by
421
+ looking for the 'Ocran' constant. If it is defined, OCRAN is currenly
422
+ building the executable from your script. For example, you can use
423
+ this to avoid opening a GUI window when compiling executables:
424
+
425
+ app = MyApp.new
426
+ app.main_loop unless defined?(Ocran)
427
+
428
+ ### Additional files and resources
429
+
430
+ You can add additional files to the OCRAN executable (for example
431
+ images) by appending them to the command line. They should be placed
432
+ in the source directory with your main script (or a subdirectory).
433
+
434
+ ocran mainscript.rb someimage.jpeg docs/document.txt
435
+
436
+ This will create the following layout in the temporary directory when
437
+ your program is executed:
438
+
439
+ src/mainscript.rb
440
+ src/someimage.jpeg
441
+ src/docs/document.txt
442
+
443
+ Both files, directoriess and glob patterns can be specified on the
444
+ command line. Files will be added as-is. If a directory is specified,
445
+ OCRAN will include all files found below that directory. Glob patterns
446
+ (See Dir.glob) can be used to specify a specific set of files, for
447
+ example:
448
+
449
+ ocran script.rb assets/**/*.png
450
+
451
+ ### Command Line Arguments
452
+
453
+ To pass command line argument to your script (both while building and
454
+ when run from the resulting executable), specify them after a
455
+ `--` marker. For example:
456
+
457
+ ocran script.rb -- --some-options=value
458
+
459
+ This will pass `--some-options=value` to the script when
460
+ build and when running the executable. Any extra argument specified by
461
+ the user when invoking the executable will be appended after the
462
+ compile-time arguments.
463
+
464
+ ### Window/Console
465
+
466
+ By default, OCRAN builds console application from .rb-files and
467
+ windowed applications (without console window) from .rbw-files.
468
+
469
+ Ruby on Windows provides two executables: ruby.exe is a console mode
470
+ application and rubyw.exe is a windowed application which does not
471
+ bring up a console window when launched using the Windows Explorer.
472
+ By default, or if the `--console` option is used, OCRAN will
473
+ use the console runtime (ruby.exe). OCRAN will automatically select the
474
+ windowed runtime when your script has the ".rbw" extension, or if you
475
+ specify the `--windows` command line option.
476
+
477
+ If your application works in console mode but not in windowed mode,
478
+ first check if your script works without OCRAN using rubyw.exe. A
479
+ script that prints to standard output (using puts, print etc.) will
480
+ eventually cause an exception when run with rubyw.exe (when the IO
481
+ buffers run full).
482
+
483
+ You can also try wrapping your script in an exception handler that
484
+ logs any errors to a file:
485
+
486
+ begin
487
+ # your script here
488
+ rescue Exception => e
489
+ File.open("except.log") do |f|
490
+ f.puts e.inspect
491
+ f.puts e.backtrace
492
+ end
493
+ end
494
+
495
+ ## CREDITS:
496
+
497
+ Lars Christensen and contributors for the OCRA project which this is forked from.
498
+
499
+ Kevin Walzer of codebykevin, Maxim Samsonov for ocra2, John Mair for codesigining support (to be merged)
500
+
501
+ Thanks for Igor Pavlov for the LZMA compressor and decompressor. The
502
+ source code used was place into Public Domain by Igor Pavlov.
503
+
504
+ Erik Veenstra for rubyscript2exe which provided inspiration.
505
+
506
+ Dice for the default .exe icon (vit-ruby.ico,
507
+ http://ruby.morphball.net/vit-ruby-ico_en.html)
508
+
509
+ ## LICENSE:
510
+
511
+ (The MIT License)
512
+
513
+ Copyright (c) 2009-2020 Lars Christensen
514
+ Copyright (c) 2020-2025 The OCRAN Committers Team
515
+
516
+ Permission is hereby granted, free of charge, to any person obtaining
517
+ a copy of this software and associated documentation files (the
518
+ 'Software'), to deal in the Software without restriction, including
519
+ without limitation the rights to use, copy, modify, merge, publish,
520
+ distribute, sublicense, and/or sell copies of the Software, and to
521
+ permit persons to whom the Software is furnished to do so, subject to
522
+ the following conditions:
523
+
524
+ The above copyright notice and this permission notice shall be
525
+ included in all copies or substantial portions of the Software.
526
+
527
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
528
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
529
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
530
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
531
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
532
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
533
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -144,10 +144,36 @@ module Ocran
144
144
  end
145
145
  end
146
146
 
147
- # Add external manifest files
147
+ # Add external manifest and builtin DLLs
148
148
  if (manifest = ruby_builtin_manifest)
149
- say "Adding external manifest #{manifest}"
150
- builder.duplicate_to_exec_prefix(manifest)
149
+ manifest.dirname.each_child do |path|
150
+ next if path.directory?
151
+ say "Adding builtin DLL/manifest #{path}"
152
+ builder.duplicate_to_exec_prefix(path)
153
+ end
154
+ end
155
+
156
+ # Include SxS assembly manifests for native extensions.
157
+ # Each .so file may have an embedded manifest referencing a companion
158
+ # *.so-assembly.manifest file in the same directory. Without these
159
+ # manifests the SxS activation context fails (error 14001) at runtime.
160
+ # Scan archdir and the extension dirs of all loaded gems.
161
+ sxs_manifest_dirs = []
162
+ archdir = Pathname(RbConfig::CONFIG["archdir"])
163
+ sxs_manifest_dirs << archdir if archdir.exist? && archdir.subpath?(exec_prefix)
164
+ if defined?(Gem)
165
+ Gem.loaded_specs.each_value do |spec|
166
+ next if spec.extensions.empty?
167
+ ext_dir = Pathname(spec.extension_dir)
168
+ sxs_manifest_dirs << ext_dir if ext_dir.exist? && ext_dir.subpath?(exec_prefix)
169
+ end
170
+ end
171
+ sxs_manifest_dirs.each do |dir|
172
+ dir.each_child do |path|
173
+ next unless path.extname == ".manifest"
174
+ say "Adding native extension assembly manifest #{path}"
175
+ builder.duplicate_to_exec_prefix(path)
176
+ end
151
177
  end
152
178
 
153
179
  # Add extra DLLs specified on the command line
@@ -209,15 +235,15 @@ module Ocran
209
235
  # If requested, add all ruby standard libraries
210
236
  if @option.add_all_core?
211
237
  say "Will include all ruby core libraries"
212
- @pre_env.load_path.each do |load_path|
213
- path = Pathname.new(load_path)
238
+ all_core_dir.each do |path|
214
239
  # Match the load path against standard library, site_ruby, and vendor_ruby paths
215
- path.to_posix.match(RUBY_LIBRARY_PATH_REGEX) do |m|
216
- subdir = m[1]
217
- path.find.each do |src|
218
- next if src.directory?
219
- builder.copy_to_lib(src, Pathname(subdir) / src.relative_path_from(path))
220
- end
240
+ unless (subdir = path.to_posix.match(RUBY_LIBRARY_PATH_REGEX)&.[](1))
241
+ raise "Unexpected library path format (does not match core dirs): #{path}"
242
+ end
243
+ path.find.each do |src|
244
+ next if src.directory?
245
+ a = Pathname(subdir) / src.relative_path_from(path)
246
+ builder.copy_to_lib(src, Pathname(subdir) / src.relative_path_from(path))
221
247
  end
222
248
  end
223
249
  end
@@ -312,6 +338,52 @@ module Ocran
312
338
  end
313
339
  end
314
340
 
341
+ # Bundle SSL certificates if OpenSSL was loaded (e.g. via net/http HTTPS)
342
+ if defined?(OpenSSL)
343
+ cert_file = Pathname(OpenSSL::X509::DEFAULT_CERT_FILE)
344
+ if cert_file.file? && cert_file.subpath?(exec_prefix)
345
+ say "Adding SSL certificate file #{cert_file}"
346
+ builder.duplicate_to_exec_prefix(cert_file)
347
+ builder.export("SSL_CERT_FILE", File.join(EXTRACT_ROOT, cert_file.relative_path_from(exec_prefix).to_posix))
348
+ end
349
+
350
+ cert_dir = Pathname(OpenSSL::X509::DEFAULT_CERT_DIR)
351
+ if cert_dir.directory? && cert_dir.subpath?(exec_prefix)
352
+ say "Adding SSL certificate directory #{cert_dir}"
353
+ cert_dir.find.each do |path|
354
+ next if path.directory?
355
+ builder.duplicate_to_exec_prefix(path)
356
+ end
357
+ builder.export("SSL_CERT_DIR", File.join(EXTRACT_ROOT, cert_dir.relative_path_from(exec_prefix).to_posix))
358
+ end
359
+ end
360
+
361
+ # Bundle Tcl/Tk library scripts if the Tk extension is loaded.
362
+ # tcl86.dll and tk86.dll are auto-detected by DLL scanning, but the
363
+ # Tcl/Tk script libraries (init.tcl etc.) must also be bundled so
364
+ # that Tcl can find them relative to the DLL at runtime.
365
+ if defined?(TclTkLib)
366
+ exec_prefix.glob("**/lib/tcl[0-9]*/init.tcl").each do |init_tcl|
367
+ tcl_lib_dir = init_tcl.dirname
368
+ next unless tcl_lib_dir.subpath?(exec_prefix)
369
+ say "Adding Tcl library files #{tcl_lib_dir}"
370
+ tcl_lib_dir.find.each do |path|
371
+ next if path.directory?
372
+ builder.duplicate_to_exec_prefix(path)
373
+ end
374
+ end
375
+
376
+ exec_prefix.glob("**/lib/tk[0-9]*/pkgIndex.tcl").each do |pkg_index|
377
+ tk_lib_dir = pkg_index.dirname
378
+ next unless tk_lib_dir.subpath?(exec_prefix)
379
+ say "Adding Tk library files #{tk_lib_dir}"
380
+ tk_lib_dir.find.each do |path|
381
+ next if path.directory?
382
+ builder.duplicate_to_exec_prefix(path)
383
+ end
384
+ end
385
+ end
386
+
315
387
  # Set environment variable
316
388
  builder.export("RUBYOPT", rubyopt)
317
389
  # Add the load path that are required with the correct path after
@@ -33,5 +33,12 @@ module Ocran
33
33
  def ruby_exe
34
34
  @ruby_exe ||= (RbConfig::CONFIG["ruby_install_name"] || "ruby") + exe_extname
35
35
  end
36
+
37
+ def all_core_dir
38
+ RbConfig::CONFIG
39
+ .slice("rubylibdir", "sitelibdir", "vendorlibdir")
40
+ .values
41
+ .map { |path| Pathname.new(path) }
42
+ end
36
43
  end
37
44
  end
@@ -49,7 +49,7 @@ module Ocran
49
49
  end
50
50
  str = "\x00".encode("UTF-16LE") * MAX_PATH
51
51
  handles.map do |handle|
52
- length = GetModuleFileNameW(handle, str, str.bytesize)
52
+ length = GetModuleFileNameW(handle, str, str.bytesize / 2)
53
53
  if length == 0
54
54
  raise "GetModuleFileNameW failed with error code #{GetLastError()}"
55
55
  end
@@ -8,7 +8,7 @@ module Ocran
8
8
  # instance of OcranBuilder.
9
9
  class StubBuilder
10
10
  Signature = [0x41, 0xb6, 0xba, 0x4e].freeze
11
- OP_END = 0
11
+
12
12
  OP_CREATE_DIRECTORY = 1
13
13
  OP_CREATE_FILE = 2
14
14
  OP_SETENV = 3
@@ -28,6 +28,34 @@ module Ocran
28
28
 
29
29
  attr_reader :data_size
30
30
 
31
+ # Clear invalid security directory entries from PE executables
32
+ # This is necessary because some linkers may set non-zero values in the
33
+ # security directory even when there is no actual digital signature
34
+ def self.clear_invalid_security_entry(file_path)
35
+ data = File.binread(file_path)
36
+ return unless data.size > 64 # Minimum PE header size
37
+
38
+ # Read DOS header to find PE header offset
39
+ e_lfanew_offset = 60
40
+ pe_offset = data[e_lfanew_offset, 4].unpack1("L")
41
+ return if pe_offset + 160 > data.size # Not enough room for headers
42
+
43
+ # Calculate security directory offset
44
+ # PE signature (4) + FILE_HEADER (20) + partial OPTIONAL_HEADER to DataDirectory
45
+ security_entry_offset = pe_offset + 4 + 20 + 128
46
+
47
+ # Read security directory entry (VirtualAddress and Size)
48
+ sec_addr = data[security_entry_offset, 4].unpack1("L")
49
+ sec_size = data[security_entry_offset + 4, 4].unpack1("L")
50
+
51
+ # Check if security entry is invalid (points beyond file or size is 0)
52
+ if sec_size != 0 && (sec_addr == 0 || sec_addr >= data.size || sec_addr + sec_size > data.size)
53
+ # Clear the invalid security entry
54
+ data[security_entry_offset, 8] = "\x00" * 8
55
+ File.binwrite(file_path, data)
56
+ end
57
+ end
58
+
31
59
  # chdir_before:
32
60
  # When set to true, the working directory is changed to the application's
33
61
  # deployment location at runtime.
@@ -65,6 +93,9 @@ module Ocran
65
93
  IO.copy_stream(gui_mode ? STUBW_PATH : STUB_PATH, stub)
66
94
  stub.close
67
95
 
96
+ # Clear any invalid security directory entries from the stub
97
+ self.class.clear_invalid_security_entry(stub.path)
98
+
68
99
  if icon_path
69
100
  system(EDICON_PATH, stub.path, icon_path.to_s, exception: true)
70
101
  end
@@ -77,7 +108,6 @@ module Ocran
77
108
 
78
109
  b = proc {
79
110
  yield(self)
80
- write_opcode(OP_END)
81
111
  }
82
112
 
83
113
  if enable_compression
@@ -184,13 +214,23 @@ module Ocran
184
214
  raise ArgumentError, "String length #{len} is too large: must be less than or equal to 65535 bytes including null terminator"
185
215
  end
186
216
 
187
- @of << [len, str].pack("vZ*")
188
- @data_size += 2 + len
217
+ write_size(len)
218
+ @of << [str].pack("Z*")
219
+ @data_size += len
189
220
  end
190
221
  private :write_string
191
222
 
192
223
  def write_string_array(*str_array)
193
224
  ary = str_array.map(&:to_s)
225
+
226
+ if ary.any?(&:empty?)
227
+ raise ArgumentError, "Argument list must not contain empty strings"
228
+ end
229
+
230
+ # Append an empty string so that when joined with "\0", the final buffer
231
+ # ends in two consecutive NUL bytes (double–NUL terminator) to mark end-of-list.
232
+ ary << ""
233
+
194
234
  size = ary.sum(0) { |s| s.bytesize + 1 }
195
235
  write_size(size)
196
236
  ary.each_slice(1) { |a| @of << a.pack("Z*") }
data/lib/ocran/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ocran
4
- VERSION = "1.3.16"
4
+ VERSION = "1.3.18"
5
5
  end
Binary file
data/share/ocran/stub.exe CHANGED
Binary file
Binary file
metadata CHANGED
@@ -1,21 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocran
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.16
4
+ version: 1.3.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andi Idogawa
8
8
  - Lars Christensen
9
- autorequire:
10
- bindir: bin
9
+ bindir: exe
11
10
  cert_chain: []
12
- date: 2024-08-05 00:00:00.000000000 Z
13
- dependencies: []
11
+ date: 1980-01-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fiddle
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
14
27
  description: "OCRAN (One-Click Ruby Application Next) builds Windows executables from
15
28
  Ruby source code. \n The executable is a self-extracting, self-running executable
16
29
  that contains the Ruby interpreter, your source code and any additionally needed
17
30
  ruby libraries or DLL.\n \n This is a fork of OCRA that is compatible with ruby
18
- version after 3.0.\n Migration guide: make sure to write ocran instead of ocra
31
+ version after 3.2.\n Migration guide: make sure to write ocran instead of ocra
19
32
  in your code. For instance: OCRAN_EXECUTABLE\n\n usage: \n ocra helloworld.rb\n
20
33
  \ helloworld.exe\n\n See readme at https://github.com/largo/ocran\n Report problems
21
34
  in the github issues. Contributions welcome.\n This gem contains executables. We
@@ -27,7 +40,10 @@ executables:
27
40
  extensions: []
28
41
  extra_rdoc_files: []
29
42
  files:
30
- - bin/ocran
43
+ - CHANGELOG.txt
44
+ - LICENSE.txt
45
+ - README.md
46
+ - exe/ocran
31
47
  - lib/ocran.rb
32
48
  - lib/ocran/build_constants.rb
33
49
  - lib/ocran/build_facade.rb
@@ -59,7 +75,6 @@ metadata:
59
75
  homepage_uri: https://github.com/largo/ocran
60
76
  source_code_uri: https://github.com/largo/ocran
61
77
  changelog_uri: https://github.com/largo/ocran/CHANGELOG.txt
62
- post_install_message:
63
78
  rdoc_options: []
64
79
  require_paths:
65
80
  - lib
@@ -67,15 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
82
  requirements:
68
83
  - - ">="
69
84
  - !ruby/object:Gem::Version
70
- version: 3.0.0
85
+ version: 3.2.0
71
86
  required_rubygems_version: !ruby/object:Gem::Requirement
72
87
  requirements:
73
88
  - - ">="
74
89
  - !ruby/object:Gem::Version
75
90
  version: '0'
76
91
  requirements: []
77
- rubygems_version: 3.5.3
78
- signing_key:
92
+ rubygems_version: 4.0.3
79
93
  specification_version: 4
80
94
  summary: OCRAN (One-Click Ruby Application Next) builds Windows executables from Ruby
81
95
  source code.
/data/{bin → exe}/ocran RENAMED
File without changes