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.

146 lines
4.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. codename=$(lsb_release -cs)
  48. echo "Building for : $RELEASE ($codename)"
  49. # Do any special-case stuff related to repositories
  50. case $(lsb_release -si) in
  51. Ubuntu)
  52. # Enable the universe repository. Don't use add-apt-repository
  53. # as this has a huge number of dependencies.
  54. if ! grep -q '^ *[^#].* universe *' /etc/apt/sources.list; then
  55. echo "- Adding 'universe' repository" >&2
  56. cp /etc/apt/sources.list /tmp/sources.list
  57. while read type url suite rest; do
  58. if [ "$type" = deb -a "$rest" = main ]; then
  59. case "$suite" in
  60. $codename | $codename-updates | $codename-security)
  61. echo "deb $url $suite universe"
  62. ;;
  63. esac
  64. fi
  65. done </tmp/sources.list \
  66. | sudo tee -a /etc/apt/sources.list >/dev/null
  67. rm /tmp/sources.list
  68. fi
  69. ;;
  70. esac
  71. # Make sure sources are available
  72. if ! grep -q '^ *deb-src' /etc/apt/sources.list; then
  73. echo "- Adding source repositories" >&2
  74. cp /etc/apt/sources.list /tmp/sources.list
  75. while read type url suite rest; do
  76. if [ "$type" = deb ]; then
  77. case "$suite" in
  78. $codename | $codename-updates | $codename-security)
  79. echo "deb-src $url $suite $rest"
  80. ;;
  81. esac
  82. fi
  83. done </tmp/sources.list \
  84. | sudo tee -a /etc/apt/sources.list >/dev/null
  85. rm /tmp/sources.list
  86. fi
  87. sudo apt-get update
  88. sudo apt-get build-dep -y pulseaudio
  89. # Install any missing dependencies for this software release
  90. case "$RELEASE" in
  91. Ubuntu-16.04)
  92. sudo apt-get install -y libjson-c-dev
  93. ;;
  94. esac
  95. cd "$(dirname $PULSE_DIR)"
  96. apt-get source pulseaudio
  97. build_dir="$(find . -maxdepth 1 -name pulseaudio-[0-9]\*)"
  98. if [ -z "$build_dir" ]; then
  99. echo "** Can't find build directory in $(ls)" >&2
  100. exit 1
  101. fi
  102. cd "$build_dir"
  103. if [ -x ./configure ]; then
  104. # This version of PA uses autotools to build
  105. # This command creates ./config.h
  106. ./configure
  107. elif [ -f ./meson.build ]; then
  108. # Meson only
  109. rm -rf build
  110. # This command creates ./build/config.h
  111. meson build
  112. else
  113. echo "** Unable to configure pulseaudio from files in $(pwd)" >&2
  114. false
  115. fi
  116. echo "- Removing unnecessary files"
  117. # We only need .h files...
  118. find . -type f \! -name \*.h -delete
  119. # .. in src/ and /build directories
  120. find . -mindepth 1 -maxdepth 1 \
  121. -name src -o -name build -o -name config.h \
  122. -o -exec rm -rf {} +
  123. echo "- Renaming $(pwd)/$build_dir as $PULSE_DIR"
  124. cd ..
  125. mv "$build_dir" "$PULSE_DIR"
  126. fi
  127. exit 0