after_install_codesign 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env bash
  2. ####################################################
  3. # Signing compiled ruby for OSX, for details visit #
  4. # https://rvm.io/rubies/codesign/ #
  5. ####################################################
  6. # Go to subprocess so we can use returns and 'use' ruby temporarily
  7. (
  8. # Require Mac OS
  9. [[ "${_system_type}" == Darwin ]] || return 1
  10. # Require 10.7 - FIXME: Should be 10.7 or newer.
  11. [[ "${_system_version}" == 10.7* ]] || return 2
  12. # Find out ruby executable to sign
  13. typeset _ruby_name
  14. _ruby_name="$(sed -n '/^ruby_install_name=/ {s/ruby_install_name="\(.*\)"/\1/; p; };' "$MY_RUBY_HOME/config" )"
  15. # Require rvm_codesign_identity
  16. [[ -n "${rvm_codesign_identity:-}" ]] || {
  17. rvm_warn "'rvm_codesign_identity' is not set so RVM can't sign ${_ruby_name}\n" \
  18. "Set it in ~/.rvmrc after reading the following about OS X code signing:\n" \
  19. "https://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html"
  20. return 3
  21. }
  22. # Require using ruby - btw this should not happen
  23. __rvm_use || {
  24. rvm_warn "can not use ruby which was just installed ... so can not sign it neither"
  25. return 4
  26. }
  27. # Sign ruby
  28. /usr/bin/codesign -f -s "${rvm_codesign_identity}" "$(which "${_ruby_name}")"
  29. )