packager 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/packager/build/Distribution.erb +24 -0
- data/lib/packager/build/PackageInfo.erb +3 -0
- data/lib/packager/rake_task.rb +229 -0
- data/lib/packager/version.rb +4 -0
- data/lib/packager.rb +3 -0
- data/packager.gemspec +24 -0
- metadata +72 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<installer-script minSpecVersion="1.000000" authoringTool="org.ruby-lang.rake" authoringToolVersion="0.8.7">
|
3
|
+
<title><%= package_name %></title>
|
4
|
+
<options customize="never" allow-external-scripts="no"/>
|
5
|
+
<domains enable_localSystem="true"/>
|
6
|
+
<script>
|
7
|
+
function ruby19p136_installed() {
|
8
|
+
return !(system.files.fileExistsAtPath('/usr/local/ruby1.9') == true);
|
9
|
+
}
|
10
|
+
</script>
|
11
|
+
<choices-outline>
|
12
|
+
<line choice="ruby19p136"/>
|
13
|
+
<line choice="<%= short_package_name %>"/>
|
14
|
+
</choices-outline>
|
15
|
+
<choice id="ruby19p136" title="ruby" start_selected="false" start_enabled="false" selected="ruby19p136_installed()" enabled="ruby19p136_installed()">
|
16
|
+
<pkg-ref id="com.strobecorp.ruby19"/>
|
17
|
+
</choice>
|
18
|
+
<choice id="<%= short_package_name %>" title="<%= package_name %>">
|
19
|
+
<pkg-ref id="<%= reverse_domain %>.<%= short_package_name %>"/>
|
20
|
+
</choice>
|
21
|
+
<pkg-ref id="com.strobecorp.ruby19" installKBytes="26156" archiveKBytes="7353" hash-sha256="7b9507f7a9178c0eaafd3ffcfd2e246400e82899e6f29df2f7c4fcec6ec04ac5" version="1.9.2p136" auth="Root">http://ruby-pkg.strobeapp.com/Ruby-1.9.2p136.pkg</pkg-ref>
|
22
|
+
<pkg-ref id="<%= reverse_domain %>.<%= short_package_name %>" installKBytes="<%= kbytes %>" version="<%= version %>" auth="Root">#<%= short_package_name %>.pkg</pkg-ref>
|
23
|
+
</installer-script>
|
24
|
+
|
@@ -0,0 +1,229 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/tasklib'
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'erb'
|
5
|
+
|
6
|
+
module Packager
|
7
|
+
class RakeTask < ::Rake::TaskLib
|
8
|
+
|
9
|
+
# Name of task.
|
10
|
+
#
|
11
|
+
# default:
|
12
|
+
# :pkg
|
13
|
+
attr_accessor :name
|
14
|
+
|
15
|
+
# Namespace for tasks.
|
16
|
+
#
|
17
|
+
# default:
|
18
|
+
# :packager
|
19
|
+
attr_accessor :group
|
20
|
+
|
21
|
+
attr_accessor :version
|
22
|
+
|
23
|
+
attr_accessor :package_name
|
24
|
+
|
25
|
+
attr_accessor :short_package_name
|
26
|
+
|
27
|
+
attr_accessor :domain
|
28
|
+
|
29
|
+
attr_accessor :bin_files
|
30
|
+
|
31
|
+
def initialize(name=:pkg)
|
32
|
+
@name = name
|
33
|
+
@group = :packager
|
34
|
+
@domain = 'gemcutter.org'
|
35
|
+
@bin_files = []
|
36
|
+
@package_name, @short_package_name = nil
|
37
|
+
|
38
|
+
yield self if block_given?
|
39
|
+
|
40
|
+
@short_package_name ||= package_name.downcase.gsub(/\W+/,'-')
|
41
|
+
|
42
|
+
namespace group do
|
43
|
+
bundle_file_task
|
44
|
+
lib_file_task
|
45
|
+
bin_file_task
|
46
|
+
make_pkg_task
|
47
|
+
rm_task
|
48
|
+
directory_tasks
|
49
|
+
distribution_file_task
|
50
|
+
package_info_file_task
|
51
|
+
bom_file_task
|
52
|
+
payload_file_task
|
53
|
+
pkg_task
|
54
|
+
|
55
|
+
desc "Package for Mac OS X"
|
56
|
+
task :pkg => "#{package_name}.pkg"
|
57
|
+
|
58
|
+
desc "Clean and Package for Mac OS X"
|
59
|
+
task :clean => [:rm, :pkg]
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "Package for Mac OS X"
|
63
|
+
task name => "#{group}:pkg"
|
64
|
+
end
|
65
|
+
|
66
|
+
def reverse_domain
|
67
|
+
@reverse_domain ||= domain.split(".").reverse.join(".")
|
68
|
+
end
|
69
|
+
|
70
|
+
def total_size
|
71
|
+
get_details unless @total_size
|
72
|
+
@total_size
|
73
|
+
end
|
74
|
+
|
75
|
+
def num_files
|
76
|
+
get_details unless @num_files
|
77
|
+
@num_files
|
78
|
+
end
|
79
|
+
|
80
|
+
def kbytes
|
81
|
+
total_size / 1024
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
# HELPERS
|
87
|
+
|
88
|
+
def pkg_dependencies
|
89
|
+
[:make_pkg, "#{package_name}-pkg/Resources", "#{package_name}-pkg/#{package_name}.pkg",
|
90
|
+
"#{package_name}-pkg/Distribution", "#{package_name}-pkg/#{package_name}.pkg/Bom",
|
91
|
+
"#{package_name}-pkg/#{package_name}.pkg/PackageInfo", "#{package_name}-pkg/#{package_name}.pkg/Payload"]
|
92
|
+
end
|
93
|
+
|
94
|
+
def get_details
|
95
|
+
@total_size, @num_files = 0, 0
|
96
|
+
|
97
|
+
Dir["#{package_name}/**/*"].each do |file|
|
98
|
+
@num_files += 1
|
99
|
+
|
100
|
+
next if File.directory?(file)
|
101
|
+
|
102
|
+
@total_size += File.size(file)
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# TASK DEFINITIONS
|
107
|
+
|
108
|
+
def bundle_file_task
|
109
|
+
file "#{package_name}/local/#{short_package_name}/bundle" => "Gemfile" do
|
110
|
+
require "rbconfig"
|
111
|
+
|
112
|
+
unless Config::CONFIG["target_cpu"] == "universal"
|
113
|
+
puts "Please use a universal binary copy of ruby"
|
114
|
+
exit 1
|
115
|
+
end
|
116
|
+
|
117
|
+
unless RUBY_VERSION == "1.9.2"
|
118
|
+
puts "Please use Ruby 1.9.2"
|
119
|
+
exit 1
|
120
|
+
end
|
121
|
+
|
122
|
+
puts "Regenerating the bundle."
|
123
|
+
|
124
|
+
sh "rm -rf bundle"
|
125
|
+
sh "rm -rf .bundle"
|
126
|
+
sh "rm -rf #{short_package_name}-pkg"
|
127
|
+
sh "rm -f #{package_name}.pkg"
|
128
|
+
Bundler.with_clean_env do
|
129
|
+
sh "bundle --standalone --without development"
|
130
|
+
end
|
131
|
+
sh "mkdir -p #{package_name}/local/#{short_package_name}"
|
132
|
+
sh "cp -R bundle #{package_name}/local/#{short_package_name}/"
|
133
|
+
|
134
|
+
verbose(false) do
|
135
|
+
Dir.chdir("#{package_name}/local/#{short_package_name}/bundle/ruby/1.9.1") do
|
136
|
+
Dir["{bin,cache,doc,specifications}"].each { |f| rm_rf f }
|
137
|
+
Dir["**/{ext,docs,test,spec}"].each { |f| rm_rf(f) if File.directory?(f) && f !~ /maruku/i }
|
138
|
+
Dir["**/erubis-*/doc-api"].each {|f| rm_rf(f) }
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def lib_file_task
|
145
|
+
file "#{package_name}/local/#{short_package_name}/lib"
|
146
|
+
|
147
|
+
`git ls-files -- lib`.split("\n").each do |file|
|
148
|
+
dest = "#{package_name}/local/#{short_package_name}/#{file}"
|
149
|
+
file dest => file do
|
150
|
+
verbose(false) { mkdir_p File.dirname(dest) }
|
151
|
+
cp_r file, dest
|
152
|
+
end
|
153
|
+
task "#{package_name}/local/#{short_package_name}/lib" => dest
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def bin_file_task
|
158
|
+
for bin_name in bin_files
|
159
|
+
file "#{package_name}/bin/#{bin_name}" => "bin/#{bin_name}" do
|
160
|
+
binary = File.read("bin/#{bin_name}").sub(/\A#.*/, "#!/usr/local/ruby1.9/bin/ruby -I /usr/local/#{short_package_name}/bundle -r bundler/setup")
|
161
|
+
|
162
|
+
sh "mkdir -p #{package_name}/bin"
|
163
|
+
File.open("#{package_name}/bin/#{bin_name}", "w") { |file| file.puts binary }
|
164
|
+
File.chmod 0755, "#{package_name}/bin/#{bin_name}"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
def make_pkg_task
|
170
|
+
pkg_tasks = ["#{package_name}/local/#{short_package_name}/bundle",
|
171
|
+
"#{package_name}/local/#{short_package_name}/lib"]
|
172
|
+
pkg_tasks += bin_files.map{|b| "#{package_name}/bin/#{b}" }
|
173
|
+
|
174
|
+
task :make_pkg => pkg_tasks
|
175
|
+
end
|
176
|
+
|
177
|
+
def rm_task
|
178
|
+
task :rm do
|
179
|
+
rm_rf package_name
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def directory_tasks
|
184
|
+
directory "#{short_package_name}-pkg/Resources"
|
185
|
+
directory "#{short_package_name}-pkg/#{short_package_name}.pkg"
|
186
|
+
end
|
187
|
+
|
188
|
+
def distribution_file_task
|
189
|
+
file "#{short_package_name}-pkg/Distribution" do
|
190
|
+
src = File.read File.expand_path("../build/Distribution.erb", __FILE__)
|
191
|
+
erb = ERB.new(src)
|
192
|
+
|
193
|
+
File.open("#{short_package_name}-pkg/Distribution", "w") do |file|
|
194
|
+
file.puts erb.result(binding)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def package_info_file_task
|
200
|
+
file "#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo" do
|
201
|
+
src = File.read File.expand_path("../build/PackageInfo.erb", __FILE__)
|
202
|
+
erb = ERB.new(src)
|
203
|
+
|
204
|
+
File.open("#{short_package_name}-pkg/#{short_package_name}.pkg/PackageInfo", "w") do |file|
|
205
|
+
file.puts erb.result(binding)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def bom_file_task
|
211
|
+
file "#{short_package_name}-pkg/#{short_package_name}.pkg/Bom" do
|
212
|
+
sh "mkbom -s #{package_name} #{short_package_name}-pkg/#{short_package_name}.pkg/Bom"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
def payload_file_task
|
217
|
+
file "#{short_package_name}-pkg/#{short_package_name}.pkg/Payload" do
|
218
|
+
sh "cd #{package_name} && pax -wz -x cpio . > ../#{short_package_name}-pkg/#{short_package_name}.pkg/Payload"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def pkg_task
|
223
|
+
file "#{package_name}.pkg" => pkg_dependencies do
|
224
|
+
sh "pkgutil --flatten #{short_package_name}-pkg #{package_name}.pkg"
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
end
|
229
|
+
end
|
data/lib/packager.rb
ADDED
data/packager.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
3
|
+
$:.unshift lib unless $:.include?(lib)
|
4
|
+
|
5
|
+
require 'packager/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "packager"
|
9
|
+
s.version = Packager::VERSION
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.authors = ["Yehuda Katz", "Peter Wagenet"]
|
12
|
+
s.email = ["wycats@gmail.com", "peter.wagenet@gmail.com"]
|
13
|
+
s.summary = %q{Packager your gem for Mac OS X}
|
14
|
+
s.description = %q{A tool for creating a standalone Mac OS X .pkg of your gem.}
|
15
|
+
|
16
|
+
s.required_rubygems_version = ">= 1.3.6"
|
17
|
+
|
18
|
+
s.add_dependency "bundler", "~> 1.1.pre.4"
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
23
|
+
|
24
|
+
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: packager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yehuda Katz
|
9
|
+
- Peter Wagenet
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-05-07 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: bundler
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ~>
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 1.1.pre.4
|
25
|
+
type: :runtime
|
26
|
+
version_requirements: *id001
|
27
|
+
description: A tool for creating a standalone Mac OS X .pkg of your gem.
|
28
|
+
email:
|
29
|
+
- wycats@gmail.com
|
30
|
+
- peter.wagenet@gmail.com
|
31
|
+
executables: []
|
32
|
+
|
33
|
+
extensions: []
|
34
|
+
|
35
|
+
extra_rdoc_files: []
|
36
|
+
|
37
|
+
files:
|
38
|
+
- lib/packager.rb
|
39
|
+
- lib/packager/build/Distribution.erb
|
40
|
+
- lib/packager/build/PackageInfo.erb
|
41
|
+
- lib/packager/rake_task.rb
|
42
|
+
- lib/packager/version.rb
|
43
|
+
- packager.gemspec
|
44
|
+
homepage:
|
45
|
+
licenses: []
|
46
|
+
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.3.6
|
64
|
+
requirements: []
|
65
|
+
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.7.2
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Packager your gem for Mac OS X
|
71
|
+
test_files: []
|
72
|
+
|