create-dmg.sh 3.9 KB

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