Javicle - a JSON Video Composition Language
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

107 satır
3.1 KiB

  1. #!/bin/bash
  2. function die () {
  3. echo 1>&2 "${1}"
  4. exit 1
  5. }
  6. function java_major_version () {
  7. for token in $(java -version 2>&1 | grep -i version) ; do
  8. case "${token}" in '"1'*)
  9. echo -n "${token}" | tr -d '"' | awk -F '.' '{print $1}'
  10. esac
  11. done
  12. }
  13. function handle_help_request() {
  14. if [[ -z "${2}" ]]; then
  15. return
  16. fi
  17. if [[ ${2} == "-h" || ${2} == "--help" ]]; then
  18. while IFS='' read -r line || [[ -n "$line" ]]; do
  19. if [[ ${line} =~ ^#.* ]]; then
  20. if [[ ! ${line} =~ ^#!/bin/bash.* ]]; then
  21. echo "${line}"
  22. fi
  23. else
  24. break
  25. fi
  26. done <"${1}"
  27. if [[ -z "${JVC_SKIP_ENV_VAR_HELP}" ]] ; then
  28. echo "# Environment Variables
  29. #
  30. # JVC_SCRATCH_DIR : Use this as the scratch directory
  31. # Default is to create a new temp directory
  32. #
  33. # JVC_NO_EXEC : If set to anything, print the commands that would
  34. # have run but do not execute anything
  35. #
  36. "
  37. fi
  38. exit 1
  39. fi
  40. }
  41. # Ensure Java is installed and that it is Java 11
  42. if [[ -z "$(which java)" ]] ; then
  43. die "Java 11 (or higher) not installed (java command not found on PATH)"
  44. fi
  45. JAVA_VERSION="$(java_major_version)"
  46. if [[ -z "${JAVA_VERSION}" ]] ; then
  47. die "Error determining Java version"
  48. elif [[ ${JAVA_VERSION} -lt 11 ]] ; then
  49. die "Java 11 (or higher) not installed (java -version check failed)"
  50. fi
  51. JVC_DIR="$(cd "$(dirname "${0}")"/.. && pwd)"
  52. JVC_JAR="$(find "${JVC_DIR}"/target -type f -name "jvc-*-prod.jar" | head -1)"
  53. if [[ -z "${JVC_JAR}" ]] ; then
  54. # Ensure maven is installed
  55. if [[ -z "$(which mvn)" ]] ; then
  56. die "Maven not installed (mvn command not found on PATH), cannot build JVC jar"
  57. fi
  58. # Build and install utility libraries
  59. pushd "${JVC_DIR}"/utils/cobbzilla-parent || die "Error changing directories to ${JVC_DIR}/utils/cobbzilla-parent"
  60. if [[ -z "$(find . -type f)" ]] ; then
  61. cd ../.. && \
  62. ./bin/use_https_submodules && \
  63. git submodule update --init --recursive && \
  64. cd - \
  65. || die "Error updating git submodule"
  66. fi
  67. mvn install || die "Error installing cobbzilla-parent"
  68. popd || die "popd error (pwd=$(pwd))"
  69. pushd "${JVC_DIR}"/utils/cobbzilla-utils || die "Error changing directories to ${JVC_DIR}/utils/cobbzilla-utils"
  70. if [[ -z "$(find target -type f -name "*.jar")" ]] ; then
  71. mvn -DskipTests=true clean install || die "Error building cobbzilla-utils library"
  72. fi
  73. popd || die "popd error (pwd=$(pwd))"
  74. # Build jvc uberjar
  75. pushd "${JVC_DIR}" || die "Error changing directories to ${JVC_DIR}"
  76. mvn -DskipTests=true -Puberjar clean package || die "Error building JVC jar"
  77. popd || die "popd error (pwd=$(pwd))"
  78. JVC_JAR="$(find "${JVC_DIR}"/target -type f -name "jvc-*-prod.jar" | head -1)"
  79. if [[ -z "${JVC_JAR}" ]] ; then
  80. die "No JVC jar file found after successful build"
  81. fi
  82. fi
  83. SCRATCH_DIR=""
  84. NO_EXEC=""
  85. if [[ -z "${JVC_SKIP_ENV_VAR_HELP}" ]] ; then
  86. if [[ -n "${JVC_SCRATCH_DIR}" ]] ; then
  87. SCRATCH_DIR="--temp-dir ${JVC_SCRATCH_DIR}"
  88. fi
  89. if [[ -n "${JVC_NO_EXEC}" ]] ; then
  90. NO_EXEC="--no-exec"
  91. fi
  92. fi
  93. JVC_OPTIONS="${SCRATCH_DIR} ${NO_EXEC}"
  94. handle_help_request "${0}" "${1}"