check_packages 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. if (( ! ${+commands[packagesbuild]} )) {
  2. autoload -Uz log_info log_status mkcd
  3. if (( ! ${+commands[curl]} )) {
  4. log_error 'curl not found. Please install curl.'
  5. return 2
  6. }
  7. if (( ! ${+project_root} )) {
  8. log_error "'project_root' not set. Please set before running ${0}."
  9. return 2
  10. }
  11. local -a curl_opts=()
  12. if (( ! ${+CI} )) {
  13. curl_opts+=(--progress-bar)
  14. } else {
  15. curl_opts+=(--show-error --silent)
  16. }
  17. curl_opts+=(--location -O ${@})
  18. log_info 'Installing Packages.app...'
  19. pushd
  20. mkcd ${project_root:h}/obs-build-dependencies
  21. local packages_url='http://s.sudre.free.fr/Software/files/Packages.dmg'
  22. local packages_hash='6afdd25386295974dad8f078b8f1e41cabebd08e72d970bf92f707c7e48b16c9'
  23. if [[ ! -f Packages.dmg ]] {
  24. log_status 'Download Packages.app'
  25. curl ${curl_opts} ${packages_url}
  26. }
  27. read -r image_checksum _ <<< "$(sha256sum Packages.dmg)"
  28. if [[ ${packages_hash} != ${image_checksum} ]] {
  29. log_error "Checksum mismatch of Packages.app download.
  30. Expected : ${packages_hash}
  31. Actual : ${image_checksum}"
  32. return 2
  33. }
  34. hdiutil attach -noverify Packages.dmg &> /dev/null && log_status 'Packages.dmg image mounted.'
  35. log_info 'Installing Packages.app...'
  36. packages_volume=$(hdiutil info -plist | grep '<string>/Volumes/Packages' | sed 's/.*<string>\(\/Volumes\/[^<]*\)<\/string>/\1/')
  37. sudo installer -pkg "${packages_volume}/packages/Packages.pkg" -target / && rehash
  38. hdiutil detach ${packages_volume} &> /dev/null && log_status 'Packages.dmg image unmounted.'
  39. }