Mirror of strace – the linux syscall tracer
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.

install-dependencies.sh 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #!/bin/sh -ex
  2. #
  3. # Copyright (c) 2018-2020 The strace developers.
  4. # All rights reserved.
  5. #
  6. # SPDX-License-Identifier: GPL-2.0-or-later
  7. j=-j`nproc` || j=
  8. type sudo >/dev/null 2>&1 && sudo=sudo || sudo=
  9. common_packages='autoconf automake faketime file gawk git gzip libbluetooth-dev make xz-utils'
  10. retry_if_failed()
  11. {
  12. for i in `seq 0 99`; do
  13. "$@" && i= && break || sleep 1
  14. done
  15. [ -z "$i" ]
  16. }
  17. updated=
  18. apt_get_install()
  19. {
  20. [ -n "$updated" ] || {
  21. retry_if_failed $sudo apt-get -qq update
  22. updated=1
  23. }
  24. retry_if_failed $sudo \
  25. apt-get -qq --no-install-suggests --no-install-recommends \
  26. install -y "$@"
  27. }
  28. git_installed=
  29. clone_repo()
  30. {
  31. local src dst branch
  32. src="$1"; shift
  33. dst="$1"; shift
  34. branch="${1-}"
  35. [ -n "$git_installed" ] || {
  36. apt_get_install git ca-certificates
  37. git_installed=1
  38. }
  39. case "$src" in
  40. *://*) ;;
  41. *) local url path
  42. url="$(git config remote.origin.url)"
  43. path="${url#*://*/}"
  44. src="${url%$path}$src"
  45. ;;
  46. esac
  47. retry_if_failed \
  48. git clone --depth=1 ${branch:+--branch $branch} "$src" "$dst"
  49. }
  50. case "$TARGET" in
  51. aarch64)
  52. packages="$common_packages gcc-multilib-arm-linux-gnueabihf libc6-dev-armhf-cross linux-libc-dev-armhf-cross"
  53. ;;
  54. x86_64|x32|x86|s390x)
  55. packages="$common_packages gcc-multilib"
  56. ;;
  57. *)
  58. packages="$common_packages gcc"
  59. ;;
  60. esac
  61. case "$CC" in
  62. gcc-*)
  63. retry_if_failed \
  64. $sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
  65. case "$TARGET" in
  66. aarch64)
  67. apt_get_install $packages "$CC"-multilib-arm-linux-gnueabihf "$CC"
  68. ;;
  69. x86_64|x32|x86|s390x)
  70. apt_get_install $packages "$CC"-multilib "$CC"
  71. ;;
  72. *)
  73. apt_get_install $packages "$CC"
  74. ;;
  75. esac
  76. ;;
  77. clang*)
  78. apt_get_install $packages "$CC"
  79. ;;
  80. *)
  81. apt_get_install $packages
  82. ;;
  83. esac
  84. case "$KHEADERS" in
  85. */*)
  86. clone_repo https://github.com/"$KHEADERS" kernel ${KBRANCH-}
  87. apt_get_install rsync
  88. $sudo make $j -C kernel headers_install INSTALL_HDR_PATH=/opt/kernel
  89. $sudo rm -rf kernel
  90. KHEADERS_INC=/opt/kernel/include
  91. ;;
  92. *)
  93. KHEADERS_INC=/usr/include
  94. ;;
  95. esac
  96. case "$CC" in
  97. musl-gcc)
  98. clone_repo strace/musl musl
  99. cd musl
  100. CC=gcc
  101. build=
  102. case "${TARGET-}" in
  103. x32)
  104. CC="$CC -mx32"
  105. ;;
  106. x86)
  107. CC="$CC -m32"
  108. build='--build=i686-pc-linux-gnu --target=i686-pc-linux-gnu'
  109. ;;
  110. esac
  111. ./configure --prefix=/opt/musl --exec-prefix=/usr ${build}
  112. make $j
  113. $sudo make $j install
  114. cd -
  115. rm -rf musl
  116. $sudo ln -s \
  117. $KHEADERS_INC/asm* \
  118. $KHEADERS_INC/linux \
  119. $KHEADERS_INC/mtd \
  120. /opt/musl/include/
  121. ;;
  122. esac
  123. case "${STACKTRACE-}" in
  124. libdw)
  125. apt_get_install libdw-dev libiberty-dev
  126. ;;
  127. libunwind)
  128. apt_get_install libunwind8-dev libiberty-dev
  129. ;;
  130. esac
  131. case "${CHECK-}" in
  132. coverage)
  133. curl -s -S https://codecov.io/bash > codecov.bash
  134. chmod u+x codecov.bash
  135. ;;
  136. valgrind)
  137. apt_get_install valgrind
  138. ;;
  139. esac