create-distributable-package.sh 4.5 KB

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