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.

94 lines
2.6 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. pulse_dir=$(find . -maxdepth 1 -name pulseaudio-[0-9]\*)
  63. if [[ -z $pulse_dir ]]; then
  64. echo "** Can't find pulse dir in $(ls)" >&2
  65. exit 1
  66. fi
  67. cd $pulse_dir
  68. ./configure
  69. # We only need the src/ directory and config.h
  70. echo "- Removing unnecessary files"
  71. find . -mindepth 1 -maxdepth 1 -name src -o -name config.h -o -exec rm -rf {} +
  72. echo "- Renaming $(pwd)/$pulse_dir as $PULSE_DIR"
  73. cd ..
  74. mv $pulse_dir $PULSE_DIR
  75. fi
  76. exit 0