03_package_obs.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. ##############################################################################
  3. # Linux libobs plugin package function
  4. ##############################################################################
  5. #
  6. # This script file can be included in build scripts for Linux or run directly
  7. #
  8. ##############################################################################
  9. # Halt on errors
  10. set -eE
  11. package_obs() {
  12. status "Create Linux debian package"
  13. trap "caught_error 'package app'" ERR
  14. ensure_dir "${CHECKOUT_DIR}"
  15. step "Package OBS..."
  16. cmake --build ${BUILD_DIR} -t package
  17. DEB_NAME=$(find ${BUILD_DIR} -maxdepth 1 -type f -name "obs*.deb" | sort -rn | head -1)
  18. if [ "${DEB_NAME}" ]; then
  19. mv ${DEB_NAME} ${BUILD_DIR}/${FILE_NAME}
  20. else
  21. error "ERROR No suitable OBS debian package generated"
  22. fi
  23. }
  24. package-obs-standalone() {
  25. PRODUCT_NAME="OBS-Studio"
  26. CHECKOUT_DIR="$(git rev-parse --show-toplevel)"
  27. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  28. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  29. source "${CHECKOUT_DIR}/CI/include/build_support_linux.sh"
  30. if [ -z "${CI}" ]; then
  31. step "Fetch OBS tags..."
  32. git fetch --tags origin
  33. fi
  34. GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
  35. GIT_HASH=$(git rev-parse --short=9 HEAD)
  36. GIT_TAG=$(git describe --tags --abbrev=0)
  37. UBUNTU_VERSION=$(lsb_release -sr)
  38. if [ "${BUILD_FOR_DISTRIBUTION}" = "true" ]; then
  39. VERSION_STRING="${GIT_TAG}"
  40. else
  41. VERSION_STRING="${GIT_TAG}-${GIT_HASH}"
  42. fi
  43. FILE_NAME="obs-studio-${VERSION_STRING}-ubuntu-${UBUNTU_VERSION}.deb"
  44. package_obs
  45. }
  46. print_usage() {
  47. echo -e "Usage: ${0}\n" \
  48. "-h, --help : Print this help\n" \
  49. "-q, --quiet : Suppress most build process output\n" \
  50. "-v, --verbose : Enable more verbose build process output\n" \
  51. "--build-dir : Specify alternative build directory (default: build)\n"
  52. }
  53. package-obs-main() {
  54. if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
  55. while true; do
  56. case "${1}" in
  57. -h | --help ) print_usage; exit 0 ;;
  58. -q | --quiet ) export QUIET=TRUE; shift ;;
  59. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  60. --build-dir ) BUILD_DIR="${2}"; shift 2 ;;
  61. -- ) shift; break ;;
  62. * ) break ;;
  63. esac
  64. done
  65. package-obs-standalone
  66. fi
  67. }
  68. package-obs-main $*