-
Notifications
You must be signed in to change notification settings - Fork 9
/
mobileprovisioning.rb
executable file
·103 lines (87 loc) · 2.51 KB
/
mobileprovisioning.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/ruby
require "rubygems"
require "bundler/setup"
require 'apple-dev'
def ensure_file_specified_and_exists(name, file)
raise OptionParser::MissingArgument, name if file.nil?
raise OptionParser::InvalidArgument, "'#{file}' #{name} file doesn't exists" if not File.exists?(file)
end
def parse_command_line(args)
options = {}
opts = OptionParser.new { |opts|
opts.banner = "Usage: #{File.basename($0)} profileFile options"
opts.separator("Options:")
opts.on( '-d', '--dump [KEY]', 'Dump a particular KEY or the full XML.') do |key|
options[:dump] = true
options[:dumpKey] = key
end
opts.on( '-t', '--type', 'Prints the type of the profile (distribution or development).') do |key|
options[:type] = true
end
opts.on( '-o', '--output FILE', 'Write output to FILE. Default is standard output.') do |output|
options[:output] = output
end
opts.on('-c', '--certificate CERTIFICATE', 'Use CERTIFICATE to verify profile.') do |certificate|
options[:certificate] = certificate
end
options[:verbose] = false
opts.on('-v', '--verbose', "Show the profile's type, verification, signers, recipients and certificates.") do
options[:verbose] = true
end
opts.on_tail( '-h', '--help', 'Display this screen.' ) do
puts opts
exit
end
}
if (args.empty?)
puts opts
exit
end
begin
opts.parse!(args)
rescue OptionParser::ParseError => e
puts "Found #{e}"
puts opts
exit 1
end
options[:profile] = args[0]
ensure_file_specified_and_exists("profile", options[:profile])
options
end
def dump(text, file)
if (file)
File.open(file, 'w') { |f| f.write(text) }
else
puts text
end
end
def dumpProfile(pp, options)
if pp.text.nil?
puts "The profile content is nil. Maybe the verification failed? Try -v."
else
text = pp
key = options[:dumpKey]
if key
text = pp[key]
end
end
dump(text, options[:output])
end
def dumpProfileType(pp, options)
# http://stackoverflow.com/questions/1003066/what-does-get-task-allow-do-in-xcode
get_task_allow = pp["Entitlements"]["get-task-allow"]
type = get_task_allow ? "development" : "distribution"
dump(type, options[:output])
end
def main()
options = parse_command_line(ARGV)
pp = Apple::Dev::ProvisioningProfile.new(options[:profile], options[:certificate])
if options[:verbose]
pp.dump
if (options[:dump])
dumpProfile(pp, options)
elsif (options[:type])
dumpProfileType(pp, options)
end
end
main()