From c0ad079f879b5d12c2d4040663048dd0715653de Mon Sep 17 00:00:00 2001 From: spham Date: Fri, 23 Apr 2021 10:06:15 -0700 Subject: [PATCH 1/3] Create a package file for packages to install on Linux and updated script to use it --- .../Linux/install-ubuntu-build-libraries.sh | 103 -------------- .../Linux/install-ubuntu-build-tools.sh | 134 +++++++++++++++--- .../Linux/package-list.ubuntu-bionic.txt | 17 +++ .../Linux/package-list.ubuntu-focal.txt | 17 +++ 4 files changed, 145 insertions(+), 126 deletions(-) delete mode 100755 scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh create mode 100644 scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt create mode 100644 scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh deleted file mode 100755 index 90786a675a..0000000000 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-libraries.sh +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash - -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - -# This script must be run as root -if [[ $EUID -ne 0 ]] -then - echo "This script must be run as root (sudo)" - exit 1 -fi - -# -# Make sure we are installing on a supported ubuntu distro -# -lsb_release -c >/dev/null 2>&1 -if [ $? -ne 0 ] -then - echo This script is only supported on Ubuntu Distros - exit 1 -fi - -UBUNTU_DISTRO="`lsb_release -c | awk '{print $2}'`" -if [ "$UBUNTU_DISTRO" == "bionic" ] -then - echo "Setup for Ubuntu 18.04 LTS ($UBUNTU_DISTRO)" -elif [ "$UBUNTU_DISTRO" == "focal" ] -then - echo "Setup for Ubuntu 20.04 LTS ($UBUNTU_DISTRO)" -else - echo "Unsupported version of Ubuntu $UBUNTU_DISTRO" - exit 1 -fi - -# -# Install curl if its not installed -# -curl --version >/dev/null 2>&1 -if [ $? -ne 0 ] -then - echo "Installing curl" - apt-get install curl -y -fi - - -# -# If the linux distro is 20.04 (focal), we need libffi.so.6, which is not part of the focal distro. We -# will install it from the bionic distro manually into focal. This is needed since Ubuntu 20.04 supports -# python 3.8 out of the box, but we are using 3.7 -# -LIBFFI6_COUNT=`apt list --installed 2>/dev/null | grep libffi6 | wc -l` -if [ "$UBUNTU_DISTRO" == "focal" ] && [ $LIBFFI6_COUNT -eq 0 ] -then - echo "Installing libffi for Ubuntu 20.04" - - pushd /tmp >/dev/null - - LIBFFI_PACKAGE_NAME=libffi6_3.2.1-8_amd64.deb - LIBFFI_PACKAGE_URL=http://mirrors.kernel.org/ubuntu/pool/main/libf/libffi/ - - curl --location $LIBFFI_PACKAGE_URL/$LIBFFI_PACKAGE_NAME -o $LIBFFI_PACKAGE_NAME - if [ $? -ne 0 ] - then - echo Unable to download $LIBFFI_PACKAGE_URL/$LIBFFI_PACKAGE_NAME - popd - exit 1 - fi - - apt install ./$LIBFFI_PACKAGE_NAME -y - if [ $? -ne 0 ] - then - echo Unable to install $LIBFFI_PACKAGE_NAME - rm -f ./$LIBFFI_PACKAGE_NAME - popd - exit 1 - fi - - rm -f ./$LIBFFI_PACKAGE_NAME - popd - echo "libffi.so.6 installed" -fi - -# Install the required build packages -apt-get install clang-6.0 -y # For the compiler and its dependencies -apt-get install libglu1-mesa-dev -y # For Qt (GL dependency) - -# The following packages resolves a runtime error with Qt Plugins -apt-get install libxcb-xinerama0 -y # For Qt plugins at runtime -apt-get install libxcb-xinput0 -y # For Qt plugins at runtime - -apt-get install libcurl4-openssl-dev -y # For HttpRequestor -apt-get install libsdl2-dev -y # For WWise - -apt-get install libz-dev -y -apt-get install mesa-common-dev -y - -echo Build Libraries Setup Complete diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh index 0c65610cf5..5fc04e0e2d 100755 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh @@ -39,36 +39,124 @@ else fi # -# Always install the latest version of cmake (from kitware) +# Install curl if its not installed # -echo Installing CMake package $CMAKE_DISTRO_VERSION - -# Remove any pre-existing version of cmake -apt purge --auto-remove cmake -y -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 -CMAKE_DEB_REPO="'deb https://apt.kitware.com/ubuntu/ $UBUNTU_DISTRO main'" - -# Add the appropriate kitware repository to apt -if [ "$UBUNTU_DISTRO" == "bionic" ] +curl --version >/dev/null 2>&1 +if [ $? -ne 0 ] then - CMAKE_DISTRO_VERSION=3.20.1-0kitware1ubuntu18.04.1 - apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' -elif [ "$UBUNTU_DISTRO" == "focal" ] -then - CMAKE_DISTRO_VERSION=3.20.1-0kitware1ubuntu20.04.1 - apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' + echo "Installing curl" + apt-get install curl -y fi -apt-get update -# Install cmake -apt-get install cmake=$CMAKE_DISTRO_VERSION -y +# +# If the linux distro is 20.04 (focal), we need libffi.so.6, which is not part of the focal distro. We +# will install it from the bionic distro manually into focal. This is needed since Ubuntu 20.04 supports +# python 3.8 out of the box, but we are using 3.7 +# +LIBFFI6_COUNT=`apt list --installed 2>/dev/null | grep libffi6 | wc -l` +if [ "$UBUNTU_DISTRO" == "focal" ] && [ $LIBFFI6_COUNT -eq 0 ] +then + echo "Installing libffi for Ubuntu 20.04" + + pushd /tmp >/dev/null + + LIBFFI_PACKAGE_NAME=libffi6_3.2.1-8_amd64.deb + LIBFFI_PACKAGE_URL=http://mirrors.kernel.org/ubuntu/pool/main/libf/libffi/ + + curl --location $LIBFFI_PACKAGE_URL/$LIBFFI_PACKAGE_NAME -o $LIBFFI_PACKAGE_NAME + if [ $? -ne 0 ] + then + echo Unable to download $LIBFFI_PACKAGE_URL/$LIBFFI_PACKAGE_NAME + popd + exit 1 + fi + + apt install ./$LIBFFI_PACKAGE_NAME -y + if [ $? -ne 0 ] + then + echo Unable to install $LIBFFI_PACKAGE_NAME + rm -f ./$LIBFFI_PACKAGE_NAME + popd + exit 1 + fi + + rm -f ./$LIBFFI_PACKAGE_NAME + popd + echo "libffi.so.6 installed" +fi # -# Make sure that Ninja is installed +# Add the kitware repository for cmake if necessary # -echo Installing Ninja -apt-get install ninja-build -y + +KITWARE_REPO_COUNT=`cat /etc/apt/sources.list | grep ^deb | grep https://apt.kitware.com/ubuntu/ | wc -l` + +if [ $KITWARE_REPO_COUNT -eq 0 ] +then + echo Adding Kitware Repository for the cmake + + 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 + CMAKE_DEB_REPO="'deb https://apt.kitware.com/ubuntu/ $UBUNTU_DISTRO main'" + + # Add the appropriate kitware repository to apt + if [ "$UBUNTU_DISTRO" == "bionic" ] + then + CMAKE_DISTRO_VERSION=3.20.1-0kitware1ubuntu18.04.1 + apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' + elif [ "$UBUNTU_DISTRO" == "focal" ] + then + CMAKE_DISTRO_VERSION=3.20.1-0kitware1ubuntu20.04.1 + apt-add-repository 'deb https://apt.kitware.com/ubuntu/ focal main' + fi + apt-get update +else + echo Kitware Repository repo already set +fi -echo Build Tools Setup Complete +# Read from the package list and process each package +PACKAGE_FILE_LIST=package-list.ubuntu-$UBUNTU_DISTRO.txt + +echo Reading package list $PACKAGE_FILE_LIST + +# Read each line (strip out comment tags) +for LINE in `cat package-list.ubuntu-focal.txt | sed 's/#.*$//g'` +do + PACKAGE=`echo $LINE | awk -F / '{print $1}'` + if [ "$PACKAGE" != "" ] # Skip blank lines + then + PACKAGE_VER=`echo $LINE | awk -F / '{print $2}'` + if [ "$PACKAGE_VER" == "" ] + then + # Process non-versioned packages + INSTALLED_COUNT=`apt list --installed 2>/dev/null | grep ^$PACKAGE/ | wc -l` + if [ $INSTALLED_COUNT -eq 0 ] + then + echo Installing $PACKAGE + apt-get install $PACKAGE -y + else + INSTALLED_VERSION=`apt list --installed 2>/dev/null | grep ^$PACKAGE/ | awk '{print $2}'` + echo $PACKAGE already installed \(version $INSTALLED_VERSION\) + fi + else + # Process versioned packages + INSTALLED_COUNT=`apt list --installed 2>/dev/null | grep ^$PACKAGE/ | wc -l` + if [ $INSTALLED_COUNT -eq 0 ] + then + echo Installing $PACKAGE \( $PACKAGE_VER \) + apt-get install $PACKAGE=$PACKAGE_VER -y + else + INSTALLED_VERSION=`apt list --installed 2>/dev/null | grep ^$PACKAGE/ | awk '{print $2}'` + if [ "$INSTALLED_VERSION" != "$PACKAGE_VER" ] + then + echo $PACKAGE already installed but with the wrong version. Purging the package + apt purge --auto-remove $PACKAGE -y + fi + echo $PACKAGE already installed \(version $INSTALLED_VERSION\) + fi + fi + fi + +done + diff --git a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt new file mode 100644 index 0000000000..3469a6f22b --- /dev/null +++ b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt @@ -0,0 +1,17 @@ +# Package list for Ubuntu 18.04 + +# Build Tools Packages +cmake/3.20.1-0kitware1ubuntu18.04.1 # For cmake +clang-6.0 # For Ninja Build System +ninja-build # For the compiler and its dependencies + +# Build Libraries +libglu1-mesa-dev # For Qt (GL dependency) +libxcb-xinerama0 # For Qt plugins at runtime +libxcb-xinput0 # For Qt plugins at runtime +libcurl4-openssl-dev # For HttpRequestor +libsdl2-dev # for WWise/Audio +zlib1g-dev +mesa-common-dev + + diff --git a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt new file mode 100644 index 0000000000..e3e6c5396b --- /dev/null +++ b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt @@ -0,0 +1,17 @@ +# Package list for Ubuntu 20.04 + +# Build Tools Packages +cmake/3.20.1-0kitware1ubuntu20.04.1 # For cmake +clang-6.0 # For Ninja Build System +ninja-build # For the compiler and its dependencies + +# Build Libraries +libglu1-mesa-dev # For Qt (GL dependency) +libxcb-xinerama0 # For Qt plugins at runtime +libxcb-xinput0 # For Qt plugins at runtime +libcurl4-openssl-dev # For HttpRequestor +libsdl2-dev # for WWise/Audio +zlib1g-dev +mesa-common-dev + + From f68ed1cd4bf479f382fc723c0c899c541b10474a Mon Sep 17 00:00:00 2001 From: spham Date: Fri, 23 Apr 2021 10:14:27 -0700 Subject: [PATCH 2/3] Fix tabs->space issues --- .../Linux/package-list.ubuntu-bionic.txt | 16 ++++++++-------- .../Platform/Linux/package-list.ubuntu-focal.txt | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt index 3469a6f22b..201e4e8424 100644 --- a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt +++ b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-bionic.txt @@ -1,16 +1,16 @@ # Package list for Ubuntu 18.04 # Build Tools Packages -cmake/3.20.1-0kitware1ubuntu18.04.1 # For cmake -clang-6.0 # For Ninja Build System -ninja-build # For the compiler and its dependencies +cmake/3.20.1-0kitware1ubuntu18.04.1 # For cmake +clang-6.0 # For Ninja Build System +ninja-build # For the compiler and its dependencies # Build Libraries -libglu1-mesa-dev # For Qt (GL dependency) -libxcb-xinerama0 # For Qt plugins at runtime -libxcb-xinput0 # For Qt plugins at runtime -libcurl4-openssl-dev # For HttpRequestor -libsdl2-dev # for WWise/Audio +libglu1-mesa-dev # For Qt (GL dependency) +libxcb-xinerama0 # For Qt plugins at runtime +libxcb-xinput0 # For Qt plugins at runtime +libcurl4-openssl-dev # For HttpRequestor +libsdl2-dev # for WWise/Audio zlib1g-dev mesa-common-dev diff --git a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt index e3e6c5396b..13b6376911 100644 --- a/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt +++ b/scripts/build/build_node/Platform/Linux/package-list.ubuntu-focal.txt @@ -1,16 +1,16 @@ # Package list for Ubuntu 20.04 # Build Tools Packages -cmake/3.20.1-0kitware1ubuntu20.04.1 # For cmake -clang-6.0 # For Ninja Build System -ninja-build # For the compiler and its dependencies +cmake/3.20.1-0kitware1ubuntu20.04.1 # For cmake +clang-6.0 # For Ninja Build System +ninja-build # For the compiler and its dependencies # Build Libraries -libglu1-mesa-dev # For Qt (GL dependency) -libxcb-xinerama0 # For Qt plugins at runtime -libxcb-xinput0 # For Qt plugins at runtime -libcurl4-openssl-dev # For HttpRequestor -libsdl2-dev # for WWise/Audio +libglu1-mesa-dev # For Qt (GL dependency) +libxcb-xinerama0 # For Qt plugins at runtime +libxcb-xinput0 # For Qt plugins at runtime +libcurl4-openssl-dev # For HttpRequestor +libsdl2-dev # for WWise/Audio zlib1g-dev mesa-common-dev From db427609744269071f60c37bf3665e237aa85fc0 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Fri, 23 Apr 2021 11:13:59 -0700 Subject: [PATCH 3/3] Update install-ubuntu-build-tools.sh --- .../build_node/Platform/Linux/install-ubuntu-build-tools.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh index 5fc04e0e2d..fd7b59592a 100755 --- a/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh +++ b/scripts/build/build_node/Platform/Linux/install-ubuntu-build-tools.sh @@ -121,7 +121,7 @@ PACKAGE_FILE_LIST=package-list.ubuntu-$UBUNTU_DISTRO.txt echo Reading package list $PACKAGE_FILE_LIST # Read each line (strip out comment tags) -for LINE in `cat package-list.ubuntu-focal.txt | sed 's/#.*$//g'` +for LINE in `cat $PACKAGE_FILE_LIST | sed 's/#.*$//g'` do PACKAGE=`echo $LINE | awk -F / '{print $1}'` if [ "$PACKAGE" != "" ] # Skip blank lines