packup 0.0.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.md +7 -0
- data/README.md +37 -0
- data/lib/packup.rb +281 -0
- data/packup.gemspec +25 -0
- data/rakefile.rb +42 -0
- data/templates/product.wxs.erb +47 -0
- data/test/behavior_test.rb +30 -0
- data/test/msi_test.rb +20 -0
- data/test/packup_test.rb +68 -0
- data/test/sourcery_test.rb +30 -0
- data/test/tasks_test.rb +79 -0
- data/test/wixobj_test.rb +18 -0
- data/test/wxs_test.rb +96 -0
- metadata +83 -0
data/LICENSE.md
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2012 Frank Mitchell
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
Packup
|
2
|
+
======
|
3
|
+
|
4
|
+
Packup is a Rake helper for building Windows installers. It helps you write simple MSI packages.
|
5
|
+
|
6
|
+
Synopsis
|
7
|
+
--------
|
8
|
+
|
9
|
+
Write a Rakefile:
|
10
|
+
|
11
|
+
require 'packup'
|
12
|
+
|
13
|
+
Packup.stuff 'Magic' do
|
14
|
+
author 'Wizard'
|
15
|
+
version '1.0.0'
|
16
|
+
|
17
|
+
file 'src/README' => '/docs/readme.txt'
|
18
|
+
file 'src/wand.exe' => '/bin/wand.exe'
|
19
|
+
end
|
20
|
+
|
21
|
+
Build a MSI and install it:
|
22
|
+
|
23
|
+
% rake msi
|
24
|
+
% msiexec /i wix\Magic.msi
|
25
|
+
|
26
|
+
Dependencies
|
27
|
+
------------
|
28
|
+
|
29
|
+
Packup requires the [WiX Toolset][wix] be installed, and the binaries be reachable from the PATH environment variable.
|
30
|
+
|
31
|
+
License
|
32
|
+
-------
|
33
|
+
|
34
|
+
Packup is available under an [MIT-style][mit] license. See the {file:LICENSE.md} document for more information.
|
35
|
+
|
36
|
+
[wix]: http://wixtoolset.org/ "The WiX toolset builds Windows installation packages from XML source code."
|
37
|
+
[mit]: http://opensource.org/license/MIT "Open Source Initiative OSI - The MIT License"
|
data/lib/packup.rb
ADDED
@@ -0,0 +1,281 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
class Packup
|
5
|
+
##
|
6
|
+
# In a pre-alpha state at the moment.
|
7
|
+
|
8
|
+
VERSION = '0.0.1.pre'
|
9
|
+
|
10
|
+
##
|
11
|
+
# Excutes the Packup DSL to define your package's definition
|
12
|
+
# (which internalliy creates Rake tasks). All Packup attributes and
|
13
|
+
# methods are available within +block+. Eg:
|
14
|
+
#
|
15
|
+
# Packup.stuff name do
|
16
|
+
# # ... package specific data ...
|
17
|
+
# end
|
18
|
+
|
19
|
+
def self.stuff name, &block
|
20
|
+
package = self.new name
|
21
|
+
package.instance_eval &block if block_given?
|
22
|
+
package.post_process
|
23
|
+
package
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# *MANDATORY*: The name of the package.
|
28
|
+
#
|
29
|
+
# Set with Packup.stuff.
|
30
|
+
|
31
|
+
attr_reader :name
|
32
|
+
|
33
|
+
##
|
34
|
+
# Optional: Files the package will install.
|
35
|
+
|
36
|
+
attr_reader :files
|
37
|
+
|
38
|
+
##
|
39
|
+
# Creates a newly initialized package description.
|
40
|
+
|
41
|
+
def initialize name
|
42
|
+
@name = name
|
43
|
+
@version = nil
|
44
|
+
@author = nil
|
45
|
+
@files = {}
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Returns the package's version. Sets the version to +value+ if given.
|
50
|
+
|
51
|
+
def version value = nil
|
52
|
+
return @version if value.nil?
|
53
|
+
@version = value
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# Returns the package's author. Sets the author to +value+ if given.
|
58
|
+
|
59
|
+
def author value = nil
|
60
|
+
return @author if value.nil?
|
61
|
+
@author = value
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Adds files to the package. +values+ is a Hash from source to
|
66
|
+
# destination. Eg:
|
67
|
+
#
|
68
|
+
# file 'source/file' => 'destination/file'
|
69
|
+
#
|
70
|
+
# or
|
71
|
+
#
|
72
|
+
# file {
|
73
|
+
# 'src/wand.exe' => 'bin/wand.exe',
|
74
|
+
# 'src/wand.chm' => 'doc/wand.chm'
|
75
|
+
# }
|
76
|
+
#
|
77
|
+
# Implicitly, this creates Rake tasks to copy the files from source to
|
78
|
+
# destination. You can skip the creation of those tasks by manually
|
79
|
+
# placing your files in the <tt>wix/src</tt> folder. Eg:
|
80
|
+
#
|
81
|
+
# task :setup do
|
82
|
+
# mkpath 'wix/src'
|
83
|
+
# cp_r 'src', 'wix/src'
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# Packup.stuff 'Magic'
|
87
|
+
#
|
88
|
+
# Rake::Task['wix/Sourcery.wxs'].enhance [:setup]
|
89
|
+
|
90
|
+
def file values
|
91
|
+
@files.merge! values
|
92
|
+
end
|
93
|
+
|
94
|
+
##
|
95
|
+
# Finalizes the package description.
|
96
|
+
|
97
|
+
def post_process
|
98
|
+
bind_files
|
99
|
+
make_tasks
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# Makes all destination file paths relative to INSTALLDIR.
|
104
|
+
|
105
|
+
def bind_files
|
106
|
+
@files.each do |source, destination|
|
107
|
+
@files[source] = File.join('wix', 'src', destination)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
##
|
112
|
+
# Generates all the Rake tasks.
|
113
|
+
|
114
|
+
def make_tasks
|
115
|
+
make_clean_task
|
116
|
+
make_wix_folder_task
|
117
|
+
make_copy_file_tasks
|
118
|
+
make_sourcery_wxs_file_task
|
119
|
+
make_sourcery_wixobj_file_task
|
120
|
+
make_product_wxs_file_task
|
121
|
+
make_product_wixobj_file_task
|
122
|
+
make_msi_file_task
|
123
|
+
make_msi_task
|
124
|
+
make_test_task
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Generates the :clean task, which deletes all the generated files.
|
129
|
+
|
130
|
+
def make_clean_task
|
131
|
+
return if Rake::Task.task_defined? :clean
|
132
|
+
task = Rake::Task.define_task :clean do
|
133
|
+
FileUtils.remove_dir 'wix', true
|
134
|
+
end
|
135
|
+
task.comment = 'Remove the WiX folder'
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Generates the 'wix' task.
|
140
|
+
|
141
|
+
def make_wix_folder_task
|
142
|
+
return if Rake::FileTask.task_defined? 'wix'
|
143
|
+
wix = Rake::FileTask.define_task 'wix' do |t|
|
144
|
+
FileUtils.mkpath t.name
|
145
|
+
end
|
146
|
+
wix.comment = 'Create the WiX folder'
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Generates tasks to copy files from source to destination. One task
|
151
|
+
# is generated for each file. Destination file tasks trigger source
|
152
|
+
# file tasks if they exist. So you can preprocess files. Eg:
|
153
|
+
#
|
154
|
+
# file 'magic.min.js' do
|
155
|
+
# sh 'compress magic.js > magic.min.js'
|
156
|
+
# end
|
157
|
+
#
|
158
|
+
# Packup.stuff 'Magic' do
|
159
|
+
# file 'magic.min.js' => 'scripts/magic.min.js'
|
160
|
+
# end
|
161
|
+
|
162
|
+
def make_copy_file_tasks
|
163
|
+
@files.each do |source, destination|
|
164
|
+
next if Rake::FileTask.task_defined? destination
|
165
|
+
type = File.directory?(source) ? 'folder' : 'file'
|
166
|
+
task = Rake::FileTask.define_task destination do |t|
|
167
|
+
folder = File.dirname(t.name)
|
168
|
+
FileUtils.mkpath folder unless File.directory? folder
|
169
|
+
FileUtils.copy source, t.name
|
170
|
+
end
|
171
|
+
task.comment = "Create the #{destination} #{type}"
|
172
|
+
task.enhance ['wix']
|
173
|
+
if Rake::FileTask.task_defined? source
|
174
|
+
task.enhance [source]
|
175
|
+
end
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
##
|
180
|
+
# Generates the 'wix/Sourcery.wxs' task.
|
181
|
+
|
182
|
+
def make_sourcery_wxs_file_task
|
183
|
+
return if Rake::FileTask.task_defined? 'wix/Sourcery.wxs'
|
184
|
+
sourcery = Rake::FileTask.define_task 'wix/Sourcery.wxs' do |t|
|
185
|
+
if File.directory? 'wix/src'
|
186
|
+
args = []
|
187
|
+
args << '-nologo' # Skip printing of the WiX logo
|
188
|
+
args << '-sfrag' # Suppress fragments
|
189
|
+
args << '-srd' # Don't harvest the root directory e.g. wix\src
|
190
|
+
args << '-ag' # Auto generate GUIDs
|
191
|
+
args << '-ke' # Keep empty directories
|
192
|
+
args << '-template fragment'
|
193
|
+
args << '-dr INSTALLDIR'
|
194
|
+
args << '-var var.Source'
|
195
|
+
args = args.join(' ')
|
196
|
+
Rake.sh "heat dir wix/src #{args} -out #{t.name}"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
sourcery.comment = 'Create the Sourcery.wxs file'
|
200
|
+
sourcery.enhance ['wix']
|
201
|
+
sourcery.enhance @files.values
|
202
|
+
end
|
203
|
+
|
204
|
+
##
|
205
|
+
# Generates the 'wix/Sourcery.wixobj' task.
|
206
|
+
|
207
|
+
def make_sourcery_wixobj_file_task
|
208
|
+
return unless Rake::FileTask.task_defined? 'wix/Sourcery.wxs'
|
209
|
+
wixobj = Rake::FileTask.define_task 'wix/Sourcery.wixobj' do |t|
|
210
|
+
Rake.sh "candle -nologo wix/Sourcery.wxs -dSource=wix/src -o #{t.name}"
|
211
|
+
end
|
212
|
+
wixobj.comment = 'Create the Sourcery.wixobj file'
|
213
|
+
wixobj.enhance ['wix/Sourcery.wxs']
|
214
|
+
end
|
215
|
+
|
216
|
+
##
|
217
|
+
# Generates the 'wix/name.wxs' task.
|
218
|
+
|
219
|
+
def make_product_wxs_file_task
|
220
|
+
return if Rake::FileTask.task_defined? "wix/#{name}.wxs"
|
221
|
+
wxs = Rake::FileTask.define_task "wix/#{name}.wxs" do |t|
|
222
|
+
template_file = File.join(File.dirname(__FILE__), '..', 'templates', 'product.wxs.erb')
|
223
|
+
template_data = File.read template_file
|
224
|
+
template = ERB.new template_data
|
225
|
+
template_results = template.result send(:binding)
|
226
|
+
File.open(t.name, 'w') { |io| io << template_results }
|
227
|
+
end
|
228
|
+
wxs.comment = "Create the #{name}.wxs file"
|
229
|
+
wxs.enhance ['wix']
|
230
|
+
if Rake::FileTask.task_defined? 'wix/Sourcery.wxs'
|
231
|
+
wxs.enhance ['wix/Sourcery.wxs']
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
##
|
236
|
+
# Generates the 'wix/name.wixobj' task.
|
237
|
+
|
238
|
+
def make_product_wixobj_file_task
|
239
|
+
return if Rake::FileTask.task_defined? "wix/#{name}.wixobj"
|
240
|
+
wixobj = Rake::FileTask.define_task "wix/#{name}.wixobj" do |t|
|
241
|
+
Rake.sh "candle -nologo wix/#{name}.wxs -o #{t.name}"
|
242
|
+
end
|
243
|
+
wixobj.comment = "Create the #{name}.wixobj file"
|
244
|
+
wixobj.enhance ["wix/#{name}.wxs"]
|
245
|
+
end
|
246
|
+
|
247
|
+
##
|
248
|
+
# Generates the 'wix/name.msi' task.
|
249
|
+
|
250
|
+
def make_msi_file_task
|
251
|
+
return if Rake::FileTask.task_defined? "wix/#{name}.msi"
|
252
|
+
wixobjs = Rake::FileTask.tasks.select { |t| t.name.end_with? '.wixobj' }
|
253
|
+
wixobjs.map! { |t| t.name }
|
254
|
+
msi = Rake::FileTask.define_task "wix/#{name}.msi" do |t|
|
255
|
+
Rake.sh "light -nologo -sval #{wixobjs.join(' ')} -o #{t.name}"
|
256
|
+
end
|
257
|
+
msi.comment = "Create the #{name}.msi file"
|
258
|
+
msi.enhance wixobjs
|
259
|
+
end
|
260
|
+
|
261
|
+
##
|
262
|
+
# Generates the :msi task, which creates the MSI.
|
263
|
+
|
264
|
+
def make_msi_task
|
265
|
+
return if Rake::Task.task_defined? :msi
|
266
|
+
msi = Rake::Task.define_task :msi
|
267
|
+
msi.comment = "Create the MSI"
|
268
|
+
msi.enhance ["wix/#{name}.msi"]
|
269
|
+
end
|
270
|
+
|
271
|
+
##
|
272
|
+
# Generates the :test task, wich validates the MSI.
|
273
|
+
|
274
|
+
def make_test_task
|
275
|
+
return if Rake::Task.task_defined? :test
|
276
|
+
test = Rake::Task.define_task :test do
|
277
|
+
Rake.sh "smoke -nologo wix/#{name}.msi"
|
278
|
+
end
|
279
|
+
test.comment = 'Validate the MSI'
|
280
|
+
end
|
281
|
+
end
|
data/packup.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
|
2
|
+
|
3
|
+
require 'packup'
|
4
|
+
|
5
|
+
spec = Gem::Specification.new do |s|
|
6
|
+
s.name = 'packup'
|
7
|
+
s.version = Packup::VERSION
|
8
|
+
s.required_ruby_version = '~> 1.9'
|
9
|
+
|
10
|
+
s.summary = 'A Rake helper for building Windows installers'
|
11
|
+
s.description = 'This gem provides a simple DSL for making MSI packages.'
|
12
|
+
|
13
|
+
s.requirements << 'WiX Toolset, v3.6 or greater'
|
14
|
+
s.add_runtime_dependency 'rake', '~> 0.9.2'
|
15
|
+
|
16
|
+
s.author = 'Frank Mitchell'
|
17
|
+
s.email = 'me@frankmitchell.org'
|
18
|
+
s.homepage = 'https://github.com/elimossinary/packup'
|
19
|
+
s.license = 'MIT'
|
20
|
+
|
21
|
+
s.files = `git ls-files`.split("\n")
|
22
|
+
s.files.reject! { |file| file =~ /^\./ }
|
23
|
+
|
24
|
+
s.test_files = `git ls-files -- test/*_test.rb`.split("\n")
|
25
|
+
end
|
data/rakefile.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/clean'
|
5
|
+
|
6
|
+
CLEAN.include '*.gem'
|
7
|
+
|
8
|
+
task :default => :test
|
9
|
+
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Build the gem'
|
17
|
+
task :build do
|
18
|
+
sh "gem build #{gemspec_file}"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Install the gem'
|
22
|
+
task :install do
|
23
|
+
sh "gem install ./#{name}-#{version}.gem"
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'Uninstall the gem'
|
27
|
+
task :uninstall do
|
28
|
+
sh "gem uninstall #{name}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def name
|
32
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
33
|
+
end
|
34
|
+
|
35
|
+
def version
|
36
|
+
line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
|
37
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemspec_file
|
41
|
+
"#{name}.gemspec"
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
3
|
+
<Product
|
4
|
+
Id="*"
|
5
|
+
Language="1033"
|
6
|
+
Name="<%= name %>"
|
7
|
+
Version="<%= version %>"
|
8
|
+
Manufacturer="<%= author %>"
|
9
|
+
UpgradeCode="<%=
|
10
|
+
require 'digest/md5'
|
11
|
+
hex = Digest::MD5.hexdigest(name).upcase.scan(/.{4}/)
|
12
|
+
hex[0,2] = hex[0,2].join('')
|
13
|
+
hex[-3,3] = hex[-3,3].join('')
|
14
|
+
hex.join('-')
|
15
|
+
%>"
|
16
|
+
>
|
17
|
+
|
18
|
+
<Package Compressed="yes" />
|
19
|
+
<MediaTemplate EmbedCab="yes" />
|
20
|
+
|
21
|
+
<FeatureRef Id="<%= name %>Feature" />
|
22
|
+
</Product>
|
23
|
+
|
24
|
+
<Fragment>
|
25
|
+
<Directory Id="TARGETDIR" Name="SourceDir">
|
26
|
+
<Directory Id="ProgramFilesFolder">
|
27
|
+
<Directory Id="ManufacturerFolder" Name="<%= author %>">
|
28
|
+
<Directory Id="INSTALLDIR" Name="<%= name %>" />
|
29
|
+
</Directory>
|
30
|
+
</Directory>
|
31
|
+
</Directory>
|
32
|
+
</Fragment>
|
33
|
+
|
34
|
+
<% unless @files.empty? %>
|
35
|
+
<Fragment>
|
36
|
+
<Feature Id="<%= name %>Feature" Level="1">
|
37
|
+
<% require 'rexml/document' %>
|
38
|
+
<% wxs = REXML::Document.new File.read('wix/Sourcery.wxs') %>
|
39
|
+
<% components = REXML::XPath.match wxs, '//Component' %>
|
40
|
+
<% components.map! { |part| part.attributes['Id'] } %>
|
41
|
+
<% components.each do |id| %>
|
42
|
+
<ComponentRef Id="<%= id %>" />
|
43
|
+
<% end %>
|
44
|
+
</Feature>
|
45
|
+
</Fragment>
|
46
|
+
<% end %>
|
47
|
+
</Wix>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'packup'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class PackupBehaviorTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Rake::Task.clear
|
7
|
+
FileUtils.remove_dir 'wix', true
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_wix_task_creates_wix_folder
|
11
|
+
Packup.stuff 'Magic'
|
12
|
+
Rake::Task['wix'].invoke
|
13
|
+
assert File.exists? 'wix'
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_clean_task_removes_wix_folder
|
17
|
+
Packup.stuff 'Magic'
|
18
|
+
Rake::Task['wix'].invoke
|
19
|
+
Rake::Task[:clean].invoke
|
20
|
+
assert !File.exists?('wix')
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_absolute_install_path_becomes_relative
|
24
|
+
Packup.stuff 'Magic' do
|
25
|
+
file 'README.md' => '/doc/README.md'
|
26
|
+
end
|
27
|
+
Rake::Task['wix/src/doc/README.md'].invoke
|
28
|
+
assert File.exists? 'wix/src/doc/README.md'
|
29
|
+
end
|
30
|
+
end
|
data/test/msi_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'packup'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class PackupMsiTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Rake::Task.clear
|
7
|
+
FileUtils.remove_dir 'wix', true
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_msi_file_gets_created
|
11
|
+
Packup.stuff 'Magic' do
|
12
|
+
version '1.0.0'
|
13
|
+
author 'Wizard'
|
14
|
+
file 'README.md' => 'README.md'
|
15
|
+
end
|
16
|
+
Rake::Task[:msi].invoke
|
17
|
+
Rake::Task[:test].invoke
|
18
|
+
assert File.exists? 'wix/Magic.msi'
|
19
|
+
end
|
20
|
+
end
|
data/test/packup_test.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'packup'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class PackupTest < Test::Unit::TestCase
|
5
|
+
def test_has_name_outside_block
|
6
|
+
package = Packup.stuff 'Magic'
|
7
|
+
assert_equal 'Magic', package.name
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_has_name_inside_block
|
11
|
+
inside = nil
|
12
|
+
Packup.stuff 'Magic' do
|
13
|
+
inside = name
|
14
|
+
end
|
15
|
+
assert_equal 'Magic', inside
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_set_version
|
19
|
+
inside = nil
|
20
|
+
Packup.stuff 'Magic' do
|
21
|
+
version '1.0.0'
|
22
|
+
inside = version
|
23
|
+
end
|
24
|
+
assert_equal '1.0.0', inside
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_default_version
|
28
|
+
inside = 0
|
29
|
+
Packup.stuff 'Magic' do
|
30
|
+
inside = version
|
31
|
+
end
|
32
|
+
assert_nil inside
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_set_author
|
36
|
+
inside = nil
|
37
|
+
Packup.stuff 'Magic' do
|
38
|
+
author 'Wizard'
|
39
|
+
inside = author
|
40
|
+
end
|
41
|
+
assert_equal 'Wizard', inside
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_default_author
|
45
|
+
inside = 0
|
46
|
+
Packup.stuff 'Magic' do
|
47
|
+
inside = author
|
48
|
+
end
|
49
|
+
assert_nil inside
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_set_files
|
53
|
+
inside = nil
|
54
|
+
Packup.stuff 'Magic' do
|
55
|
+
file 'rabbit.txt' => 'hat.txt'
|
56
|
+
inside = files
|
57
|
+
end
|
58
|
+
assert_equal 'wix/src/hat.txt', inside['rabbit.txt']
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_default_files
|
62
|
+
inside = nil
|
63
|
+
Packup.stuff 'Magic' do
|
64
|
+
inside = files
|
65
|
+
end
|
66
|
+
assert_equal 0, inside.length
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'packup'
|
2
|
+
require 'rexml/document'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class PackupSourceryTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Rake::Task.clear
|
8
|
+
FileUtils.remove_dir 'wix', true
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_sourcery_file_has_sources
|
12
|
+
Packup.stuff 'Magic' do
|
13
|
+
file 'README.md' => 'README.md'
|
14
|
+
end
|
15
|
+
Rake::Task['wix/Sourcery.wxs'].invoke
|
16
|
+
wxs = REXML::Document.new File.read('wix/Sourcery.wxs')
|
17
|
+
element = REXML::XPath.first(wxs, "//File")
|
18
|
+
assert '$(var.Source)\README.md', element.attributes['Source']
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_sourcery_finds_existing_files
|
22
|
+
FileUtils.mkpath 'wix/src'
|
23
|
+
FileUtils.copy 'README.md', 'wix/src/README.md'
|
24
|
+
Packup.stuff 'Magic'
|
25
|
+
Rake::Task['wix/Sourcery.wxs'].invoke
|
26
|
+
wxs = REXML::Document.new File.read('wix/Sourcery.wxs')
|
27
|
+
element = REXML::XPath.first(wxs, "//File")
|
28
|
+
assert '$(var.Source)\README.md', element.attributes['Source']
|
29
|
+
end
|
30
|
+
end
|
data/test/tasks_test.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'packup'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class PackupTasksTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Rake::Task.clear
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_creates_wix_folder_task
|
10
|
+
Packup.stuff 'Magic'
|
11
|
+
assert Rake::FileTask.task_defined? 'wix'
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_create_wxs_file_task
|
15
|
+
Packup.stuff 'Magic'
|
16
|
+
assert Rake::FileTask.task_defined? 'wix/Magic.wxs'
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_create_wixobj_file_task
|
20
|
+
Packup.stuff 'Magic'
|
21
|
+
assert Rake::FileTask.task_defined? 'wix/Magic.wixobj'
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_create_msi_file_task
|
25
|
+
Packup.stuff 'Magic'
|
26
|
+
assert Rake::FileTask.task_defined? 'wix/Magic.msi'
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_bind_source_file_task_if_exists
|
30
|
+
Rake::FileTask.define_task 'README.md' do
|
31
|
+
FileUtils.touch 'README.md'
|
32
|
+
end
|
33
|
+
Packup.stuff 'Magic' do
|
34
|
+
file 'README.md' => 'README.md'
|
35
|
+
end
|
36
|
+
reqs = Rake::FileTask['wix/src/README.md'].prerequisites
|
37
|
+
assert_equal ['wix', 'README.md'], reqs
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_skip_source_file_task_if_not_exists
|
41
|
+
Packup.stuff 'Magic' do
|
42
|
+
file 'README.md' => 'README.md'
|
43
|
+
end
|
44
|
+
reqs = Rake::FileTask['wix/src/README.md'].prerequisites
|
45
|
+
assert_equal ['wix'], reqs
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_create_destination_file_task
|
49
|
+
Packup.stuff 'Magic' do
|
50
|
+
file 'README.md' => 'README.md'
|
51
|
+
end
|
52
|
+
assert Rake::FileTask.task_defined? 'wix/src/README.md'
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_create_sourcery_wxs_task
|
56
|
+
Packup.stuff 'Magic'
|
57
|
+
assert Rake::FileTask.task_defined? 'wix/Sourcery.wxs'
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_create_sourcery_wixobj_task
|
61
|
+
Packup.stuff 'Magic'
|
62
|
+
assert Rake::FileTask.task_defined?('wix/Sourcery.wixobj')
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_create_clean_task
|
66
|
+
Packup.stuff 'Magic'
|
67
|
+
assert Rake::Task.task_defined? :clean
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_create_msi_task
|
71
|
+
Packup.stuff 'Magic'
|
72
|
+
assert Rake::Task.task_defined? :msi
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_create_test_task
|
76
|
+
Packup.stuff 'Magic'
|
77
|
+
assert Rake::Task.task_defined? :test
|
78
|
+
end
|
79
|
+
end
|
data/test/wixobj_test.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'packup'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class PackupWixobjTest < Test::Unit::TestCase
|
5
|
+
def setup
|
6
|
+
Rake::Task.clear
|
7
|
+
FileUtils.remove_dir 'wix', true
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_wixobj_file_gets_created
|
11
|
+
Packup.stuff 'Magic' do
|
12
|
+
version '1.0.0'
|
13
|
+
author 'Wizard'
|
14
|
+
end
|
15
|
+
Rake::Task['wix/Magic.wixobj'].invoke
|
16
|
+
assert File.exists? 'wix/Magic.wixobj'
|
17
|
+
end
|
18
|
+
end
|
data/test/wxs_test.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'packup'
|
2
|
+
require 'rexml/document'
|
3
|
+
require 'test/unit'
|
4
|
+
|
5
|
+
class PackupWxsTest < Test::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Rake::Task.clear
|
8
|
+
FileUtils.remove_dir 'wix', true
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_wxs_file_has_product_name
|
12
|
+
Packup.stuff 'Magic'
|
13
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
14
|
+
wxs = REXML::Document.new File.read('wix/Magic.wxs')
|
15
|
+
product = REXML::XPath.first(wxs, "/Wix/Product")
|
16
|
+
assert_equal 'Magic', product.attributes['Name']
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_wxs_file_has_product_version
|
20
|
+
Packup.stuff 'Magic' do
|
21
|
+
version '1.0.0'
|
22
|
+
end
|
23
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
24
|
+
wxs = REXML::Document.new File.read('wix/Magic.wxs')
|
25
|
+
product = REXML::XPath.first(wxs, "/Wix/Product")
|
26
|
+
assert_equal '1.0.0', product.attributes['Version']
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_wxs_file_has_product_manufacturer
|
30
|
+
Packup.stuff 'Magic' do
|
31
|
+
author 'Wizard'
|
32
|
+
end
|
33
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
34
|
+
wxs = REXML::Document.new File.read('wix/Magic.wxs')
|
35
|
+
product = REXML::XPath.first(wxs, "/Wix/Product")
|
36
|
+
assert_equal 'Wizard', product.attributes['Manufacturer']
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_wxs_file_has_upgrade_code
|
40
|
+
Packup.stuff 'Magic'
|
41
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
42
|
+
wxs = REXML::Document.new File.read('wix/Magic.wxs')
|
43
|
+
product = REXML::XPath.first wxs, '/Wix/Product'
|
44
|
+
assert_equal '02700E45-4D67-9F31-F27C-6F0768986DD1', product.attributes['UpgradeCode']
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_wxs_file_has_manufacturer_folder
|
48
|
+
Packup.stuff 'Magic' do
|
49
|
+
author 'Wizard'
|
50
|
+
end
|
51
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
52
|
+
wxs = REXML::Document.new File.read('wix/Magic.wxs')
|
53
|
+
dirs = REXML::XPath.match wxs, '//Directory'
|
54
|
+
dirs.delete_if { |dir| dir.attributes['Id'] != 'ManufacturerFolder' }
|
55
|
+
assert_equal 'Wizard', dirs.first.attributes['Name']
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_wxs_file_has_product_folder
|
59
|
+
Packup.stuff 'Magic'
|
60
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
61
|
+
wxs = REXML::Document.new File.read('wix/Magic.wxs')
|
62
|
+
dirs = REXML::XPath.match wxs, '//Directory'
|
63
|
+
dirs.delete_if { |dir| dir.attributes['Id'] != 'INSTALLDIR' }
|
64
|
+
assert_equal 'Magic', dirs.first.attributes['Name']
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_wxs_file_creates_source_file
|
68
|
+
Packup.stuff 'Magic' do
|
69
|
+
file 'README.md' => 'README.md'
|
70
|
+
end
|
71
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
72
|
+
assert File.exist?('wix/src/README.md')
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_wxs_file_creates_source_folder
|
76
|
+
Packup.stuff 'Magic' do
|
77
|
+
file 'README.md' => 'Wand/README.md'
|
78
|
+
end
|
79
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
80
|
+
assert File.directory?('wix/src/Wand')
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_wxs_file_references_sourcery_components
|
84
|
+
Packup.stuff 'Magic' do
|
85
|
+
file 'README.md' => 'README.md'
|
86
|
+
end
|
87
|
+
Rake::Task['wix/Magic.wxs'].invoke
|
88
|
+
sourcery = REXML::Document.new File.read('wix/Sourcery.wxs')
|
89
|
+
components = REXML::XPath.match sourcery, '//Component'
|
90
|
+
components.map! { |component| component.attributes['Id'] }
|
91
|
+
wxs = REXML::Document.new File.read('wix/Magic.wxs')
|
92
|
+
refs = REXML::XPath.match wxs, '//ComponentRef'
|
93
|
+
refs.map! { |ref| ref.attributes['Id'] }
|
94
|
+
assert_equal components, refs
|
95
|
+
end
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: packup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.pre
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Frank Mitchell
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.9.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.2
|
30
|
+
description: This gem provides a simple DSL for making MSI packages.
|
31
|
+
email: me@frankmitchell.org
|
32
|
+
executables: []
|
33
|
+
extensions: []
|
34
|
+
extra_rdoc_files: []
|
35
|
+
files:
|
36
|
+
- LICENSE.md
|
37
|
+
- README.md
|
38
|
+
- lib/packup.rb
|
39
|
+
- packup.gemspec
|
40
|
+
- rakefile.rb
|
41
|
+
- templates/product.wxs.erb
|
42
|
+
- test/behavior_test.rb
|
43
|
+
- test/msi_test.rb
|
44
|
+
- test/packup_test.rb
|
45
|
+
- test/sourcery_test.rb
|
46
|
+
- test/tasks_test.rb
|
47
|
+
- test/wixobj_test.rb
|
48
|
+
- test/wxs_test.rb
|
49
|
+
homepage: https://github.com/elimossinary/packup
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.9'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>'
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 1.3.1
|
68
|
+
requirements:
|
69
|
+
- WiX Toolset, v3.6 or greater
|
70
|
+
rubyforge_project:
|
71
|
+
rubygems_version: 1.8.24
|
72
|
+
signing_key:
|
73
|
+
specification_version: 3
|
74
|
+
summary: A Rake helper for building Windows installers
|
75
|
+
test_files:
|
76
|
+
- test/behavior_test.rb
|
77
|
+
- test/msi_test.rb
|
78
|
+
- test/packup_test.rb
|
79
|
+
- test/sourcery_test.rb
|
80
|
+
- test/tasks_test.rb
|
81
|
+
- test/wixobj_test.rb
|
82
|
+
- test/wxs_test.rb
|
83
|
+
has_rdoc:
|