| 1 | #!/bin/bash |
| 2 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | # You may not use this file except in compliance with the License. |
| 6 | # A copy of the License is located at |
| 7 | # |
| 8 | # http://aws.amazon.com/apache2.0 |
| 9 | # |
| 10 | # or in the "license" file accompanying this file. This file is distributed |
| 11 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | # express or implied. See the License for the specific language governing |
| 13 | # permissions and limitations under the License. |
| 14 | # |
| 15 | |
| 16 | # Shim code to get local docker/ec2 instances bootstrapped like a CodeBuild instance. |
| 17 | # Not actually used by CodeBuild. |
| 18 | |
| 19 | # This script is now targeting Ubuntu 24 not Ubuntu 18. |
| 20 | |
| 21 | source codebuild/bin/s2n_setup_env.sh |
| 22 | |
| 23 | set -e |
| 24 | |
| 25 | github_apt(){ |
| 26 | apt update -y |
| 27 | apt install -y gh |
| 28 | } |
| 29 | get_rust() { |
| 30 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y |
| 31 | source $HOME/.cargo/env |
| 32 | rustup default nightly |
| 33 | } |
| 34 | |
| 35 | base_packages() { |
| 36 | echo "Installing repositories and base packages" |
| 37 | apt update -y |
| 38 | apt install -y software-properties-common |
| 39 | add-apt-repository ppa:ubuntu-toolchain-r/test -y |
| 40 | add-apt-repository ppa:longsleep/golang-backports -y |
| 41 | apt-get update -o Acquire::CompressionTypes::Order::=gz |
| 42 | |
| 43 | DEPENDENCIES="unzip make indent iproute2 kwstyle libssl-dev net-tools tcpdump valgrind lcov m4 nettle-dev nettle-bin pkg-config psmisc gcc g++ zlib1g-dev python3-pip python3-testresources llvm libclang-dev curl shellcheck git tox cmake libtool ninja-build golang-go quilt jq apache2" |
| 44 | if [[ -n "${GCC_VERSION:-}" ]] && [[ "${GCC_VERSION:-}" != "NONE" ]]; then |
| 45 | DEPENDENCIES+=" gcc-$GCC_VERSION g++-$GCC_VERSION"; |
| 46 | fi |
| 47 | |
| 48 | apt-get -y install --no-install-recommends ${DEPENDENCIES} |
| 49 | } |
| 50 | |
| 51 | base_packages |
| 52 | github_apt |
| 53 | get_rust |
| 54 | |
| 55 | # If prlimit is not on our current PATH, download and compile prlimit manually. s2n needs prlimit to memlock pages |
| 56 | if ! type prlimit > /dev/null && [[ ! -d "$PRLIMIT_INSTALL_DIR" ]]; then |
| 57 | mkdir -p "$PRLIMIT_INSTALL_DIR"; |
| 58 | codebuild/bin/install_prlimit.sh "$(mktemp -d)" "$PRLIMIT_INSTALL_DIR"; |
| 59 | fi |
| 60 | |
| 61 | if [[ "$TESTS" == "ctverif" || "$TESTS" == "ALL" ]] && [[ ! -d "$CTVERIF_INSTALL_DIR" ]]; then |
| 62 | mkdir -p "$CTVERIF_INSTALL_DIR" && codebuild/bin/install_ctverif.sh "$CTVERIF_INSTALL_DIR" > /dev/null ; fi |
| 63 | |
| 64 | if [[ "$TESTS" == "sidetrail" || "$TESTS" == "ALL" ]] ; then |
| 65 | codebuild/bin/install_sidetrail_dependencies.sh ; fi |
| 66 | |
| 67 | if [[ "$TESTS" == "sidetrail" || "$TESTS" == "ALL" ]] && [[ ! -d "$SIDETRAIL_INSTALL_DIR" ]]; then |
| 68 | mkdir -p "$SIDETRAIL_INSTALL_DIR" && codebuild/bin/install_sidetrail.sh "$SIDETRAIL_INSTALL_DIR" > /dev/null ; fi |