create-dmg.sh 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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 [ "$MOBILE" = "yes" ]; then
  69. if [ "$USEZIP" = "yes" ]; then
  70. DMGFOLDERNAME="MobileVLCKit-binary"
  71. else
  72. DMGFOLDERNAME="MobileVLCKit - binary package"
  73. fi
  74. DMGITEMNAME="MobileVLCKit-REPLACEWITHVERSION"
  75. fi
  76. if [ "$TV" = "yes" ]; then
  77. if [ "$USEZIP" = "yes" ]; then
  78. DMGFOLDERNAME="TVVLCKit-binary"
  79. else
  80. DMGFOLDERNAME="TVVLCKit - binary package"
  81. fi
  82. DMGITEMNAME="TVVLCKit-REPLACEWITHVERSION"
  83. fi
  84. info "checking for distributable binary package"
  85. spushd ${root}
  86. if [ "$MOBILE" = "no" ]; then
  87. if [ ! -e "VLCKit" ]; then
  88. info "VLCKit not found for distribution, creating..."
  89. if [ "$VERBOSE" = "yes" ]; then
  90. make VLCKit V=1
  91. else
  92. make VLCKit
  93. fi
  94. fi
  95. else
  96. if [ "$TV" = "yes" ]; then
  97. if [ ! -e "build/TVVLCKit.framework" ]; then
  98. info "TVVLCKit not found for distribution, creating... this will take long"
  99. ./buildMobileVLCKit.sh -f -t
  100. fi
  101. else
  102. if [ ! -e "build/MobileVLCKit.framework" ]; then
  103. info "MobileVLCKit not found for distribution, creating... this will take long"
  104. ./buildMobileVLCKit.sh -f
  105. fi
  106. fi
  107. fi
  108. if [ ! -e "${DMGFOLDERNAME}" ]; then
  109. info "Collecting items"
  110. mkdir -p "${DMGFOLDERNAME}"
  111. mkdir -p "${DMGFOLDERNAME}/Sample Code"
  112. if [ "$MOBILE" = "no" ]; then
  113. cp -R VLCKit/* "${DMGFOLDERNAME}"
  114. cp -R Examples_OSX/* "${DMGFOLDERNAME}/Sample Code"
  115. else
  116. if [ "$TV" = "yes" ]; then
  117. cp -R build/TVVLCKit.framework "${DMGFOLDERNAME}"
  118. else
  119. cp -R build/MobileVLCKit.framework "${DMGFOLDERNAME}"
  120. cp -R Examples_iOS/* "${DMGFOLDERNAME}/Sample Code"
  121. fi
  122. cp COPYING "${DMGFOLDERNAME}"
  123. fi
  124. cp NEWS "${DMGFOLDERNAME}"
  125. spushd "${DMGFOLDERNAME}"
  126. mv NEWS NEWS.txt
  127. mv COPYING COPYING.txt
  128. spopd
  129. rm -f ${DMGITEMNAME}-rw.dmg
  130. fi
  131. if [ "$USEZIP" = "no" ]; then
  132. info "Creating disk-image"
  133. hdiutil create -srcfolder "${DMGFOLDERNAME}" "${DMGITEMNAME}-rw.dmg" -scrub -format UDRW
  134. mkdir -p ./mount
  135. info "Moving file icons around"
  136. hdiutil attach -readwrite -noverify -noautoopen -mountRoot ./mount ${DMGITEMNAME}-rw.dmg
  137. if [ "$MOBILE" = "no" ]; then
  138. osascript Packaging/dmg_setup.scpt "${DMGFOLDERNAME}"
  139. else
  140. if [ "$TV" = "no" ]; then
  141. osascript Packaging/mobile_dmg_setup.scpt "${DMGFOLDERNAME}"
  142. fi
  143. fi
  144. hdiutil detach ./mount/"${DMGFOLDERNAME}"
  145. info "Compressing disk-image"
  146. rm -f ${DMGITEMNAME}.dmg
  147. hdiutil convert "${DMGITEMNAME}-rw.dmg" -format UDBZ -o "${DMGITEMNAME}.dmg"
  148. rm -f ${DMGITEMNAME}-rw.dmg
  149. rm -rf "${DMGFOLDERNAME}"
  150. else
  151. info "Creating zip-archive"
  152. zip -r ${DMGITEMNAME}.zip "${DMGFOLDERNAME}"
  153. fi
  154. spopd
  155. info "Distributable package created"