create-dmg.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/bin/sh
  2. set -e
  3. info()
  4. {
  5. local green="\033[1;32m"
  6. local normal="\033[0m"
  7. echo "[${green}Package${normal}] $1"
  8. }
  9. spushd()
  10. {
  11. pushd "$1" > /dev/null
  12. }
  13. spopd()
  14. {
  15. popd > /dev/null
  16. }
  17. MOBILE=no
  18. VERBOSE=no
  19. usage()
  20. {
  21. cat << EOF
  22. usage: $0 [options]
  23. Build vlc in the current directory
  24. OPTIONS:
  25. -h Show some help
  26. -v Be verbose
  27. -m Package MobileVLCKit
  28. EOF
  29. }
  30. while getopts "hvm" OPTION
  31. do
  32. case $OPTION in
  33. h)
  34. usage
  35. exit 1
  36. ;;
  37. v)
  38. VERBOSE=yes
  39. ;;
  40. m)
  41. MOBILE=yes
  42. ;;
  43. esac
  44. done
  45. shift $(($OPTIND - 1))
  46. out="/dev/null"
  47. if [ "$VERBOSE" = "yes" ]; then
  48. out="/dev/stdout"
  49. fi
  50. if [ "x$1" != "x" ]; then
  51. usage
  52. exit 1
  53. fi
  54. root=`dirname $0`/../
  55. DMGFOLDERNAME="VLCKit - binary package"
  56. DMGITEMNAME="VLCKit-REPLACEWITHVERSION"
  57. if [ "$MOBILE" = "yes" ]; then
  58. DMGFOLDERNAME="MobileVLCKit - binary package"
  59. DMGITEMNAME="MobileVLCKit-REPLACEWITHVERSION"
  60. fi
  61. info "checking for distributable binary package"
  62. spushd ${root}
  63. if [ "$MOBILE" = "no" ]; then
  64. if [ ! -e "VLCKit" ]; then
  65. info "VLCKit not found for distribution, creating..."
  66. if [ "$VERBOSE" = "yes" ]; then
  67. make VLCKit V=1
  68. else
  69. make VLCKit
  70. fi
  71. fi
  72. else
  73. if [ ! -e "build/MobileVLCKit.framework" ]; then
  74. info "MobileVLCKit not found for distribution, creating... this will take long"
  75. ./buildMobileVLCKit.sh -f
  76. fi
  77. fi
  78. if [ ! -e "${DMGFOLDERNAME}" ]; then
  79. info "Collecting items"
  80. mkdir -p "${DMGFOLDERNAME}"
  81. mkdir -p "${DMGFOLDERNAME}/Sample Code"
  82. if [ "$MOBILE" = "no" ]; then
  83. cp -R VLCKit/* "${DMGFOLDERNAME}"
  84. cp -R Examples_OSX/* "${DMGFOLDERNAME}/Sample Code"
  85. else
  86. cp -R build/MobileVLCKit.framework "${DMGFOLDERNAME}"
  87. cp -R Examples_iOS/* "${DMGFOLDERNAME}/Sample Code"
  88. cp COPYING "${DMGFOLDERNAME}"
  89. fi
  90. cp NEWS "${DMGFOLDERNAME}"
  91. spushd "${DMGFOLDERNAME}"
  92. mv NEWS NEWS.txt
  93. mv COPYING COPYING.txt
  94. spopd
  95. rm -f ${DMGITEMNAME}-rw.dmg
  96. fi
  97. info "Creating disk-image"
  98. hdiutil create -srcfolder "${DMGFOLDERNAME}" "${DMGITEMNAME}-rw.dmg" -scrub -format UDRW
  99. mkdir -p ./mount
  100. info "Moving file icons around"
  101. hdiutil attach -readwrite -noverify -noautoopen -mountRoot ./mount ${DMGITEMNAME}-rw.dmg
  102. if [ "$MOBILE" = "no" ]; then
  103. osascript Packaging/dmg_setup.scpt "${DMGFOLDERNAME}"
  104. else
  105. osascript Packaging/mobile_dmg_setup.scpt "${DMGFOLDERNAME}"
  106. fi
  107. hdiutil detach ./mount/"${DMGFOLDERNAME}"
  108. info "Compressing disk-image"
  109. rm -f ${DMGITEMNAME}.dmg
  110. hdiutil convert "${DMGITEMNAME}-rw.dmg" -format UDBZ -o "${DMGITEMNAME}.dmg"
  111. rm -f ${DMGITEMNAME}-rw.dmg
  112. rm -rf "${DMGFOLDERNAME}"
  113. spopd
  114. info "Disk-image created"