Class: RokuBuilder::Packager
- Inherits:
-
Util
- Object
- Util
- RokuBuilder::Packager
show all
- Extended by:
- Plugin
- Defined in:
- lib/roku_builder/plugins/packager.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Plugin
commands, dependencies, parse_options
Methods inherited from Util
#initialize
Class Method Details
.commands ⇒ Object
8
9
10
11
12
13
14
|
# File 'lib/roku_builder/plugins/packager.rb', line 8
def self.commands
{
package: {device: true, source: true, stage: true, exclude: true},
genkey: {device: true},
key: {device: true, source: true}
}
end
|
.dependencies ⇒ Object
33
34
35
|
# File 'lib/roku_builder/plugins/packager.rb', line 33
def self.dependencies
[Loader, Inspector]
end
|
.parse_options(parser:, options:) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/roku_builder/plugins/packager.rb', line 16
def self.parse_options(parser:, options:)
parser.separator "Commands:"
parser.on("-p", "--package", "Package an app") do
options[:package] = true
end
parser.on("-k", "--key", "Change device key") do
options[:key] = true
end
parser.on("--genkey", "Generate a new key") do
options[:genkey] = true
end
parser.separator "Options:"
parser.on("-i", "--inspect-package", "Inspect package after packaging") do
options[:inspect_package] = true
end
end
|
Instance Method Details
105
106
107
108
109
110
111
112
113
114
115
|
# File 'lib/roku_builder/plugins/packager.rb', line 105
def dev_id
path = "/plugin_package"
conn = simple_connection
response = conn.get path
dev_id = /Your Dev ID:\s*<font[^>]*>([^<]*)<\/font>/.match(response.body)
dev_id ||= /Your Dev ID:[^>]*<\/label> ([^<]*)/.match(response.body)
dev_id = dev_id[1] if dev_id
dev_id ||= "none"
dev_id
end
|
#genkey(options:) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
# File 'lib/roku_builder/plugins/packager.rb', line 53
def genkey(options:)
password, dev_id = generate_new_key()
@logger.unknown("Password: "+password)
@logger.info("DevID: "+dev_id)
out = @config.out
out[:file] ||= "key_"+dev_id+".pkg"
@config.out = out
Dir.mktmpdir { |dir|
config_copy = @config.dup
config_copy.root_dir = dir
Manifest.generate({config: config_copy, attributes: {}})
Dir.mkdir(File.join(dir, "source"))
File.open(File.join(dir, "source", "main.brs"), "w") do |io|
io.puts "sub main()"
io.puts " print \"Load\""
io.puts "end sub"
end
loader = Loader.new(config: config_copy)
options[:current] = true
loader.sideload(options: options)
sign_package(app_name_version: "key_"+dev_id, password: password, stage: options[:stage])
@logger.unknown("Keyed PKG: #{File.join(@config.out[:folder], @config.out[:file])}")
}
end
|
#key(options:) ⇒ Boolean
Sets the key on the roku device
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/roku_builder/plugins/packager.rb', line 84
def key(options:)
oldId = dev_id
raise ExecutionError, "Missing Key Config" unless @config.key
payload = {
mysubmit: "Rekey",
passwd: @config.key[:password],
archive: Faraday::UploadIO.new(@config.key[:keyed_pkg], 'application/octet-stream')
}
multipart_connection.post "/plugin_inspect", payload
newId = dev_id
@logger.info("Key did not change") unless newId != oldId
@logger.debug(oldId + " -> " + newId)
end
|
#package(options:) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/roku_builder/plugins/packager.rb', line 37
def package(options:)
check_options(options)
Loader.new(config: @config).sideload(options: options)
key(options: options)
sign_package(app_name_version: "", password: @config.key[:password], stage: options[:stage])
if options[:inspect_package]
@config.in = @config.out
options[:password] = @config.key[:password]
Inspector.new(config: @config).inspect(options: options)
end
end
|