wixgem 0.64.0 → 0.65.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64606c985a2b5acc78b072ce7d2fc51df06078d2
4
- data.tar.gz: 686826c5f70fe04f73e8dadfd49355a0ee6b22f1
3
+ metadata.gz: d5ed53abaf6b54b665845c36f28eaa4f2102c02b
4
+ data.tar.gz: 2d3190c02befcba86c5226c0be1bc67228758ce9
5
5
  SHA512:
6
- metadata.gz: 519c6ac58af86368b960d34a501fe49656eb111ce001c651a73d52af7c5fc125e767608826ee1e6555fd08d4db67a493936663f508bce1072b026a50359b6c38
7
- data.tar.gz: 33659cd17e70a8d4a1fa3e9a1d91e48954aa56b2f57fd16245feec18868e5285efa7f27ccb04642a8c8e3eb0dfa62af7f5ba06c41a112dfe775231187df94af7
6
+ metadata.gz: b8c552429381777ff6e16a05d63ddbc8498db018565161d049c9f326e61a3346348df94c38abd9f5f9e71ce50f528a76be881de20b2a0d9b63cebaa06b1e9933
7
+ data.tar.gz: 7e952911a1454bc7be23982120dfd0294c656a6a98c10c8d981ec4ecffaeded81a92e0108ce7e58f3946a2a22209bf75de5d9e648caf369a6762c9c4d476939e
data/example/example.msi CHANGED
Binary file
Binary file
data/example/rakefile.rb CHANGED
@@ -1,8 +1,6 @@
1
- require 'wixgem'
1
+ require_relative '../lib/wixgem.rb'
2
+ #require 'wixgem' Use this require statement when including in a project outside of wixgem
2
3
 
3
- #Wixgem::Wix.install_path = 'C:\Development\dep\OpenSource\WixToolset\3.9'
4
- Wixgem::Wix.install_path = '<Path to the root directory of the wix toolset>'
5
-
6
4
  task :create_installation_files do
7
5
  FileUtils.mkpath('./install_files/directory')
8
6
  sleep(1)
@@ -20,8 +18,7 @@ desc "Generate an installation msi file"
20
18
  task :installation => [:mergemodule] do
21
19
  installation_files = Dir.glob('./example.msm')
22
20
  Wixgem::Wix.make_installation("./example.msi",
23
- { upgrade_code: '{a62c35a7-6a6d-4392-822b-f6aca7eef88b}',
24
- files: installation_files }
21
+ { upgrade_code: '{a62c35a7-6a6d-4392-822b-f6aca7eef88b}', files: installation_files }
25
22
  )
26
23
  end
27
24
 
data/lib/admin.rb ADDED
@@ -0,0 +1,11 @@
1
+ require 'cmd.rb'
2
+
3
+ def admin?
4
+ cmd = CMD.new('net session')
5
+ cmd[:ignore_exit_code] = true
6
+ cmd[:quiet] = true
7
+ cmd.execute
8
+ return true if(cmd[:exit_code] == 0)
9
+ return false
10
+ end
11
+ ENV['HOME'] ||= "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" if(admin?)
data/lib/wixgem.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'fileutils'
2
2
  require 'tmpdir.rb'
3
3
  require 'rexml/document'
4
- require "#{File.dirname(__FILE__)}/command.rb"
4
+ require 'CMD'
5
5
  require 'SecureRandom'
6
6
  require_relative('file.rb')
7
7
  require_relative('shortcut.rb')
@@ -9,17 +9,19 @@ require_relative('shortcut.rb')
9
9
  module Wixgem
10
10
 
11
11
  class Wix
12
+ @@install_path = ''
13
+ @@install_path = ENV['WIX'] unless(ENV['WIX'].nil?)
14
+
12
15
  def self.initialize
13
- @install_path = ''
14
16
  @debug = false
15
17
  @logger = nil
16
18
  @log_file = nil
17
19
  end
18
20
  def self.install_path=(path)
19
- @install_path = path
21
+ @@install_path = path
20
22
  end
21
23
  def self.install_path
22
- return @install_path
24
+ return @@install_path
23
25
  end
24
26
 
25
27
  def self.debug=(bool)
@@ -267,7 +269,7 @@ class Wix
267
269
  end
268
270
 
269
271
  def self.execute_heat(input, cmd_line_options)
270
- heat_cmd = Command.new("\"#{install_path}/bin/heat.exe\" #{modify_heat_commandline(input, cmd_line_options)}", { quiet: true })
272
+ heat_cmd = CMD.new("\"#{install_path}/bin/heat.exe\" #{modify_heat_commandline(input, cmd_line_options)}", { quiet: true })
271
273
  heat_cmd.execute
272
274
  log_wix_output(heat_cmd)
273
275
  end
@@ -411,11 +413,11 @@ class Wix
411
413
  def self.create_output(wxs_file, output)
412
414
  wixobj_file = "#{File.basename(wxs_file,'.wxs')}.wixobj"
413
415
 
414
- candle_cmd = Command.new("\"#{install_path}/bin/candle.exe\" -out \"#{wixobj_file}\" \"#{wxs_file}\"", { quiet: true })
416
+ candle_cmd = CMD.new("\"#{install_path}/bin/candle.exe\" -out \"#{wixobj_file}\" \"#{wxs_file}\"", { quiet: true })
415
417
  candle_cmd.execute
416
418
  log_wix_output(candle_cmd)
417
419
 
418
- light_cmd = Command.new("\"#{install_path}/bin/light.exe\" -nologo -out \"#{output}\" \"#{wixobj_file}\"", { quiet: true })
420
+ light_cmd = CMD.new("\"#{install_path}/bin/light.exe\" -nologo -out \"#{output}\" \"#{wixobj_file}\"", { quiet: true })
419
421
  light_cmd.execute
420
422
  log_wix_output(light_cmd)
421
423
  end
@@ -427,7 +429,7 @@ class Wix
427
429
  end
428
430
 
429
431
  def self.create_package(output, input)
430
- raise 'WIX path is not set!' if(install_path.nil?)
432
+ raise 'WIX path is not set! Install Wixtoolset or assign with Wixgem::Wix.install_path = <path to wix toolset' if(self.install_path.nil?)
431
433
  input = { files: input } unless(input.kind_of?(Hash))
432
434
  verify_input_keys(input)
433
435
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wixgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.64.0
4
+ version: 0.65.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Marshall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-10 00:00:00.000000000 Z
11
+ date: 2015-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,34 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: execute
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: WindowsInstaller
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
69
97
  description: Simple Ruby interface to facilitate creating and compiling windows installation
70
98
  files with the Wix Toolset.
71
99
  email: KCCKSMarshall@gmail.com
@@ -76,14 +104,13 @@ files:
76
104
  - LICENSE
77
105
  - README.md
78
106
  - example/example.msi
107
+ - example/example.msm
79
108
  - example/install_files/directory/file2.txt
80
109
  - example/install_files/file1.txt
81
110
  - example/rakefile.rb
82
- - lib/WindowsInstaller.rb
83
- - lib/command.rb
111
+ - lib/admin.rb
84
112
  - lib/file.rb
85
113
  - lib/shortcut.rb
86
- - lib/shortcut.rb.kev
87
114
  - lib/wixgem.rb
88
115
  homepage: http://rubygems.org/gems/wixgem
89
116
  licenses:
@@ -105,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
132
  version: '0'
106
133
  requirements: []
107
134
  rubyforge_project:
108
- rubygems_version: 2.4.5
135
+ rubygems_version: 2.4.5.1
109
136
  signing_key:
110
137
  specification_version: 4
111
138
  summary: Simple Ruby interface to facilitate working with Wix Toolset
@@ -1,171 +0,0 @@
1
- require 'win32ole'
2
- require File.dirname(__FILE__) + '/command.rb'
3
-
4
- module Wixgem
5
- class WindowsInstaller
6
- def self.install(msi_file)
7
- raise "#{msi_file} does not exist!" unless(File.exists?(msi_file))
8
- msi_file = msi_file.gsub(/\//, '\\')
9
- raise "#{msi_file} is already installed" if(WindowsInstaller.msi_installed?(msi_file))
10
- execute("msiexec.exe /quiet /i #{msi_file}")
11
- end
12
-
13
- def self.uninstall(msi_file)
14
- raise "#{msi_file} does not exist!" unless(File.exists?(msi_file))
15
-
16
- info = msi_records(msi_file)
17
- uninstall_product_code(info['ProductCode'])
18
- end
19
-
20
- def self.uninstall_product_name(product_name)
21
- raise "#{product_name} is not installed" unless(product_name_installed?(product_name))
22
- uninstall_product_code(product_code_from_product_name(product_name))
23
- end
24
-
25
- def self.uninstall_product_code(product_code)
26
- raise "#{product_code} is not installed" unless(product_code_installed?(product_code))
27
- execute("msiexec.exe /quiet /x #{product_code}")
28
- end
29
-
30
- def self.msi_installed?(msi_file)
31
- info = msi_records(msi_file)
32
- result = product_code_installed?(info['ProductCode'])
33
- return result
34
- end
35
-
36
- def self.product_name_installed?(product_name)
37
- installer = WIN32OLE.new('WindowsInstaller.Installer')
38
- installer.Products.each { |prod_code|
39
- name = installer.ProductInfo(prod_code, "ProductName")
40
- return true if (product_name == name)
41
- }
42
- return false
43
- end
44
-
45
- def self.product_code_installed?(product_code)
46
- installer = WIN32OLE.new('WindowsInstaller.Installer')
47
- installer.Products.each { |installed_product_code| return true if (product_code == installed_product_code) }
48
- return false
49
- end
50
-
51
- def self.product_code_installed?(product_code)
52
- installer = WIN32OLE.new('WindowsInstaller.Installer')
53
- installer.Products.each { |prod_code| return true if (product_code == prod_code) }
54
- return false
55
- end
56
-
57
- def self.version_from_product_name(product_name)
58
- installer = WIN32OLE.new('WindowsInstaller.Installer')
59
- info = product_info(installer, product_code_from_product_name(product_name, installer))
60
- return info['VersionString']
61
- end
62
-
63
- def self.product_code_from_product_name(product_name, installer = nil)
64
- installer = WIN32OLE.new('WindowsInstaller.Installer') if(installer.nil?)
65
- installer.Products.each { |prod_code|
66
- name = installer.ProductInfo(prod_code, "ProductName")
67
- return prod_code if (product_name == name)
68
- }
69
- raise "Failed to find product code for product: #{product_name}"
70
- end
71
-
72
- def self.product_info(installer, code)
73
- raise 'Windows installer cannot be nil' if(installer.nil?)
74
- hash = Hash.new
75
- # known product keywords found on internet. Would be nice to generate.
76
- %w[Language PackageCode Transforms AssignmentType PackageName InstalledProductName VersionString RegCompany
77
- RegOwner ProductID ProductIcon InstallLocation InstallSource InstallDate Publisher LocalPackage HelpLink
78
- HelpTelephone URLInfoAbout URLUpdateInfo InstanceType].sort.each do |prop|
79
- value = installer.ProductInfo(code, prop)
80
- hash[prop] = value unless(value.nil? || value == '')
81
- end
82
- return hash
83
- end
84
-
85
- def self.msi_info(installer, msi_file)
86
- raise 'Windows installer cannot be nil' if(installer.nil?)
87
- hash = Hash.new
88
- # known product keywords found on internet. Would be nice to generate.
89
- %w[Language PackageCode Transforms AssignmentType PackageName InstalledProductName VersionString RegCompany
90
- RegOwner ProductID ProductIcon InstallLocation InstallSource InstallDate Publisher LocalPackage HelpLink
91
- HelpTelephone URLInfoAbout URLUpdateInfo InstanceType].sort.each do |prop|
92
- value = installer.ProductInfo(code, prop)
93
- hash[prop] = value unless(value.nil? || value == '')
94
- end
95
- return hash
96
- end
97
-
98
- def self.dump_info(product_name)
99
- installer = WIN32OLE.new('WindowsInstaller.Installer')
100
- properties = product_info(installer, product_code_from_product_name(product_name, installer))
101
- properties.each { |id, value| puts "#{id}: #{value}" }
102
- end
103
-
104
- private
105
- def self.msi_records(msi_file)
106
- records = {}
107
-
108
- installer = WIN32OLE.new('WindowsInstaller.Installer')
109
- sql_query = "SELECT * FROM `Property`"
110
-
111
- db = installer.OpenDatabase(msi_file, 0)
112
-
113
- view = db.OpenView(sql_query)
114
- view.Execute(nil)
115
-
116
- record = view.Fetch()
117
- return '' if(record == nil)
118
-
119
- while(!record.nil?)
120
- records[record.StringData(1)] = record.StringData(2)
121
- record = view.Fetch()
122
- end
123
- db.ole_free
124
- db = nil
125
- installer.ole_free
126
- installer = nil
127
-
128
- return records
129
- end
130
-
131
- def self.dump_msi_records(msi)
132
- records = msi_records(msi)
133
-
134
- puts "#{msi} Properties:"
135
- records.each do |key,value|
136
- puts "#{key}: #{value}"
137
- end
138
- end
139
-
140
- def self.dump_product(product_name)
141
- installer = WIN32OLE.new('WindowsInstaller.Installer')
142
- # only one session per process!
143
- session = installer.OpenProduct(product_code?(product_name, installer))
144
- db = session.Database
145
-
146
- sql_query = "SELECT * FROM `Property`"
147
- view = db.OpenView(sql_query)
148
- view.Execute(nil)
149
-
150
- record = view.Fetch()
151
- return '' if(record == nil)
152
-
153
- puts "Session Properties:"
154
- while(!record.nil?)
155
- puts "#{record.StringData(1)}: #{record.StringData(2)}"
156
- record = view.Fetch()
157
- end
158
- db.ole_free
159
- db = nil
160
- installer.ole_free
161
- installer = nil
162
- puts ''
163
- end
164
-
165
- def self.execute(cmd)
166
- command = Wixgem::Command.new(cmd, { quiet: true } )
167
- #command[:debug] = true
168
- command.execute
169
- end
170
- end
171
- end
data/lib/command.rb DELETED
@@ -1,43 +0,0 @@
1
- require 'open3'
2
-
3
- module Wixgem
4
-
5
- class Command < Hash
6
- def initialize(cmd, options=nil)
7
- self[:output] = ''
8
- self[:error] = ''
9
- self[:exit_code] = ''
10
- self[:ignore_exit_code] = false
11
- self[:debug] = false
12
- self[:quiet] = false
13
-
14
- self[:command]=cmd
15
- options.each { |key, value| self[key] = value} unless(options.nil?)
16
- end
17
-
18
- def execute
19
- begin
20
- puts self[:command] unless(self[:quiet])
21
- self[:output],self[:error], self[:exit_code] = Open3.capture3(self[:command])
22
- self[:exit_code]=self[:exit_code].to_i
23
-
24
- if(self[:debug])
25
- puts "command: #{self[:command]}" if(self[:quiet])
26
- puts "output: #{self[:output]}"
27
- puts "error: #{self[:error]}"
28
- puts "exit_code: #{self[:exit_code]}"
29
- end
30
- rescue Exception => e
31
- self[:error] = "Exception: " + e.to_s
32
- self[:exit_code]=1
33
- end
34
-
35
- if((self[:exit_code] != 0) && !self[:ignore_exit_code])
36
- exception_text = self[:error]
37
- exception_text = self[:output] if(self[:error].empty?)
38
- raise exception_text
39
- end
40
- end
41
- end
42
-
43
- end
data/lib/shortcut.rb.kev DELETED
@@ -1,129 +0,0 @@
1
- require 'rexml/document'
2
- require 'SecureRandom'
3
-
4
- module Wixgem
5
-
6
- class Shortcut
7
-
8
- def initialize(file, hash)
9
- @file = file
10
- @hash = hash
11
- end
12
-
13
- def create(xml_doc)
14
- raise "Shortcut #{@file} does not exist" unless(File.exists?(@file))
15
-
16
- file_elements = REXML::XPath.match(xml_doc, "//File[@Source='.\\#{@file.gsub(/\//,'\\')}']")
17
- raise "Shortcut #{@file} does not match an installation file" if(file_elements.length == 0)
18
-
19
- case @hash[:directory]
20
- when :desktop
21
- create_file_shortcut(file_elements[0])
22
- xml_doc = create_desktop_folder(xml_doc)
23
- # when :start_menu
24
- # program_files_element = create_start_menu_shortcut(xml_doc)
25
- # create_start_menu_item(program_files_element)
26
- else
27
- raise 'Support for #{:directory} shortcut has not been added'
28
- end
29
-
30
- return xml_doc
31
- end
32
-
33
- def create_file_shortcut(file_element)
34
- shortcut_element = file_element.add_element 'Shortcut'
35
-
36
- shortcut_element.attributes['Id'] = "Shortcut_#{SecureRandom.uuid.gsub(/-/,'')}"
37
- shortcut_element.attributes['Arguments'] = @hash[:arguments] if(@hash.has_key?(:arguments))
38
-
39
- shortcut_name = File.basename(@file)
40
- if(@hash.has_key?(:name))
41
- shortcut_name = @hash[:name]
42
- else
43
- @hash[:name] = shortcut_name
44
- end
45
- shortcut_element.attributes['Name'] = shortcut_name
46
-
47
- shortcut_element.attributes['Description'] = @hash[:description] if(@hash.has_key?(:description))
48
- shortcut_element.attributes['Directory'] = 'DesktopFolder'
49
-
50
- shortcut_element.attributes['Advertise']="yes"
51
- shortcut_element.attributes['Advertise'] = "no" if(@hash.has_key?(:advertise) && !@hash[:advertise])
52
- create_icon_element(shortcut_element) if(@hash.has_key?(:icon))
53
-
54
- return shortcut_element
55
- end
56
-
57
- def create_icon_element(shortcut_element)
58
- icon_element = shortcut_element.add_element 'Icon'
59
- icon_element.attributes['Id'] = File.basename(@hash[:icon])
60
- icon_element.attributes['SourceFile'] = ".\\#{@hash[:icon].gsub(/\//, '\\')}"
61
- return icon_element
62
- end
63
-
64
- def create_desktop_folder(xml_doc)
65
- desktop_elements = REXML::XPath.match(xml_doc, "//DesktopFolder")
66
- if(desktop_elements.length == 0)
67
- wix_elements = REXML::XPath.match(xml_doc, "//Wix")
68
- fragment_element = wix_elements[0].add_element 'Fragment'
69
- target_dir = fragment_element.add_element 'DirectoryRef', { 'Id' => 'TARGETDIR' }
70
- target_dir.add_element 'Directory', { 'Id' => 'DesktopFolder', 'Name' => 'Desktop' }
71
- end
72
- return xml_doc
73
- end
74
-
75
- # def create_start_menu_shortcut(program_folder_element)
76
- # puts "1"
77
- # shortcut_element = program_folder_element.add_element 'Shortcut'
78
- #
79
- # shortcut_element.attributes['Id'] = 'ApplicationStartMenuShortcut'
80
- #
81
- # shortcut_name = File.basename(@file)
82
- # ext = File.extname(@file)
83
- # if(@hash.has_key?(:name))
84
- # shortcut_name = @hash[:name]
85
- # else
86
- # shortcut_name = File.basename(shortcut_name, ext) if(ext != '')
87
- # @hash[:name] = shortcut_name
88
- # end
89
- # shortcut_element.attributes['Name'] = shortcut_name
90
-
91
- # puts "2"
92
- # shortcut_element.attributes['Description'] = @hash[:description] if(@hash.has_key?(:description))
93
- # shortcut_element.attributes['Target'] = @file
94
- #
95
- # puts "3"
96
- # remove_folder_element = program_folder_element.add_element 'RemoveFolder'
97
- # remove_folder_element.attributes['Id'] = 'ApplicationProgramsFolder'
98
- # remove_folder_element.attributes['On'] = 'uninstall'
99
-
100
- # puts "4"
101
- # registry_folder_element = program_folder_element.add_element 'RegistryValue'
102
- # remove_folder_element.attributes['Root'] = 'HKCU'
103
- # remove_folder_element.attributes['Key'] = "Software\\Microsoft\\#{shortcut_name.gsub(/ /,'')}"
104
- # remove_folder_element.attributes['Name'] = 'installed'
105
- # remove_folder_element.attributes['Type'] = 'integer'
106
- # remove_folder_element.attributes['Value'] = '1'
107
- # remove_folder_element.attributes['KeyPath'] = 'yes'
108
-
109
- # return shortcut_element
110
- # end
111
-
112
- # def create_start_menu_component(xml_doc)
113
- # app_programs_elements = REXML::XPath.match(xml_doc, "//ApplicationProgramsFolder")
114
- # app_programs_element = nil
115
- # if(app_programs_elements.length == 0)
116
- # wix_elements = REXML::XPath.match(xml_doc, "//Wix")
117
- # fragment_element = wix_elements[0].add_element 'Fragment'
118
- # app_programs_element = fragment_element.add_element 'DirectoryRef', { 'Id' => 'ApplicationProgramsFolder' }
119
- # else if(app_programs_elements.length == 1)
120
- # app_programs_element = app_programs_elements[0]
121
- # else
122
- # raise "Wix file contains multiple ApplicationProgramsFolder's"
123
- # end
124
-
125
- # return app_programs_element.add_element 'Component', { 'Id' => 'ApplicationShortcut', 'Guid' => '{a9e94876-60b5-4038-8baa-ea76a3f9ebe1}' }
126
- # end
127
- end
128
-
129
- #end