packager 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Packager
2
+
3
+ Packager is a Ruby Gem that builds one-click installer packages
4
+ of your gem for Mac OS X and Windows.
5
+
6
+ ## Requirements
7
+
8
+ **Windows:** MinGW Ruby install (such as [One-Click RubyInstaller](http://rubyinstaller.org/)) and [Inno Setup](http://www.jrsoftware.org/isdl.php)
9
+
10
+ **Mac OS X:** Universal binary version of Ruby ([Learn More](https://github.com/wagenet/packager/wiki/Ruby-Universal-Binary-Installation)) and possibly the OS X Developer Tools
11
+
12
+ ## Usage
13
+
14
+ In your project's Rakefile
15
+
16
+ Packager::RakeTask.new(:pkg) do |t|
17
+ t.package_name = "My Project"
18
+ t.version = "1.0.0"
19
+ t.domain = "myproject.com"
20
+ t.bin_files = ["utility", "helper"]
21
+ t.resource_files = ["images", "README"]
22
+ end
23
+
24
+ ## Known Issues
25
+
26
+ * Requires a git repo for your project (git ls-files is used internally)
27
+ * Limited configuration
28
+ * No installer styling options
29
+ * When uninstalling from Windows Ruby Uninstaller isn't run properly,
30
+ though this shouldn't actually cause any problems.
31
+
32
+ ## Credits
33
+
34
+ * Peter Wagenet
35
+ * Yehuda Katz
data/lib/packager.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Packager
2
-
2
+ RESOURCES_PATH = File.expand_path('../../resources', __FILE__)
3
3
  end
@@ -0,0 +1,164 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+ require 'erb'
4
+ require 'rbconfig'
5
+ require 'packager'
6
+
7
+ module Packager
8
+ module Rake
9
+ class BaseTask < ::Rake::TaskLib
10
+
11
+ attr_accessor :version
12
+
13
+ attr_accessor :package_name
14
+
15
+ attr_accessor :short_package_name
16
+
17
+ attr_accessor :domain
18
+
19
+ attr_accessor :bin_files
20
+
21
+ attr_accessor :resource_files
22
+
23
+ def initialize
24
+ @domain = 'gemcutter.org'
25
+ @bin_files = []
26
+ @resource_files = []
27
+ @package_name, @short_package_name = nil
28
+
29
+ yield self if block_given?
30
+
31
+ if !@package_name || @package_name.empty?
32
+ raise "package_name is required"
33
+ end
34
+
35
+ @short_package_name ||= package_name.downcase.gsub(/\W+/,'-')
36
+ end
37
+
38
+ def ruby_bin_path
39
+ nil
40
+ end
41
+
42
+ private
43
+
44
+ def setup_bundler
45
+ require 'bundler/shared_helpers'
46
+
47
+ unless Bundler::SharedHelpers.in_bundle?
48
+ raise "Must be in a Bundler bundle"
49
+ end
50
+
51
+ require 'bundler'
52
+
53
+ begin
54
+ Bundler.setup
55
+ rescue Bundler::GemNotFound
56
+ # Do nothing yet, since we don't actually care
57
+ end
58
+
59
+ # Add bundler to the load path after disabling system gems
60
+ bundler_lib = File.expand_path("../..", __FILE__)
61
+ $LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib)
62
+ end
63
+
64
+ def create_bundle_file_task(&block)
65
+ file "#{package_name}/local/#{short_package_name}/bundle" => "Gemfile" do
66
+ block.call if block
67
+
68
+ setup_bundler
69
+
70
+ unless RUBY_VERSION == "1.9.2"
71
+ puts "Please use Ruby 1.9.2"
72
+ exit 1
73
+ end
74
+
75
+ puts "Regenerating the bundle."
76
+
77
+ rm_rf "bundle"
78
+ rm_rf ".bundle"
79
+ rm_rf "#{short_package_name}-pkg"
80
+ rm "#{package_name}.pkg", :force => true
81
+ Bundler.with_clean_env do
82
+ sh "bundle --standalone --without development"
83
+ end
84
+ mkdir_p "#{package_name}/local/#{short_package_name}"
85
+ cp_r "bundle", "#{package_name}/local/#{short_package_name}/"
86
+
87
+ verbose(false) do
88
+ Dir.chdir("#{package_name}/local/#{short_package_name}/bundle/ruby/1.9.1") do
89
+ Dir["{bin,cache,doc,specifications}"].each { |f| rm_rf f }
90
+ Dir["**/{ext,docs,test,spec}"].each { |f| rm_rf(f) if File.directory?(f) && f !~ /maruku/i }
91
+ Dir["**/erubis-*/doc-api"].each {|f| rm_rf(f) }
92
+ end
93
+ end
94
+ end
95
+ end
96
+
97
+ def create_lib_file_task
98
+ file "#{package_name}/local/#{short_package_name}/lib"
99
+
100
+ `git ls-files -- lib`.split("\n").each do |file|
101
+ # submodules show up as a single file
102
+ files = File.directory?(file) ? Dir["#{file}/**/*"] : [file]
103
+
104
+ files.each do |f|
105
+ dest = "#{package_name}/local/#{short_package_name}/#{f}"
106
+ file dest => f do
107
+ verbose(false) { mkdir_p File.dirname(dest) }
108
+ cp_r f, dest
109
+ end
110
+ task "#{package_name}/local/#{short_package_name}/lib" => dest
111
+ end
112
+ end
113
+ end
114
+
115
+ def create_bin_files_task
116
+ bin_files.each do |bin_name|
117
+ path = "#{package_name}/bin/#{bin_name}"
118
+ file path => "bin/#{bin_name}" do
119
+ data = File.read("bin/#{bin_name}").sub(/\A#.*/, "#!#{ruby_bin_path}") if ruby_bin_path
120
+
121
+ mkdir_p "#{package_name}/bin"
122
+ File.open(path, "w") { |file| file.puts data }
123
+ File.chmod 0755, path
124
+ end
125
+ end
126
+ end
127
+
128
+ def create_resource_files_task
129
+ resource_files.each do |resource_name|
130
+ file "#{package_name}/local/#{short_package_name}/#{resource_name}" => resource_name do
131
+ destdir = "#{package_name}/local/#{short_package_name}/#{File.dirname(resource_name)}"
132
+ mkdir_p destdir
133
+ cp_r resource_name, destdir
134
+ target = "#{package_name}/local/#{short_package_name}/#{resource_name}"
135
+ if File.directory?(target)
136
+ Dir.glob(target).each{|f| File.chmod 0655 unless File.directory?(f) }
137
+ else
138
+ File.chmod 0644, target
139
+ end
140
+ end
141
+ end
142
+ end
143
+
144
+ def make_pkg_tasks
145
+ tasks = ["#{package_name}/local/#{short_package_name}/bundle",
146
+ "#{package_name}/local/#{short_package_name}/lib"]
147
+ tasks += bin_files.map{|b| "#{package_name}/bin/#{b}" }
148
+ tasks += resource_files.map{|r| "#{package_name}/local/#{short_package_name}/#{r}" }
149
+ end
150
+
151
+ def create_make_pkg_task
152
+ task :make_pkg => make_pkg_tasks
153
+ end
154
+
155
+ def create_rm_task
156
+ # TODO: Remove more fully
157
+ task :rm do
158
+ rm_rf package_name
159
+ end
160
+ end
161
+
162
+ end
163
+ end
164
+ end
@@ -0,0 +1,129 @@
1
+ require 'packager/rake/base_task'
2
+
3
+ module Packager
4
+ module Rake
5
+ class MacTask < BaseTask
6
+
7
+ def initialize(*)
8
+ super
9
+
10
+ create_bundle_file_task do
11
+ unless RbConfig::CONFIG["target_cpu"] == "universal"
12
+ puts "Please use a universal binary copy of ruby"
13
+ exit 1
14
+ end
15
+ end
16
+ create_lib_file_task
17
+ create_bin_files_task
18
+ create_resource_files_task
19
+ create_make_pkg_task
20
+ create_rm_task
21
+ create_directory_tasks
22
+ create_distribution_file_task
23
+ create_package_info_file_task
24
+ create_bom_file_task
25
+ create_payload_file_task
26
+ create_pkg_task
27
+
28
+ desc "Package for Mac OS X"
29
+ task :pkg => "#{package_name}.pkg"
30
+
31
+ desc "Clean and Package for Mac OS X"
32
+ task :clean => [:rm, :pkg]
33
+ end
34
+
35
+ def reverse_domain
36
+ @reverse_domain ||= domain.split(".").reverse.join(".")
37
+ end
38
+
39
+ def total_size
40
+ get_details unless @total_size
41
+ @total_size
42
+ end
43
+
44
+ def num_files
45
+ get_details unless @num_files
46
+ @num_files
47
+ end
48
+
49
+ def kbytes
50
+ total_size / 1024
51
+ end
52
+
53
+ def ruby_bin_path
54
+ "/usr/local/ruby1.9/bin/ruby -I /usr/local/#{short_package_name}/bundle -r bundler/setup"
55
+ end
56
+
57
+ private
58
+
59
+ # HELPERS
60
+
61
+ def get_details
62
+ @total_size, @num_files = 0, 0
63
+
64
+ Dir["#{package_name}/**/*"].each do |file|
65
+ @num_files += 1
66
+
67
+ next if File.directory?(file)
68
+
69
+ @total_size += File.size(file)
70
+ end
71
+ end
72
+
73
+ # TASK DEFINITIONS
74
+
75
+ def create_directory_tasks
76
+ directory "#{short_package_name}-pkg/Resources"
77
+ directory "#{short_package_name}-pkg/#{short_package_name}.pkg"
78
+ end
79
+
80
+ def create_distribution_file_task
81
+ erb_path = File.join(RESOURCES_PATH, "Distribution.erb")
82
+
83
+ file "#{short_package_name}-pkg/Distribution" do
84
+ src = File.read erb_path
85
+ erb = ERB.new(src)
86
+
87
+ File.open("#{short_package_name}-pkg/Distribution", "w") do |file|
88
+ file.puts erb.result(binding)
89
+ end
90
+ end
91
+ end
92
+
93
+ def create_package_info_file_task
94
+ erb_path = File.join(RESOURCES_PATH, "PackageInfo.erb")
95
+
96
+ file "#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo" do
97
+ src = File.read erb_path
98
+ erb = ERB.new(src)
99
+
100
+ File.open("#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo", "w") do |file|
101
+ file.puts erb.result(binding)
102
+ end
103
+ end
104
+ end
105
+
106
+ def create_bom_file_task
107
+ file "#{short_package_name}-pkg/#{short_package_name}.pkg/Bom" do
108
+ sh "mkbom -s #{package_name} #{short_package_name}-pkg/#{short_package_name}.pkg/Bom"
109
+ end
110
+ end
111
+
112
+ def create_payload_file_task
113
+ file "#{short_package_name}-pkg/#{short_package_name}.pkg/Payload" do
114
+ sh "cd #{package_name} && pax -wz -x cpio . > ../#{short_package_name}-pkg/#{short_package_name}.pkg/Payload"
115
+ end
116
+ end
117
+
118
+ def create_pkg_task
119
+ pkg_dependencies = [:make_pkg, "#{short_package_name}-pkg/Resources", "#{short_package_name}-pkg/#{short_package_name}.pkg",
120
+ "#{short_package_name}-pkg/Distribution", "#{short_package_name}-pkg/#{short_package_name}.pkg/Bom",
121
+ "#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo", "#{short_package_name}-pkg/#{short_package_name}.pkg/Payload"]
122
+
123
+ file "#{package_name}.pkg" => pkg_dependencies do
124
+ sh "pkgutil --flatten #{short_package_name}-pkg #{package_name}.pkg"
125
+ end
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,119 @@
1
+ require 'packager/rake/base_task'
2
+
3
+ module Packager
4
+ module Rake
5
+ class WindowsTask < BaseTask
6
+
7
+ attr_accessor :path_constant
8
+
9
+ def initialize(*)
10
+ super
11
+
12
+ @path_constant ||= "#{package_name.gsub(/\s+/,'')}Path"
13
+
14
+ create_bundle_file_task do
15
+ unless RbConfig::CONFIG["host_os"] =~ /mingw32/
16
+ puts "Please use a mingw32 copy of ruby"
17
+ exit 1
18
+ end
19
+ end
20
+ create_lib_file_task
21
+ create_bin_files_task
22
+ create_bin_file_aliases_task
23
+ create_resource_files_task
24
+ create_make_pkg_task
25
+ create_rm_task
26
+
27
+ create_ruby_download_task
28
+ create_iss_task
29
+ create_pkg_task
30
+
31
+ desc "Package for Windows"
32
+ task :pkg => "#{package_name}.exe"
33
+
34
+ desc "Clean and Package for Windows"
35
+ task :clean => [:rm, :pkg]
36
+ end
37
+
38
+ def ruby_bin_path
39
+ "\"%#{path_constant}%/ruby/bin/ruby.exe\" -I \"%#{path_constant}%/local/#{short_package_name}/bundle\" -r bundler/setup"
40
+ end
41
+
42
+ private
43
+
44
+ def create_bin_file_aliases_task
45
+ bin_files.each do |bin_name|
46
+ path = "#{package_name}/bin/#{bin_name}.bat"
47
+ file path => "bin/#{bin_name}" do
48
+ File.open(path, "w") do |f|
49
+ f.puts <<END
50
+ @ECHO OFF
51
+ IF NOT "%~f0" == "~f0" GOTO :WinNT
52
+ @#{ruby_bin_path} "#{bin_name}" %1 %2 %3 %4 %5 %6 %7 %8 %9
53
+ GOTO :EOF
54
+ :WinNT
55
+ @#{ruby_bin_path} "%~dpn0" %*
56
+ END
57
+ end
58
+ File.chmod 0755, path
59
+ end
60
+ end
61
+ end
62
+
63
+ def create_ruby_download_task
64
+ installer_path = "#{package_name}/rubyinstaller.exe"
65
+
66
+ task :download_ruby do
67
+ unless File.exist?(installer_path)
68
+ mkdir_p File.dirname(installer_path)
69
+
70
+ puts "Downloading rubyinstaller.exe"
71
+
72
+ require 'net/http'
73
+ Net::HTTP.start("packager.strobeapp.com") do |http|
74
+ File.open(installer_path, 'wb') do |f|
75
+ http.request_get('/rubyinstaller.exe') do |resp|
76
+ resp.read_body do |segment|
77
+ print '.'
78
+ f.write(segment)
79
+ end
80
+ end
81
+ end
82
+ end
83
+
84
+ puts "Done"
85
+ end
86
+ end
87
+ end
88
+
89
+ def create_iss_task
90
+ erb_path = File.join(RESOURCES_PATH, "packager.iss.erb")
91
+
92
+ file "#{package_name}/packager.iss" do
93
+ src = File.read erb_path
94
+ erb = ERB.new(src)
95
+
96
+ File.open("#{package_name}/packager.iss", "w") do |file|
97
+ file.puts erb.result(binding)
98
+ end
99
+ end
100
+ end
101
+
102
+ def make_pkg_tasks
103
+ super + bin_files.map{|b| "#{package_name}/bin/#{b}.bat" }
104
+ end
105
+
106
+ def create_pkg_task
107
+ file "#{package_name}.exe" => [:make_pkg, :download_ruby, "#{package_name}/packager.iss"] do
108
+ inno_dir = ENV['INNO_DIR'] || "C:\\Program Files\\Inno Setup 5\\"
109
+ inno_dir += '\\' unless inno_dir[-1..-1] == '\\'
110
+
111
+ puts "Compiling. This may take a while..."
112
+ sh %{"#{inno_dir}Compil32.exe" /cc "#{package_name}\\packager.iss"}
113
+ mv "#{package_name}/Output/setup.exe", "#{package_name}.exe"
114
+ end
115
+ end
116
+
117
+ end
118
+ end
119
+ end
@@ -1,279 +1,28 @@
1
+ require 'rbconfig'
1
2
  require 'rake'
2
3
  require 'rake/tasklib'
3
- require 'erb'
4
4
 
5
5
  module Packager
6
6
  class RakeTask < ::Rake::TaskLib
7
7
 
8
- # Name of task.
9
- #
10
- # default:
11
- # :pkg
12
- attr_accessor :name
13
-
14
- # Namespace for tasks.
15
- #
16
- # default:
17
- # :packager
18
- attr_accessor :group
19
-
20
- attr_accessor :version
21
-
22
- attr_accessor :package_name
23
-
24
- attr_accessor :short_package_name
25
-
26
- attr_accessor :domain
27
-
28
- attr_accessor :bin_files
29
-
30
- attr_accessor :resource_files
31
-
32
- def initialize(name=:pkg)
33
- @name = name
34
- @group = :packager
35
- @domain = 'gemcutter.org'
36
- @bin_files = []
37
- @resource_files = []
38
- @package_name, @short_package_name = nil
39
-
40
- yield self if block_given?
41
-
42
- if !@package_name || @package_name.empty?
43
- raise "package_name is required"
44
- end
45
-
46
- @short_package_name ||= package_name.downcase.gsub(/\W+/,'-')
47
-
8
+ def initialize(name=:pkg, group=:packager, &block)
48
9
  namespace group do
49
- bundle_file_task
50
- lib_file_task
51
- bin_files_task
52
- resource_files_task
53
- make_pkg_task
54
- rm_task
55
- directory_tasks
56
- distribution_file_task
57
- package_info_file_task
58
- bom_file_task
59
- payload_file_task
60
- pkg_task
61
-
62
- desc "Package for Mac OS X"
63
- task :pkg => "#{package_name}.pkg"
64
-
65
- desc "Clean and Package for Mac OS X"
66
- task :clean => [:rm, :pkg]
67
- end
68
-
69
- desc "Package for Mac OS X"
70
- task name => "#{group}:pkg"
71
- end
72
-
73
- def reverse_domain
74
- @reverse_domain ||= domain.split(".").reverse.join(".")
75
- end
76
-
77
- def total_size
78
- get_details unless @total_size
79
- @total_size
80
- end
81
-
82
- def num_files
83
- get_details unless @num_files
84
- @num_files
85
- end
86
-
87
- def kbytes
88
- total_size / 1024
89
- end
90
-
91
- private
92
-
93
- # HELPERS
94
-
95
- def pkg_dependencies
96
- [:make_pkg, "#{short_package_name}-pkg/Resources", "#{short_package_name}-pkg/#{short_package_name}.pkg",
97
- "#{short_package_name}-pkg/Distribution", "#{short_package_name}-pkg/#{short_package_name}.pkg/Bom",
98
- "#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo", "#{short_package_name}-pkg/#{short_package_name}.pkg/Payload"]
99
- end
100
-
101
- def get_details
102
- @total_size, @num_files = 0, 0
103
-
104
- Dir["#{package_name}/**/*"].each do |file|
105
- @num_files += 1
106
-
107
- next if File.directory?(file)
108
-
109
- @total_size += File.size(file)
110
- end
111
- end
112
-
113
- def setup_bundler
114
- require 'bundler/shared_helpers'
115
-
116
- unless Bundler::SharedHelpers.in_bundle?
117
- raise "Must be in a Bundler bundle"
118
- end
119
-
120
- require 'bundler'
121
-
122
- begin
123
- Bundler.setup
124
- rescue Bundler::GemNotFound
125
- # Do nothing yet, since we don't actually care
126
- end
127
-
128
- # Add bundler to the load path after disabling system gems
129
- bundler_lib = File.expand_path("../..", __FILE__)
130
- $LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib)
131
- end
132
-
133
- # TASK DEFINITIONS
134
-
135
- def bundle_file_task
136
- file "#{package_name}/local/#{short_package_name}/bundle" => "Gemfile" do
137
- require "rbconfig"
138
-
139
- setup_bundler
140
-
141
- unless Config::CONFIG["target_cpu"] == "universal"
142
- puts "Please use a universal binary copy of ruby"
143
- exit 1
144
- end
145
-
146
- unless RUBY_VERSION == "1.9.2"
147
- puts "Please use Ruby 1.9.2"
148
- exit 1
149
- end
150
-
151
- puts "Regenerating the bundle."
152
-
153
- sh "rm -rf bundle"
154
- sh "rm -rf .bundle"
155
- sh "rm -rf #{short_package_name}-pkg"
156
- sh "rm -f #{package_name}.pkg"
157
- Bundler.with_clean_env do
158
- sh "bundle --standalone --without development"
159
- end
160
- sh "mkdir -p #{package_name}/local/#{short_package_name}"
161
- sh "cp -R bundle #{package_name}/local/#{short_package_name}/"
162
-
163
- verbose(false) do
164
- Dir.chdir("#{package_name}/local/#{short_package_name}/bundle/ruby/1.9.1") do
165
- Dir["{bin,cache,doc,specifications}"].each { |f| rm_rf f }
166
- Dir["**/{ext,docs,test,spec}"].each { |f| rm_rf(f) if File.directory?(f) && f !~ /maruku/i }
167
- Dir["**/erubis-*/doc-api"].each {|f| rm_rf(f) }
168
- end
169
- end
170
- end
171
- end
172
-
173
- def lib_file_task
174
- file "#{package_name}/local/#{short_package_name}/lib"
175
-
176
- `git ls-files -- lib`.split("\n").each do |file|
177
- dest = "#{package_name}/local/#{short_package_name}/#{file}"
178
- file dest => file do
179
- verbose(false) { mkdir_p File.dirname(dest) }
180
- cp_r file, dest
181
- end
182
- task "#{package_name}/local/#{short_package_name}/lib" => dest
183
- end
184
- end
185
-
186
- def bin_files_task
187
- bin_files.each do |bin_name|
188
- file "#{package_name}/bin/#{bin_name}" => "bin/#{bin_name}" do
189
- data = File.read("bin/#{bin_name}").sub(/\A#.*/, "#!/usr/local/ruby1.9/bin/ruby -I /usr/local/#{short_package_name}/bundle -r bundler/setup")
190
-
191
- sh "mkdir -p #{package_name}/bin"
192
- File.open("#{package_name}/bin/#{bin_name}", "w") { |file| file.puts data }
193
- File.chmod 0755, "#{package_name}/bin/#{bin_name}"
194
- end
195
- end
196
- end
197
-
198
- def resource_files_task
199
- resource_files.each do |resource_name|
200
- file "#{package_name}/local/#{short_package_name}/#{resource_name}" => resource_name do
201
- destdir = "#{package_name}/local/#{short_package_name}/#{File.dirname(resource_name)}"
202
- sh "mkdir -p #{destdir}"
203
- sh "cp -R #{resource_name} #{destdir}"
204
- target = "#{package_name}/local/#{short_package_name}/#{resource_name}"
205
- if File.directory?(target)
206
- Dir.glob(target).each{|f| File.chmod 0655 unless File.directory?(f) }
207
- else
208
- File.chmod 0644, target
209
- end
210
- end
211
- end
212
- end
213
-
214
- def make_pkg_task
215
- pkg_tasks = ["#{package_name}/local/#{short_package_name}/bundle",
216
- "#{package_name}/local/#{short_package_name}/lib"]
217
- pkg_tasks += bin_files.map{|b| "#{package_name}/bin/#{b}" }
218
- pkg_tasks += resource_files.map{|r| "#{package_name}/local/#{short_package_name}/#{r}" }
219
-
220
- task :make_pkg => pkg_tasks
221
- end
222
-
223
- def rm_task
224
- task :rm do
225
- rm_rf package_name
226
- end
227
- end
228
-
229
- def directory_tasks
230
- directory "#{short_package_name}-pkg/Resources"
231
- directory "#{short_package_name}-pkg/#{short_package_name}.pkg"
232
- end
233
-
234
- def distribution_file_task
235
- erb_path = File.expand_path("../build/Distribution.erb", __FILE__)
236
-
237
- file "#{short_package_name}-pkg/Distribution" do
238
- src = File.read erb_path
239
- erb = ERB.new(src)
240
-
241
- File.open("#{short_package_name}-pkg/Distribution", "w") do |file|
242
- file.puts erb.result(binding)
10
+ case os = RbConfig::CONFIG['host_os']
11
+ when /mswin|windows|cygwin|mingw/i
12
+ require 'packager/rake/windows_task'
13
+ Packager::Rake::WindowsTask.new(&block)
14
+ when /darwin/i
15
+ require 'packager/rake/mac_task'
16
+ Packager::Rake::MacTask.new(&block)
17
+ else
18
+ task :pkg do
19
+ puts "Don't know how to package for: #{os}"
243
20
  end
244
21
  end
245
22
  end
246
23
 
247
- def package_info_file_task
248
- erb_path = File.expand_path("../build/PackageInfo.erb", __FILE__)
249
-
250
- file "#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo" do
251
- src = File.read erb_path
252
- erb = ERB.new(src)
253
-
254
- File.open("#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo", "w") do |file|
255
- file.puts erb.result(binding)
256
- end
257
- end
258
- end
259
-
260
- def bom_file_task
261
- file "#{short_package_name}-pkg/#{short_package_name}.pkg/Bom" do
262
- sh "mkbom -s #{package_name} #{short_package_name}-pkg/#{short_package_name}.pkg/Bom"
263
- end
264
- end
265
-
266
- def payload_file_task
267
- file "#{short_package_name}-pkg/#{short_package_name}.pkg/Payload" do
268
- sh "cd #{package_name} && pax -wz -x cpio . > ../#{short_package_name}-pkg/#{short_package_name}.pkg/Payload"
269
- end
270
- end
271
-
272
- def pkg_task
273
- file "#{package_name}.pkg" => pkg_dependencies do
274
- sh "pkgutil --flatten #{short_package_name}-pkg #{package_name}.pkg"
275
- end
276
- end
24
+ task name => "#{group}:pkg"
25
+ end
277
26
 
278
27
  end
279
28
  end
@@ -1,4 +1,4 @@
1
1
  module Packager
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
4
4
 
File without changes
File without changes
@@ -0,0 +1,46 @@
1
+ [Setup]
2
+ AppName=<%= package_name %>
3
+ AppVersion=<%= version %>
4
+ DefaultDirName={pf}\<%= package_name %>
5
+ DefaultGroupName=<%= package_name %>
6
+ Compression=lzma2
7
+ SolidCompression=yes
8
+ ; For Ruby expansion ~ 32MB (installed) - 12MB (installer)
9
+ ExtraDiskSpaceRequired=20971520
10
+
11
+ [Files]
12
+ Source: "rubyinstaller.exe"; DestDir: "{tmp}";
13
+ Source: "bin\*.*"; DestDir: "{app}\bin"; Flags: recursesubdirs;
14
+ Source: "local\*.*"; DestDir: "{app}\local"; Flags: recursesubdirs;
15
+
16
+ [UninstallDelete]
17
+ Type: filesandordirs; Name: "{app}\ruby"
18
+
19
+ [Registry]
20
+ Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: "string"; ValueName: "<%= path_constant %>"; \
21
+ ValueData: "{app}";
22
+ Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"; ValueType: "expandsz"; ValueName: "Path"; \
23
+ ValueData: "{olddata};{app}\bin"; Check: NeedsAddPath(ExpandConstant('{app}\bin'))
24
+
25
+ [Run]
26
+ Filename: "{tmp}\rubyinstaller.exe"; Parameters: "/silent /nocancel /noicons /dir=""{app}/ruby"""; \
27
+ Flags: shellexec waituntilterminated; StatusMsg: "Installing Ruby";
28
+
29
+ [Code]
30
+
31
+ function NeedsAddPath(Param: string): boolean;
32
+ var
33
+ OrigPath: string;
34
+ begin
35
+ if not RegQueryStringValue(HKEY_LOCAL_MACHINE,
36
+ 'SYSTEM\CurrentControlSet\Control\Session Manager\Environment',
37
+ 'Path', OrigPath)
38
+ then begin
39
+ Result := True;
40
+ exit;
41
+ end;
42
+ // look for the path with leading and trailing semicolon
43
+ // Pos() returns 0 if not found
44
+ Result := Pos(';' + Param + ';', ';' + OrigPath + ';') = 0;
45
+ end;
46
+
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: packager
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.3
5
+ version: 0.0.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Yehuda Katz
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-05-08 00:00:00 Z
14
+ date: 2011-06-09 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -35,12 +35,17 @@ extensions: []
35
35
  extra_rdoc_files: []
36
36
 
37
37
  files:
38
+ - README.md
38
39
  - lib/packager.rb
39
- - lib/packager/build/Distribution.erb
40
- - lib/packager/build/PackageInfo.erb
40
+ - lib/packager/rake/base_task.rb
41
+ - lib/packager/rake/mac_task.rb
42
+ - lib/packager/rake/windows_task.rb
41
43
  - lib/packager/rake_task.rb
42
44
  - lib/packager/version.rb
43
45
  - packager.gemspec
46
+ - resources/Distribution.erb
47
+ - resources/PackageInfo.erb
48
+ - resources/packager.iss.erb
44
49
  homepage:
45
50
  licenses: []
46
51
 
@@ -64,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
69
  requirements: []
65
70
 
66
71
  rubyforge_project:
67
- rubygems_version: 1.7.2
72
+ rubygems_version: 1.8.5
68
73
  signing_key:
69
74
  specification_version: 3
70
75
  summary: Packager your gem for Mac OS X