]>
git.saurik.com Git - apple/security.git/blob - certificates/ota_cert_tool/Scripts/File.rb
5 # Copyright 2012 Apple Inc. All rights reserved.
11 attr_reader
:ios_SDK_path
12 attr_reader
:base_path
13 attr_reader
:output_directory
14 attr_reader
:asset_directory
15 attr_reader
:asset_top_directory
16 attr_reader
:asset_data_directory
17 attr_reader
:staging_directory
20 def validate_path(path
, isDir
= true)
21 return false if path
.nil? || path
.empty
?
22 return false if !FileTest
.exists
?(path
)
23 return false if isDir !
= FileTest
.directory
?(path
)
27 def ensure_directory(path
)
28 if !FileTest
.exists
?(path
)
29 FileUtils
.mkdir_p(path
)
33 def initialize(input_dir
, output_directory
, staging_directory
= "/tmp/staging")
37 puts
"In BuildPKIAsset.initialize" if @verbose
38 puts
"input_dir = #{input_dir}" if @verbose
39 puts
"output_directory = #{output_directory}" if @verbose
40 puts
"staging_directory = #{staging_directory}" if @verbose
42 # Check the input parameter
43 if !
validate_path(input_dir
)
44 puts
"Invalid base directory given: #{input_dir}"
48 @base_path = File
.expand_path(input_dir
)
50 if output_directory
.nil? || output_directory
.empty
?
51 puts
"No output directory was given"
55 exit
if `xcodebuild -sdk iphoneos.internal -find assettool`.nil?
57 @output_directory = File
.expand_path(output_directory
)
59 @asset_directory = File
.join(@output_directory, "Assets")
60 ensure_directory(@asset_directory)
62 @asset_top_directory = File
.join(@asset_directory, "SecurityCertificatesAssets")
63 ensure_directory(@asset_top_directory)
65 @asset_data_directory = File
.join(@asset_top_directory, "AssetData/PKITrustData")
66 ensure_directory(@asset_data_directory)
68 @staging_directory = File
.expand_path(staging_directory
)
69 ensure_directory(@staging_directory)
72 puts
"@base_path = #{@base_path }" if @verbose
73 puts
"@output_directory = #{@output_directory }" if @verbose
74 puts
"@asset_directory = #{@asset_directory }" if @verbose
75 puts
"@asset_top_directory = #{@asset_top_directory }" if @verbose
76 puts
"@asset_data_directory = #{@asset_data_directory }" if @verbose
77 puts
"@staging_directory = #{@staging_directory }" if @verbose
79 puts
"Done with BuildPKIAsset.initialize" if @verbose
85 puts
"In BuildPKIAsset.stage" if @verbose
87 #copy over the files into the asset directory
88 input_plist_file_path
= File
.join(@base_path, "Info.plist")
89 if !FileTest
.exists
?(input_plist_file_path
)
90 puts
"The asset data Info.plist file is missing #{input_plist_file_path}"
94 puts
"input_plist_file_path = #{input_plist_file_path}" if @verbose
96 FileUtils
.cp(input_plist_file_path
, @asset_top_directory)
98 puts
"About to copy over the plist files" if @verbose
100 # copy all of the necessary files into the asset data directory
101 file_list
= %w(EVRoots
.plist certs
.plist revoked
.plist Manifest
.plist distrusted
.plist roots
.plist
)
102 file_list
.each
do |file
|
103 file_path
= File
.join(@base_path, file
)
104 if !FileTest
.exists
?(file_path
)
105 puts
"#{file_path} is missing in the base directory"
108 FileUtils
.cp(file_path
, @asset_data_directory)
111 puts
"Completed copying over the plist files" if @verbose
113 puts
"About to call assettool stage" if @verbose
114 `xcrun -sdk iphoneos.internal assettool stage -p #{@asset_directory} -s #{@staging_directory}`
115 puts
"Completed call to assettool stage" if @verbose
117 puts
"Done with BuildPKIAsset.stage" if @verbose
121 puts
"In BuildPKIAsset.sign" if @verbose
122 puts
"About to call assettool sign" if @verbose
123 `xcrun -sdk iphoneos.internal assettool sign -s #{@staging_directory}`
124 puts
"Completed call to assettool sign" if @verbose
125 puts
"Done with BuildPKIAsset.sign" if @verbose
131 The following code is here ONLY for testing
134 #b = BuildPKIAsset.new(File.expand_path("~/cert_out"), File.expand_path("~/bobby_cert"))
137 #puts "That's all folks@"