create-dmg.sh 2.9 KB

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