1
0

packaging-test.sh 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/bin/bash
  2. # opensuse 15 has a missing dep for systemd
  3. if which zypper > /dev/null ; then
  4. sudo zypper install -y insserv-compat docker-buildx
  5. fi
  6. if [ -e /etc/sysctl.d/99-gce.conf ]; then
  7. # The GCE defaults disable IPv4 forwarding, which breaks the Docker
  8. # build. Workaround this by renaming the file so that it is executed
  9. # earlier than our own overrides.
  10. #
  11. # This ultimately needs to be fixed at the image level - see infra
  12. # issue 15654.
  13. sudo mv /etc/sysctl.d/99-gce.conf /etc/sysctl.d/98-gce.conf
  14. fi
  15. # Required by bats
  16. sudo touch /etc/is_vagrant_vm
  17. sudo useradd vagrant
  18. set -e
  19. . .ci/java-versions.properties
  20. BUILD_JAVA_HOME=$HOME/.java/$ES_BUILD_JAVA
  21. rm -Rfv $HOME/.gradle/init.d/ && mkdir -p $HOME/.gradle/init.d
  22. cp -v .ci/init.gradle $HOME/.gradle/init.d
  23. unset JAVA_HOME
  24. if [ -f "/etc/os-release" ] ; then
  25. cat /etc/os-release
  26. . /etc/os-release
  27. if [[ "$ID" == "debian" || "$ID_LIKE" == "debian" ]] ; then
  28. # FIXME: The base image should not have rpm installed
  29. sudo rm -Rf /usr/bin/rpm
  30. # Work around incorrect lintian version
  31. # https://github.com/elastic/elasticsearch/issues/48573
  32. if [ $VERSION_ID == 10 ] ; then
  33. sudo apt-get update -y
  34. sudo apt-get install -y --allow-downgrades lintian=2.15.0
  35. fi
  36. fi
  37. if [[ "$ID" == "rhel" ]] ; then
  38. # Downgrade containerd if necessary to work around runc bug
  39. # See: https://github.com/opencontainers/runc/issues/3551
  40. if containerd -version | grep -sF 1.6.7; then
  41. sudo yum downgrade -y containerd.io
  42. fi
  43. fi
  44. else
  45. cat /etc/issue || true
  46. fi
  47. sudo bash -c 'cat > /etc/sudoers.d/elasticsearch_vars' << SUDOERS_VARS
  48. Defaults env_keep += "ES_JAVA_HOME"
  49. Defaults env_keep += "JAVA_HOME"
  50. Defaults env_keep += "SYSTEM_JAVA_HOME"
  51. SUDOERS_VARS
  52. sudo chmod 0440 /etc/sudoers.d/elasticsearch_vars
  53. # Bats tests still use this locationa
  54. sudo rm -Rf /elasticsearch
  55. sudo mkdir -p /elasticsearch/qa/ && sudo chown jenkins /elasticsearch/qa/ && ln -s $PWD/qa/vagrant /elasticsearch/qa/
  56. # Ensure since we're running as root that we can do git operations in this directory
  57. # See: https://git-scm.com/docs/git-config/2.35.2#Documentation/git-config.txt-safedirectory
  58. git config --global --add safe.directory $WORKSPACE
  59. # Older versions of openjdk are incompatible to newer kernel of ubuntu. Use adoptopenjdk17 instead
  60. resolve_system_java_home() {
  61. if [[ "$BUILD_JAVA_HOME" == *"openjdk17"* ]]; then
  62. if [ -f "/etc/os-release" ]; then
  63. . /etc/os-release
  64. if [[ "$ID" == "ubuntu" && "$VERSION_ID" == "24.04" ]]; then
  65. echo "$HOME/.java/adoptopenjdk17"
  66. return
  67. fi
  68. fi
  69. fi
  70. echo "$(readlink -f -n $BUILD_JAVA_HOME)"
  71. }
  72. # sudo sets it's own PATH thus we use env to override that and call sudo annother time so we keep the secure root PATH
  73. # run with --continue to run both bats and java tests even if one fails
  74. # be explicit about Gradle home dir so we use the same even with sudo
  75. sudo -E env \
  76. PATH=$BUILD_JAVA_HOME/bin:`sudo bash -c 'echo -n $PATH'` \
  77. --unset=ES_JAVA_HOME \
  78. --unset=JAVA_HOME \
  79. SYSTEM_JAVA_HOME=$(resolve_system_java_home) \
  80. DOCKER_CONFIG="${HOME}/.docker" \
  81. ./gradlew -g $HOME/.gradle --console=plain --scan --parallel --build-cache -Dorg.elasticsearch.build.cache.url=https://gradle-enterprise.elastic.co/cache/ --continue $@