Created
December 10, 2013 19:14
-
-
Save foozmeat/7896392 to your computer and use it in GitHub Desktop.
a ruby function to perform some basic checks on an app package to validate it for Mac App Store submission
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mas_validation | |
return unless $config[:build][:package] | |
if $config[:build][:ios] | |
else | |
if $config[:build][:configuration] == 'ReleaseMacAppStore' | |
notice("Validating for MAS") | |
# puts "Verifying package signature" | |
# verify_cmd = %Q(codesign -v -vvv "#{$mas_package_file}") | |
# failed("Package isn't signed correctly") unless system(verify_cmd) | |
tmp_path = "/tmp/" + $package_title | |
plist_file = $mas_package_file + '.plist' | |
FileUtils.rm_r tmp_path, :force => true if File.exists?(tmp_path) | |
util_cmd = %Q(/usr/libexec/productutil --package "#{$mas_package_file}" --expand "#{tmp_path}" --extract-metadata --check-signature > "#{plist_file}") | |
# puts util_cmd | |
failed("Dumping package metadata") unless system(util_cmd) | |
valid=`/usr/libexec/PlistBuddy -c 'Print product-signature:validated' "#{plist_file}"`.chop | |
failed("Validating package") unless valid == "true" | |
errors = `/usr/libexec/PlistBuddy -c 'Print product-metadata:packages:0:unsigned-execute-paths' "#{plist_file}"` | |
if errors =~ /Array \{\n\}/ | |
puts "No unsigned elements in package" | |
else | |
puts errors | |
failed "There are unsigned elements in this build\nYou may need to use -> svn propdel -R svn:executable <path> <- to remove this error\nLike this: find . -type f -perm -a+x -not -iwholename '*.svn*' -print0 | xargs -0 -I {} svn propdel -R svn:executable \"{}\"" | |
end | |
# I'm not porting the tests for PPC code or for codesign space allocation. | |
# Ensure that Sparkle.framework isn't in the app bundle | |
if /matches/ =~ `grep Sparkle.framework '#{$product_path}/Contents/MacOS/#{$config[:build][:appname]}'` | |
failed "Sparkle framework referenced in app bundle" | |
end | |
embeddedProfileList = `find '#{$product_path}' -name embedded.provisionprofile` | |
if embeddedProfileList.lines.count > 1 | |
puts embeddedProfileList | |
failed "More than one embedded.provisionprofile file found inside of the app." | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment