wixgem 0.110.0 → 0.111.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/custom_action.rb +2 -2
- data/lib/registry_key.rb +32 -71
- data/lib/wixgem.rb +17 -5
- metadata +2 -3
- data/lib/registry_entries.rb +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acbf145ad790fe0b0faabf479d25e3837f65700d477e93a910d6efcd9f77e04d
|
4
|
+
data.tar.gz: cbc834eebb2e65b249f157edf7ebe065548d3cbd26d0968b2bc0ca672e14494e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69a025c6eef3598dbf2dba9f68265aa05c04f75af7f92c6af48929860781b9519e65b1bcad5d1824785428b3796a92fd8287f99be637758252234b9f984394e2
|
7
|
+
data.tar.gz: c27dba3df585bc4b46de25be5dd988eeb07c3f73f18537ce40e65d84b30131550d80a1de9864272f29754b5a7336d0bbc746a4511cb0ef36efb43725cfd389f6
|
data/lib/custom_action.rb
CHANGED
@@ -48,8 +48,8 @@ class CustomAction
|
|
48
48
|
action.attributes['FileKey'] = file_key
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
action.attributes['Directory'] = custom_action[:directory] if(custom_action.key?(:directory))
|
52
|
+
action.attributes['ExeCommand'] = custom_action[:exe_command] if(custom_action.key?(:exe_command))
|
53
53
|
action.attributes['DllEntry'] = custom_action[:dll_entry] if(custom_action.key?(:dll_entry))
|
54
54
|
|
55
55
|
if(custom_action.key?(:property))
|
data/lib/registry_key.rb
CHANGED
@@ -1,81 +1,42 @@
|
|
1
|
-
require 'rexml/document'
|
2
|
-
require 'SecureRandom'
|
1
|
+
##require 'rexml/document'
|
2
|
+
#require 'SecureRandom'
|
3
3
|
|
4
|
-
module Wixgem
|
4
|
+
#module Wixgem
|
5
5
|
|
6
|
-
|
6
|
+
# https://support.firegiant.com/hc/en-us/articles/230912127-RegistryKey-and-RegistryValue-elements
|
7
|
+
class RegistryKey
|
7
8
|
def initialize(xml_doc, input)
|
8
9
|
@xml_doc = xml_doc
|
9
10
|
@input = input
|
10
11
|
end
|
11
|
-
def add(
|
12
|
-
unless(
|
13
|
-
raise '
|
14
|
-
|
15
|
-
|
16
|
-
file_key=nil
|
17
|
-
if(custom_action.key?(:file))
|
18
|
-
install_path = ".\\#{custom_action[:file].gsub(/\//,'\\')}"
|
19
|
-
file_elements = REXML::XPath.match(@xml_doc, "//File[@Source='#{install_path}']")
|
20
|
-
raise "Unable to locate installation file '#{custom_action[:file]} for custom action'" if(file_elements.nil? || (file_elements.size == 0))
|
21
|
-
|
22
|
-
file_key = file_elements[0].attributes['Id']
|
23
|
-
end
|
24
|
-
|
25
|
-
id = "ca_#{SecureRandom.uuid.gsub(/-/,'')}"
|
26
|
-
id = custom_action[:id] if(custom_action.key?(:id))
|
27
|
-
|
28
|
-
impersonate = 'yes'
|
29
|
-
impersonate = custom_action[:impersonate] if(custom_action.key?(:impersonate))
|
30
|
-
|
31
|
-
condition='NOT Installed AND NOT REMOVE'
|
32
|
-
condition='1' if(custom_action.key?(:binary_key))
|
33
|
-
condition = custom_action[:condition] if(custom_action.key?(:condition))
|
34
|
-
|
35
|
-
execute='deferred'
|
36
|
-
execute = custom_action[:execute] if(custom_action.key?(:execute))
|
37
|
-
|
38
|
-
ret='check'
|
39
|
-
ret = custom_action[:return] if(custom_action.key?(:return))
|
40
|
-
|
41
|
-
wix_element = REXML::XPath.match(@xml_doc, "/Wix")[0]
|
42
|
-
fragment = wix_element.add_element 'Fragment'
|
43
|
-
|
44
|
-
action = fragment.add_element 'CustomAction', { 'Id' => id, 'Impersonate' => impersonate, 'Return' => ret, 'HideTarget' => 'no', 'Execute' => execute }
|
45
|
-
if(custom_action.key?(:binary_key))
|
46
|
-
action.attributes['BinaryKey'] = custom_action[:binary_key]
|
47
|
-
else
|
48
|
-
action.attributes['FileKey'] = file_key
|
49
|
-
end
|
12
|
+
def add(registry_key)
|
13
|
+
unless(registry_key.key?(:root) && registry_key.key?(:key) && registry_key.key?(:value))
|
14
|
+
raise 'Registry key must have root, key, and value elements'
|
15
|
+
end
|
50
16
|
|
51
|
-
|
52
|
-
|
53
|
-
|
17
|
+
key_value = registry_key[:value]
|
18
|
+
unless(key_value.key?(:name) || key_value.key?(:value) || key_value.key?(:type))
|
19
|
+
raise 'Registry value must have name, value, and type elements'
|
20
|
+
end
|
54
21
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
install_execute_sequence = fragment.add_element 'InstallExecuteSequence'
|
22
|
+
registry_keys_component = REXML::XPath.match(@xml_doc, "//Component[@Id='RegistryKeys']")
|
23
|
+
if(registry_keys_component.size == 0)
|
24
|
+
wix_element = REXML::XPath.match(@xml_doc, "/Wix")[0]
|
25
|
+
fragment = wix_element.add_element 'Fragment'
|
26
|
+
component_group = fragment.add_element 'ComponentGroup'
|
27
|
+
component_group.attributes['Id'] = "rk_#{SecureRandom.uuid.gsub(/-/,'')}"
|
64
28
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
elements[0].add_element 'CustomActionRef', { 'Id' => id }
|
79
|
-
end
|
80
|
-
end
|
29
|
+
default_feature = REXML::XPath.match(@xml_doc, '//Wix/Product/Feature')
|
30
|
+
component_ref = default_feature[0].add_element 'ComponentGroupRef', 'Id' => component_group.attributes['Id']
|
31
|
+
|
32
|
+
component = component_group.add_element 'Component'
|
33
|
+
component.attributes['Id'] = 'RegistryKeys'
|
34
|
+
component.attributes['Directory'] = 'INSTALLDIR'
|
35
|
+
else
|
36
|
+
puts "component: #{registry_keys_component.to_s}"
|
37
|
+
end
|
38
|
+
|
39
|
+
registry_key_element = component.add_element 'RegistryKey', { 'Root' => registry_key[:root], 'Key' => registry_key[:key] }
|
40
|
+
value_element = registry_key_element.add_element 'RegistryValue', { 'Action' => 'write', 'Name' => key_value[:name], 'Value' => key_value[:value], 'Type' => key_value[:type] }
|
41
|
+
end
|
81
42
|
end
|
data/lib/wixgem.rb
CHANGED
@@ -6,6 +6,7 @@ require 'SecureRandom'
|
|
6
6
|
require_relative 'file.rb'
|
7
7
|
require_relative 'shortcut.rb'
|
8
8
|
require_relative 'custom_action.rb'
|
9
|
+
require_relative 'registry_key.rb'
|
9
10
|
require_relative 'temp_directory.rb'
|
10
11
|
require_relative 'associate_extension.rb'
|
11
12
|
require_relative 'service.rb'
|
@@ -134,13 +135,22 @@ class Wix
|
|
134
135
|
|
135
136
|
def self.manage_custom_actions(xml_doc, input)
|
136
137
|
custom_actions = CustomAction.new(xml_doc, input)
|
137
|
-
|
138
|
+
return xml_doc if(input[:custom_actions].nil?)
|
138
139
|
|
139
|
-
|
140
|
+
input[:custom_actions].each { |ca| custom_actions.add(ca) }
|
140
141
|
|
141
|
-
|
142
|
+
return xml_doc
|
142
143
|
end
|
143
|
-
|
144
|
+
|
145
|
+
def self.manage_registry_keys(xml_doc, input)
|
146
|
+
return xml_doc if(input[:set_registry_keys].nil?)
|
147
|
+
|
148
|
+
registry_keys = RegistryKey.new(xml_doc, input)
|
149
|
+
input[:set_registry_keys].each { |rk| registry_keys.add(rk) }
|
150
|
+
|
151
|
+
return xml_doc
|
152
|
+
end
|
153
|
+
|
144
154
|
def self.manage_associate_extensions(xml_doc, input)
|
145
155
|
return xml_doc unless(input.key?(:extensions))
|
146
156
|
|
@@ -270,7 +280,7 @@ class Wix
|
|
270
280
|
files = input
|
271
281
|
files = input[:files] if(input.kind_of?(Hash))
|
272
282
|
|
273
|
-
|
283
|
+
return files
|
274
284
|
end
|
275
285
|
|
276
286
|
def self.ignore_files(input)
|
@@ -527,6 +537,7 @@ class Wix
|
|
527
537
|
xml_doc = manage_win10_crt(xml_doc, input)
|
528
538
|
#xml_doc = manage_ui(xml_doc, input)
|
529
539
|
xml_doc = manage_custom_actions(xml_doc, input)
|
540
|
+
xml_doc = manage_registry_keys(xml_doc, input)
|
530
541
|
xml_doc = manage_upgrade(xml_doc,input)
|
531
542
|
xml_doc = manage_msm_files(xml_doc)
|
532
543
|
xml_doc = manage_read_only_files(xml_doc,input)
|
@@ -603,6 +614,7 @@ class Wix
|
|
603
614
|
rescue Exception => e
|
604
615
|
raise e
|
605
616
|
ensure
|
617
|
+
puts "debug path: #{output_absolute_path}" if(@debug)
|
606
618
|
FileUtils.cp("#{dir}/#{wxs_file}", "#{output_absolute_path}.wxs") if(File.exists?("#{dir}/#{wxs_file}") && @debug)
|
607
619
|
File.open("#{output_absolute_path}.log", 'w') { |f| f.puts(@logger) } if(@debug &!@logger.nil?)
|
608
620
|
end
|
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.
|
4
|
+
version: 0.111.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: 2023-04-
|
11
|
+
date: 2023-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: execute
|
@@ -140,7 +140,6 @@ files:
|
|
140
140
|
- lib/associate_extension.rb
|
141
141
|
- lib/custom_action.rb
|
142
142
|
- lib/file.rb
|
143
|
-
- lib/registry_entries.rb
|
144
143
|
- lib/registry_key.rb
|
145
144
|
- lib/service.rb
|
146
145
|
- lib/shortcut.rb
|
data/lib/registry_entries.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
class RegistryEntries
|
2
|
-
def initialize(hash)
|
3
|
-
@hash = hash
|
4
|
-
end
|
5
|
-
|
6
|
-
def create_key(xml_doc)
|
7
|
-
raise "RegistryEntry hash is required to have a :root key" unless(@hash.has_key?(:root))
|
8
|
-
raise "RegistryEntry hash is required to have a :path key" unless(@hash.has_key?(:path))
|
9
|
-
raise "RegistryEntry hash is required to have a :key key" unless(@hash.has_key?(:key))
|
10
|
-
raise "Key hash is required to have a :name key" unless(@hash[:key].has_key?(:name))
|
11
|
-
raise "Key hash is required to have a :value key" unless(@hash[:value].has_key?(:name))
|
12
|
-
raise "Key hash is required to have a :value key" unless(@hash[:value_type].has_key?(:name))
|
13
|
-
|
14
|
-
service_exe = @hash[:service_exe]
|
15
|
-
raise "Service #{file} does not exist" unless(File.exists?(service_exe))
|
16
|
-
|
17
|
-
file_elements = REXML::XPath.match(xml_doc, "//File[@Source='.\\#{service_exe.gsub(/\//,'\\')}']")
|
18
|
-
raise "Service #{@file} does not match a 'File' element with a 'Source' attribute in the wix generated wix file" if(file_elements.length == 0)
|
19
|
-
|
20
|
-
service_exe_element = file_elements[0]
|
21
|
-
service_exe_element.attributes['KeyPath']='yes'
|
22
|
-
|
23
|
-
create_service_element(xml_doc, service_exe_element)
|
24
|
-
|
25
|
-
return xml_doc
|
26
|
-
end
|
27
|
-
|
28
|
-
def set(xml_doc, input)
|
29
|
-
file = file.gsub(/\//,'\\')
|
30
|
-
file_elements = REXML::XPath.match(@xml_doc, "//File[@Source='.\\#{file}']")
|
31
|
-
raise "Unable to find file '#{file}' to associate with extension '#{extension}'" if(file_elements.nil? || file_elements.size != 1)
|
32
|
-
|
33
|
-
file_parent = file_elements[0].parent
|
34
|
-
|
35
|
-
app=File.basename(file)
|
36
|
-
# App Paths to support Start,Run -> "myapp"
|
37
|
-
#<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe" Value="[!MyApp.exe]" Type="string" />
|
38
|
-
file_parent.add_element 'RegistryValue', { 'Root' => 'HKLM', 'Key' => "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\#{app}",
|
39
|
-
'Value' => "[INSTALLDIR]#{file}", 'Type' => 'string' }
|
40
|
-
#<RegistryValue Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\MyApp.exe" Name="Path" Value="[APPLICATIONFOLDER]" Type="string" />
|
41
|
-
file_parent.add_element 'RegistryValue', { 'Root' => 'HKLM', 'Key' => "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\#{app}",
|
42
|
-
'Name' => 'Path', 'Value' => '[INSTALLDIR]', 'Type' => 'string' }
|
43
|
-
|
44
|
-
# Extend to the "open with" list + Win7 jump menu pinning
|
45
|
-
#<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\MyApp.exe\SupportedTypes" Name=".xyz" Value="" Type="string" />
|
46
|
-
file_parent.add_element 'RegistryValue', { 'Root' => 'HKLM', 'Key' => "SOFTWARE\\Classes\\Applications\\#{app}\\SupportedTypes",
|
47
|
-
'Name' => extension, 'Value' => '', 'Type' => 'string' }
|
48
|
-
#<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\Applications\MyApp.exe\shell\open" Name="FriendlyAppName" Value="!(loc.ApplicationName)" Type="string" />
|
49
|
-
file_parent.add_element 'RegistryValue', { 'Root' => 'HKLM', 'Key' => "SOFTWARE\\Classes\\Applications\\#{app}\\shell\\open\\command",
|
50
|
-
'Value' => "[INSTALLDIR]#{file} \"%1\"", 'Type' => 'string' }
|
51
|
-
|
52
|
-
# MyApp.Document ProgID
|
53
|
-
#<RegistryValue Root="HKLM" Key="SOFTWARE\Classes\MyApp.Document" Name="FriendlyTypeName" Value="!(loc.DescXYZ)" Type="string" />
|
54
|
-
file_parent.add_element 'RegistryValue', { 'Root' => 'HKLM', 'Key' => "SOFTWARE\\Classes\\#{File.basename(app, '.exe')}.Document",
|
55
|
-
'Name' => 'Aim Project File', 'Value' => "[INSTALLDIR]#{app} \"%1\"", 'Type' => 'string' }
|
56
|
-
|
57
|
-
#<ProgId Id="MyApp.Document" Description="!(loc.DescXYZ)" Icon="filetype.ico" Advertise="yes">
|
58
|
-
# <Extension Id="xyz">
|
59
|
-
# <Verb Id="open" Command="!(loc.ExplorerMenuOpenXYZ)" Argument=""%1"" />
|
60
|
-
# <MIME Advertise="yes" ContentType="application/xyz" Default="yes" />
|
61
|
-
# </Extension>
|
62
|
-
#</ProgId>
|
63
|
-
prog_id = file_parent.add_element 'ProgId', { 'Id' => "#{File.basename(app, '.exe')}.Document", 'Description' => "Aim project file",
|
64
|
-
'Advertise' => 'yes'}
|
65
|
-
ext = prog_id.add_element 'Extension', { 'Id' => extension.gsub(/\./, '') }
|
66
|
-
ext.add_element 'Verb', { 'Id' => 'open', 'Command' => "[INSTALLDIR]#{app}", 'Argument' => "\"%1\"" }
|
67
|
-
end
|
68
|
-
end
|