01_install_dependencies.sh 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #!/bin/bash
  2. ##############################################################################
  3. # Linux dependency management function
  4. ##############################################################################
  5. #
  6. # This script file can be included in build scripts for Linux or run directly
  7. # with the -s/--standalone switch
  8. #
  9. ##############################################################################
  10. # Halt on errors
  11. set -eE
  12. install_build-deps() {
  13. shift
  14. status "Install OBS build dependencies"
  15. trap "caught_error 'install_build-deps'" ERR
  16. sudo apt-get install -y $@
  17. }
  18. install_obs-deps() {
  19. shift
  20. status "Install OBS dependencies"
  21. trap "caught_error 'install_obs-deps'" ERR
  22. if [ -z "${DISABLE_PIPEWIRE}" ]; then
  23. sudo apt-get install -y $@ libpipewire-0.3-dev
  24. else
  25. sudo apt-get install -y $@
  26. fi
  27. }
  28. install_qt-deps() {
  29. shift
  30. status "Install Qt dependencies"
  31. trap "caught_error 'install_qt-deps'" ERR
  32. sudo apt-get install -y $@
  33. }
  34. install_cef() {
  35. shift
  36. status "Setup for dependency CEF v${1}"
  37. ensure_dir "${DEPS_BUILD_DIR}"
  38. if [ "${CI}" -a "${RESTORED_CEF}" ]; then
  39. _SKIP=TRUE
  40. elif [ -d "${DEPS_BUILD_DIR}/cef_binary_${1}_linux64" -a -f "${DEPS_BUILD_DIR}/cef_binary_${1}_linux64/build/libcef_dll_wrapper/libcef_dll_wrapper.a" ]; then
  41. _SKIP=TRUE
  42. fi
  43. if [ -z "${_SKIP}" ]; then
  44. step "Download..."
  45. ${CURLCMD:-curl -O} https://cdn-fastly.obsproject.com/downloads/cef_binary_${1}_linux64.tar.bz2
  46. step "Unpack..."
  47. tar -xf cef_binary_${1}_linux64.tar.bz2
  48. else
  49. step "Found existing Chromium Embedded Framework and loader library..."
  50. fi
  51. }
  52. install_plugin-deps() {
  53. shift
  54. status "Install plugin dependencies"
  55. trap "caught_error 'install_plugin-deps'" ERR
  56. sudo apt-get install -y $@
  57. }
  58. install_dependencies() {
  59. status "Set up apt"
  60. trap "caught_error 'install_dependencies'" ERR
  61. BUILD_DEPS=(
  62. "build-deps cmake ninja-build pkg-config clang clang-format build-essential curl ccache"
  63. "obs-deps libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswresample-dev \
  64. libswscale-dev libx264-dev libcurl4-openssl-dev libmbedtls-dev libgl1-mesa-dev libjansson-dev \
  65. libluajit-5.1-dev python3-dev libx11-dev libxcb-randr0-dev libxcb-shm0-dev libxcb-xinerama0-dev \
  66. libxcb-composite0-dev libxinerama-dev libxcb1-dev libx11-xcb-dev libxcb-xfixes0-dev swig libcmocka-dev \
  67. libpci-dev libxss-dev libglvnd-dev libgles2-mesa libgles2-mesa-dev libwayland-dev libxkbcommon-dev"
  68. "qt-deps qtbase5-dev qtbase5-private-dev libqt5svg5-dev qtwayland5"
  69. "cef ${LINUX_CEF_BUILD_VERSION:-${CI_LINUX_CEF_VERSION}}"
  70. "plugin-deps libasound2-dev libfdk-aac-dev libfontconfig-dev libfreetype6-dev libjack-jackd2-dev \
  71. libpulse-dev libsndio-dev libspeexdsp-dev libudev-dev libv4l-dev libva-dev libvlc-dev libdrm-dev"
  72. )
  73. sudo dpkg --add-architecture amd64
  74. sudo apt-get -qq update
  75. for DEPENDENCY in "${BUILD_DEPS[@]}"; do
  76. set -- ${DEPENDENCY}
  77. trap "caught_error ${DEPENDENCY}" ERR
  78. FUNC_NAME="install_${1}"
  79. ${FUNC_NAME} ${@}
  80. done
  81. }
  82. install-dependencies-standalone() {
  83. CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
  84. PRODUCT_NAME="OBS-Studio"
  85. DEPS_BUILD_DIR="${CHECKOUT_DIR}/../obs-build-dependencies"
  86. source "${CHECKOUT_DIR}/CI/include/build_support.sh"
  87. source "${CHECKOUT_DIR}/CI/include/build_support_linux.sh"
  88. status "Setup of OBS build dependencies"
  89. install_dependencies
  90. }
  91. print_usage() {
  92. echo -e "Usage: ${0}\n" \
  93. "-h, --help : Print this help\n" \
  94. "-q, --quiet : Suppress most build process output\n" \
  95. "-v, --verbose : Enable more verbose build process output\n" \
  96. "--disable-pipewire : Disable building with Pipewire support (default: off)\n"
  97. }
  98. install-dependencies-main() {
  99. if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
  100. while true; do
  101. case "${1}" in
  102. -h | --help ) print_usage; exit 0 ;;
  103. -q | --quiet ) export QUIET=TRUE; shift ;;
  104. -v | --verbose ) export VERBOSE=TRUE; shift ;;
  105. --disable-pipewire ) DISABLE_PIPEWIRE=TRUE; shift ;;
  106. -- ) shift; break ;;
  107. * ) break ;;
  108. esac
  109. done
  110. install-dependencies-standalone
  111. fi
  112. }
  113. install-dependencies-main $*