ocra 1.1.4 → 1.1.5.pre1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,22 @@
1
+ === 1.1.5
2
+
3
+ * Ignore console events (Ctrl-C, Ctrl-Break). Ruby process handles
4
+ them anyway and exist, allowing the stub to clean up temporary
5
+ files.
6
+
7
+ * Temporary memory used for decompression is now freed before the ruby
8
+ interpreter is launched by the stub.
9
+
10
+ * Progress dialog is no longer displayed when removing temporary
11
+ files.
12
+
13
+ * Now includes most files from any require'd Rubygem (Now works with
14
+ mime-types, oledb and other gems that load additional data files
15
+ from the Gem installation). Some files are still ignored
16
+ (e.g. Readme's). Use "--no-gem-filter" to make Ocra unconditionally
17
+ include all files listed in the Gem specification (Thanks to Jorge
18
+ L. Cangas for patch & ideas).
19
+
1
20
  === 1.1.4
2
21
 
3
22
  * The tempdir marker is now pretty-printed as "<tempdir>" in the
data/README.txt CHANGED
@@ -25,7 +25,8 @@ in the forums there aswell.
25
25
 
26
26
  == TODO:
27
27
 
28
- * Clean up using manual recursive deletion (not SHop).
28
+ * Support for packaging gems that need extra non-ruby files
29
+ (e.g. mime-types, prawn).
29
30
 
30
31
  == SYNOPSIS:
31
32
 
data/Rakefile CHANGED
@@ -29,7 +29,7 @@ standalone_zip = "bin/ocrasa-#{ENV['VERSION']}.zip"
29
29
 
30
30
  file standalone_zip => 'bin/ocrasa.rb' do
31
31
  chdir 'bin' do
32
- system "zip ocrasa-#{ENV['VERSION']}.zip ocrasa.rb"
32
+ sh "zip", "ocrasa-#{ENV['VERSION']}.zip", "ocrasa.rb"
33
33
  end
34
34
  end
35
35
 
@@ -128,7 +128,7 @@ task :list_all_rubies do
128
128
  end
129
129
 
130
130
  task :release_docs => :redocs do
131
- sh "pscp -r doc/* ocra.rubyforge.org:/var/www/gforge-projects/ocra"
131
+ sh "pscp -r doc/* larsch@ocra.rubyforge.org:/var/www/gforge-projects/ocra"
132
132
  end
133
133
 
134
134
 
data/bin/ocra CHANGED
@@ -9,11 +9,25 @@ module Ocra
9
9
  OP_CREATE_PROCESS = 3
10
10
  OP_DECOMPRESS_LZMA = 4
11
11
  OP_SETENV = 5
12
+ OP_POST_CREATE_PROCESS = 6
12
13
 
13
- VERSION = "1.1.4"
14
+ VERSION = "1.1.5.pre1"
14
15
 
15
16
  IGNORE_MODULES = /^enumerator.so$/
16
17
 
18
+ IGNORE_GEMFILES = %r{(
19
+ # Auxiliary files in the root of the gem
20
+ ^(History|Install|Manifest|README|Licen[sc]e).(txt|rdoc)$ |
21
+ # Installation files in the root of the gem
22
+ ^(Rakefile|setup.rb|extconf.rb)$ |
23
+ # Documentation/test directories in the root of the gem
24
+ ^(doc|ext|examples|test|tests|benchmarks)\/ |
25
+ # Directories anywhere
26
+ (^|\/)(\.autotest|\.svn\.cvs)(\/|$) |
27
+ # Unlikely extensions
28
+ \.(rdoc)$/
29
+ )}xi
30
+
17
31
  PATH_SEPARATOR = /[\/\\]/
18
32
 
19
33
  TEMPDIR_MARKER = "\xFF"
@@ -29,6 +43,8 @@ module Ocra
29
43
  attr_accessor :quiet
30
44
  attr_accessor :autodll
31
45
  attr_accessor :show_warnings
46
+ attr_accessor :gem_filter
47
+
32
48
  attr_reader :lzmapath
33
49
  attr_reader :ediconpath
34
50
  attr_reader :stubimage
@@ -71,6 +87,7 @@ module Ocra
71
87
  quiet = false
72
88
  autodll = true
73
89
  show_warnings = true
90
+ gem_filter = true
74
91
 
75
92
  usage = <<EOF
76
93
  ocra [options] script.rb
@@ -84,6 +101,7 @@ ocra [options] script.rb
84
101
  --no-autoload Don't load/include script.rb's autoloads
85
102
  --icon <ico> Replace icon with a custom one
86
103
  --version Display version number
104
+ --no-gem-filter Don't filter uncommon files from gems (readme's, etc.)
87
105
  EOF
88
106
 
89
107
  while arg = argv.shift
@@ -110,6 +128,8 @@ EOF
110
128
  exit
111
129
  when /\A--no-warnings\z/
112
130
  show_warnings = false
131
+ when /\A--no-gem-filter\z/
132
+ gem_filter = false
113
133
  when /\A--help\z/, /\A--/
114
134
  puts usage
115
135
  exit
@@ -133,6 +153,7 @@ EOF
133
153
  @autodll = autodll
134
154
  @files = files
135
155
  @show_warnings = show_warnings
156
+ @gem_filter = gem_filter
136
157
  end
137
158
 
138
159
  def Ocra.init(argv)
@@ -223,6 +244,50 @@ EOF
223
244
  instsitelibdir = sitelibdir[exec_prefix.size+1..-1]
224
245
 
225
246
  load_path = []
247
+
248
+ # Detect loaded gems and add additional gem files to the
249
+ # executable. Ruby 1.8 provides Gem.loaded_specs to detect gems,
250
+ # but this is empty with Ruby 1.9. So instead, we look for any
251
+ # loaded file from a gem path.
252
+ if defined?(Gem)
253
+ gems = []
254
+ features_from_gems = []
255
+ features.each do |filename|
256
+ if filename !~ /^[a-z]:/i
257
+ filename = find_load_path($:, filename)
258
+ next if filename.nil? # Could be enumerator.so
259
+ end
260
+ Gem.path.each do |gempath|
261
+ geminstallpath = File.join(gempath, "gems")
262
+ if subpath?(filename, geminstallpath)
263
+ gemlocalpath = filename[geminstallpath.size+1..-1]
264
+ fullgemname = gemlocalpath.split('/')[0]
265
+ gems << [gempath, fullgemname]
266
+ features_from_gems << filename
267
+ end
268
+ end
269
+ end
270
+ gems.sort!.uniq!
271
+ gem_files = []
272
+ gems.each do |gempath, fullgemname|
273
+ gemspecpath = File.join(gempath, "specifications", fullgemname + ".gemspec")
274
+ gemspecs << gemspecpath
275
+ spec = Gem::Specification.load(gemspecpath)
276
+
277
+ # Get list of files
278
+ files = spec.files
279
+ # Filter out some unlikely files (Readme, etc.)
280
+ files = files.select { |filename| filename !~ IGNORE_GEMFILES } if Ocra.gem_filter
281
+ # Find the full path
282
+ files = files.map { |file| File.join(gempath, "gems", fullgemname, file) }
283
+
284
+ gem_files += files
285
+ end
286
+ gem_files.sort!.uniq!
287
+ features -= features_from_gems
288
+ else
289
+ gem_files = []
290
+ end
226
291
 
227
292
  # Find loaded files
228
293
  libs = []
@@ -255,6 +320,18 @@ EOF
255
320
  end
256
321
  end
257
322
 
323
+ # Add files from Gems
324
+ gem_files.each do |gemfile|
325
+ if subpath?(gemfile, exec_prefix)
326
+ libs << [ gemfile, relative_path(exec_prefix, gemfile) ]
327
+ elsif defined?(Gem) and gemhome = Gem.path.find { |pth| subpath?(gemfile, pth) }
328
+ targetpath = File.join("gemhome", relative_path(gemhome, fullpath))
329
+ libs << [ gemfile, targetpath ]
330
+ else
331
+ raise "Don't know where to put #{gemfile}"
332
+ end
333
+ end
334
+
258
335
  # Detect additional DLLs
259
336
  dlls = Ocra.autodll ? LibraryDetector.detect_dlls : []
260
337
 
@@ -310,8 +387,8 @@ EOF
310
387
  Ocra.extra_dlls.each do |dll|
311
388
  sb.createfile(File.join(bindir, dll), File.join("bin", dll).tr('/','\\'))
312
389
  end
313
-
314
- # Add gemspecs
390
+
391
+ # Add gemspec files
315
392
  gemspecs.each do |gemspec|
316
393
  if subpath?(gemspec, exec_prefix)
317
394
  path = gemspec[exec_prefix.size+1..-1]
@@ -335,7 +412,7 @@ EOF
335
412
  sb.setenv('GEM_PATH', "#{TEMPDIR_MARKER}\\gemhome")
336
413
 
337
414
  # Launch the script
338
- sb.createprocess(TEMPDIR_MARKER + "\\bin\\" + rubyexe, "#{rubyexe} \"\xff\\src\\" + File.basename(Ocra.files[0]) + "\"")
415
+ sb.postcreateprocess(TEMPDIR_MARKER + "\\bin\\" + rubyexe, "#{rubyexe} \"\xff\\src\\" + File.basename(Ocra.files[0]) + "\"")
339
416
 
340
417
  puts "=== Compressing" unless Ocra.quiet or not Ocra.lzma_mode
341
418
  end
@@ -450,6 +527,10 @@ EOF
450
527
  puts "l #{showtempdir image} #{showtempdir cmdline}" unless Ocra.quiet
451
528
  @of << [OP_CREATE_PROCESS, image, cmdline].pack("VZ*Z*")
452
529
  end
530
+ def postcreateprocess(image, cmdline)
531
+ puts "p #{showtempdir image} #{showtempdir cmdline}" unless Ocra.quiet
532
+ @of << [OP_POST_CREATE_PROCESS, image, cmdline].pack("VZ*Z*")
533
+ end
453
534
  def setenv(name, value)
454
535
  puts "e #{name} #{showtempdir value}" unless Ocra.quiet
455
536
  @of << [OP_SETENV, name, value].pack("VZ*Z*")
@@ -1,3 +1,3 @@
1
1
  class Ocra
2
- VERSION = '1.1.4'
2
+ VERSION = '1.1.5.pre1'
3
3
  end
Binary file
Binary file
Binary file
@@ -120,6 +120,15 @@ class TestOcra < Test::Unit::TestCase
120
120
  end
121
121
  end
122
122
 
123
+ # Should be able to build executables with LZMA compression
124
+ def test_lzma
125
+ with_fixture 'helloworld' do
126
+ assert system("ruby", ocra, "helloworld.rb", "--quiet", "--lzma")
127
+ assert File.exist?("helloworld.exe")
128
+ assert system("helloworld.exe")
129
+ end
130
+ end
131
+
123
132
  # Test that executables can writing a file to the current working
124
133
  # directory.
125
134
  def test_writefile
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocra
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
5
- prerelease: false
4
+ hash: -769618389
5
+ prerelease: true
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 4
10
- version: 1.1.4
9
+ - 5
10
+ - pre1
11
+ version: 1.1.5.pre1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Lars Christensen
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2010-08-04 00:00:00 +02:00
19
+ date: 2010-08-15 00:00:00 +02:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -99,12 +100,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
100
  required_rubygems_version: !ruby/object:Gem::Requirement
100
101
  none: false
101
102
  requirements:
102
- - - ">="
103
+ - - ">"
103
104
  - !ruby/object:Gem::Version
104
- hash: 3
105
+ hash: 25
105
106
  segments:
106
- - 0
107
- version: "0"
107
+ - 1
108
+ - 3
109
+ - 1
110
+ version: 1.3.1
108
111
  requirements: []
109
112
 
110
113
  rubyforge_project: ocra