You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.1 KiB

  1. #!/bin/sh
  2. #
  3. # xrdp: A Remote Desktop Protocol server.
  4. #
  5. # Copyright (C) 2021 Matt Burt, all xrdp contributors
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License");
  8. # you may not use this file except in compliance with the License.
  9. # You may obtain a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS,
  15. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. # See the License for the specific language governing permissions and
  17. # limitations under the License.
  18. #
  19. # Builds the pulseaudio sources on Debian/Ubuntu and writes the internal
  20. # pulseaudio files needed to build the xrdp pulseaudio module into a
  21. # single directory
  22. # This script will pollute the machine with all the pulseaudio dependencies
  23. # needed to build the pulseaudio dpkg. If this isn't acceptable, consider
  24. # running this script in a schroot (or similar) wrapper.
  25. # Use '-d <dir>' to specify an alternate directory
  26. set -e ; # Exit on any error
  27. # Target directory for output files
  28. PULSE_DIR="$HOME/pulseaudio.src" ; # Default if nothing is specified
  29. # Argument processing
  30. while [ $# -gt 0 ]; do
  31. arg="$1"
  32. shift
  33. case "$arg" in
  34. -d) if [ $# -gt 0 ]; then
  35. PULSE_DIR="$1"
  36. shift
  37. else
  38. echo "** $arg needs an argument" >&2
  39. fi
  40. ;;
  41. *) echo "** Unrecognised argument '$arg'" >&2
  42. esac
  43. done
  44. if [ ! -d "$PULSE_DIR" ]; then
  45. # Operating system release ?
  46. RELEASE="$(lsb_release -si)-$(lsb_release -sr)"
  47. echo "Building for : $RELEASE"
  48. # Make sure sources are available
  49. if ! grep -q '^ *deb-src' /etc/apt/sources.list; then
  50. sudo sed -i.bak -e 's|^# deb-src|deb-src|' /etc/apt/sources.list
  51. fi
  52. sudo apt-get update
  53. sudo apt-get build-dep -y pulseaudio
  54. # Install any missing dependencies for this software release
  55. case "$RELEASE" in
  56. Ubuntu-16.04)
  57. sudo apt-get install -y libjson-c-dev
  58. ;;
  59. esac
  60. cd "$(dirname $PULSE_DIR)"
  61. apt-get source pulseaudio
  62. build_dir="$(find . -maxdepth 1 -name pulseaudio-[0-9]\*)"
  63. if [ -z "$build_dir" ]; then
  64. echo "** Can't find build directory in $(ls)" >&2
  65. exit 1
  66. fi
  67. cd "$build_dir"
  68. if [ -x ./configure ]; then
  69. # This version of PA uses autotools to build
  70. # This command creates ./config.h
  71. ./configure
  72. elif [ -f ./meson.build ]; then
  73. # Meson only
  74. rm -rf build
  75. # This command creates ./build/config.h
  76. meson build
  77. else
  78. echo "** Unable to configure pulseaudio from files in $(pwd)" >&2
  79. false
  80. fi
  81. echo "- Removing unnecessary files"
  82. # We only need .h files...
  83. find . -type f \! -name \*.h -delete
  84. # .. in src/ and /build directories
  85. find . -mindepth 1 -maxdepth 1 \
  86. -name src -o -name build -o -name config.h \
  87. -o -exec rm -rf {} +
  88. echo "- Renaming $(pwd)/$build_dir as $PULSE_DIR"
  89. cd ..
  90. mv "$build_dir" "$PULSE_DIR"
  91. fi
  92. exit 0