create-distributable-package.sh 4.1 KB

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