install-ubuntu-build-tools.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. # This script must be run as root
  8. if [[ $EUID -ne 0 ]]
  9. then
  10. echo "This script must be run as root (sudo)"
  11. exit 1
  12. fi
  13. #
  14. # Make sure we are installing on a supported ubuntu distro
  15. #
  16. lsb_release -c >/dev/null 2>&1
  17. if [ $? -ne 0 ]
  18. then
  19. echo This script is only supported on Ubuntu Distros
  20. exit 1
  21. fi
  22. #
  23. # Get Ubuntu version data
  24. #
  25. UBUNTU_DISTRO="$(lsb_release -sc)"
  26. UBUNTU_VER="$(lsb_release -sr)"
  27. if [ "$UBUNTU_DISTRO" == "bionic" ] || [ "$UBUNTU_DISTRO" == "focal" ] || [ "$UBUNTU_DISTRO" == "jammy" ]
  28. then
  29. echo "Setup for Ubuntu $UBUNTU_VER LTS ($UBUNTU_DISTRO)"
  30. else
  31. echo "Unsupported OS version - $UBUNTU_DISTRO"
  32. exit 1
  33. fi
  34. #
  35. # Add Ubuntu universe repo
  36. #
  37. apt install software-properties-common
  38. add-apt-repository universe
  39. #
  40. # Install curl if its not installed
  41. #
  42. curl --version >/dev/null 2>&1
  43. if [ $? -ne 0 ]
  44. then
  45. echo "Installing curl"
  46. apt-get install curl -y
  47. fi
  48. #
  49. # Add the kitware repository for cmake if necessary
  50. #
  51. KITWARE_REPO_COUNT=$(cat /etc/apt/sources.list | grep ^deb | grep https://apt.kitware.com/ubuntu/ | wc -l)
  52. CMAKE_VER=3.22.1
  53. if [ $KITWARE_REPO_COUNT -eq 0 ]
  54. then
  55. echo Adding Kitware Repository for CMake $CMAKE_VER
  56. wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
  57. CMAKE_DEB_REPO="'deb https://apt.kitware.com/ubuntu/ $UBUNTU_DISTRO main'"
  58. # Add the appropriate kitware repository to apt
  59. if [ "$UBUNTU_DISTRO" == "bionic" ] || [ "$UBUNTU_DISTRO" == "focal" ]
  60. then
  61. CMAKE_DISTRO_VERSION=$CMAKE_VER-0kitware1ubuntu$UBUNTU_VER.1
  62. apt-add-repository "deb https://apt.kitware.com/ubuntu/ $UBUNTU_DISTRO main"
  63. elif [ "$UBUNTU_DISTRO" == "jammy" ]
  64. then
  65. # Ubuntu 22.04 already has an acceptable version of cmake
  66. echo "Ubuntu 22.04's cmake package already at version $CMAKE_VER"
  67. fi
  68. else
  69. echo Kitware Repository repo already set
  70. fi
  71. #
  72. # Add Amazon Corretto repository to install the necessary JDK for Jenkins and Android
  73. #
  74. CORRETTO_REPO_COUNT=$(cat /etc/apt/sources.list | grep ^dev | grep https://apt.corretto.aws | wc -l)
  75. if [ $CORRETTO_REPO_COUNT -eq 0 ]
  76. then
  77. echo Adding Corretto Repository for JDK
  78. wget -O- https://apt.corretto.aws/corretto.key | apt-key add -
  79. add-apt-repository 'deb https://apt.corretto.aws stable main'
  80. else
  81. echo Corretto repo already set
  82. fi
  83. #
  84. # Add the repository for ROS2
  85. #
  86. ROS2_REPO_COUNT=$(cat /etc/apt/sources.list | grep ^deb | grep http://packages.ros.org/ros2/ubuntu | wc -l)
  87. if [ $ROS2_REPO_COUNT -eq 0 ]
  88. then
  89. echo Adding ROS2 Repository
  90. curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
  91. echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $UBUNTU_DISTRO main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
  92. else
  93. echo ROS2 repo already set
  94. fi
  95. #
  96. # Finally, update the sources repos
  97. #
  98. apt-get update