deps.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. #!/bin/sh
  2. set -eu
  3. SKIP_OPENSSL3="${SKIP_OPENSSL3:-}"
  4. SKIP_MESON="${SKIP_MESON:-}"
  5. deps_linux_alpine() {
  6. apk upgrade
  7. apk add \
  8. git binutils ninja pkgconf gcc linux-headers shadow sudo libgcrypt-dev texinfo gzip \
  9. openssl-dev zlib-dev lzo-dev ncurses-dev readline-dev musl-dev lz4-dev vde2-dev cmocka-dev
  10. if [ -z "$SKIP_MESON" ]; then
  11. apk add meson
  12. fi
  13. }
  14. deps_linux_debian_mingw() {
  15. apt-get install -y \
  16. mingw-w64 mingw-w64-tools \
  17. wine wine-binfmt \
  18. libgcrypt-mingw-w64-dev \
  19. "$@"
  20. }
  21. deps_linux_debian_linux() {
  22. if [ -n "$HOST" ]; then
  23. dpkg --add-architecture "$HOST"
  24. fi
  25. apt-get update
  26. apt-get install -y \
  27. binutils make gcc \
  28. zlib1g-dev:"$HOST" \
  29. libssl-dev:"$HOST" \
  30. liblzo2-dev:"$HOST" \
  31. liblz4-dev:"$HOST" \
  32. libncurses-dev:"$HOST" \
  33. libreadline-dev:"$HOST" \
  34. libgcrypt-dev:"$HOST" \
  35. libminiupnpc-dev:"$HOST" \
  36. libvdeplug-dev:"$HOST" \
  37. libcmocka-dev:"$HOST" \
  38. "$@"
  39. if [ -n "$HOST" ]; then
  40. apt-get install -y crossbuild-essential-"$HOST" qemu-user
  41. else
  42. linux_openssl3
  43. fi
  44. }
  45. deps_linux_debian() {
  46. export DEBIAN_FRONTEND=noninteractive
  47. apt-get update
  48. apt-get upgrade -y
  49. apt-get install -y git pkgconf sudo texinfo ninja-build
  50. HOST=${HOST:-}
  51. if [ "$HOST" = mingw ]; then
  52. deps_linux_debian_mingw "$@"
  53. else
  54. deps_linux_debian_linux "$@"
  55. fi
  56. if [ -n "$SKIP_MESON" ]; then
  57. return
  58. fi
  59. . /etc/os-release
  60. # Debian Buster ships an old version of meson (0.49).
  61. # MinGW cross-compilation requires something newer than 0.55 that ships in Bullseye,
  62. # or it fails when looking for dependencies in the OpenSSL wrap.
  63. if [ "${ID:-}/${VERSION_CODENAME:-}" = debian/buster ] || [ "$HOST" = mingw ]; then
  64. apt-get install -y python3 python3-pip ninja-build
  65. pip3 install meson
  66. else
  67. apt-get install -y meson
  68. fi
  69. }
  70. deps_linux_rhel() {
  71. yum upgrade -y
  72. if [ "$ID" != fedora ]; then
  73. yum install -y epel-release
  74. if type dnf; then
  75. dnf install -y 'dnf-command(config-manager)'
  76. dnf config-manager --enable powertools || true
  77. dnf config-manager --enable crb || true
  78. fi
  79. fi
  80. yum install -y \
  81. git binutils make ninja-build pkgconf gcc sudo texinfo-tex systemd perl-IPC-Cmd \
  82. lzo-devel zlib-devel lz4-devel ncurses-devel readline-devel libgcrypt-devel "$@"
  83. if [ -z "$SKIP_MESON" ]; then
  84. yum install -y meson
  85. fi
  86. if yum info openssl11-devel; then
  87. yum install -y openssl11-devel
  88. else
  89. dnf install -y openssl-devel
  90. fi
  91. if yum info miniupnpc-devel; then
  92. yum install -y miniupnpc-devel
  93. fi
  94. }
  95. linux_openssl3() {
  96. if [ -n "$SKIP_OPENSSL3" ]; then
  97. echo >&2 "skipping openssl3 installation in this job"
  98. return
  99. fi
  100. src=/usr/local/src/openssl
  101. ssl3=/opt/ssl3
  102. mkdir -p $src
  103. git clone --depth 1 --branch openssl-3.0.2 https://github.com/openssl/openssl $src
  104. cd $src
  105. ./Configure --prefix=$ssl3 --openssldir=$ssl3
  106. make -j"$(nproc)"
  107. make install_sw
  108. if [ -f /etc/ld.so.conf ]; then
  109. echo $ssl3/lib64 >>/etc/ld.so.conf
  110. ldconfig -v
  111. else
  112. ldconfig -v $ssl3/lib64
  113. fi
  114. cd -
  115. }
  116. deps_linux() {
  117. . /etc/os-release
  118. case "$ID" in
  119. alpine)
  120. deps_linux_alpine "$@"
  121. ;;
  122. debian | ubuntu)
  123. deps_linux_debian "$@"
  124. ;;
  125. fedora)
  126. deps_linux_rhel "$@"
  127. ;;
  128. centos | almalinux)
  129. deps_linux_rhel "$@"
  130. if [ "${PLATFORM_ID:-}" != platform:el9 ]; then
  131. linux_openssl3
  132. fi
  133. ;;
  134. *) exit 1 ;;
  135. esac
  136. }
  137. deps_macos() {
  138. brew install lzo lz4 miniupnpc libgcrypt openssl "$@"
  139. if [ -z "$SKIP_MESON" ]; then
  140. brew install meson
  141. fi
  142. }
  143. case "$(uname -s)" in
  144. Linux) deps_linux "$@" ;;
  145. Darwin) deps_macos "$@" ;;
  146. *) exit 1 ;;
  147. esac