| 1 | #!/bin/bash |
| 2 | # |
| 3 | # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"). |
| 6 | # You may not use this file except in compliance with the License. |
| 7 | # A copy of the License is located at |
| 8 | # |
| 9 | # http://aws.amazon.com/apache2.0 |
| 10 | # |
| 11 | # or in the "license" file accompanying this file. This file is distributed |
| 12 | # on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 13 | # express or implied. See the License for the specific language governing |
| 14 | # permissions and limitations under the License. |
| 15 | # |
| 16 | |
| 17 | set -e |
| 18 | source codebuild/bin/s2n_setup_env.sh |
| 19 | |
| 20 | usage() { |
| 21 | echo "install_gnutls37.sh build_dir install_dir os_name" |
| 22 | exit 1 |
| 23 | } |
| 24 | |
| 25 | if [ "$#" -ne "2" ]; then |
| 26 | usage |
| 27 | fi |
| 28 | |
| 29 | GNUTLS_BUILD_DIR=$1 |
| 30 | GNUTLS_INSTALL_DIR=$2 |
| 31 | |
| 32 | source codebuild/bin/jobs.sh |
| 33 | |
| 34 | # libgmp is needed for libnettle |
| 35 | case "$DISTRO" in |
| 36 | "ubuntu") |
| 37 | sudo apt-get -qq install libgmp3-dev -y |
| 38 | ;; |
| 39 | "amazon linux") |
| 40 | sudo yum install -y gmp-devel |
| 41 | ;; |
| 42 | "darwin" ) |
| 43 | # Installing an existing package is a "failure" in brew |
| 44 | brew install gmp || true |
| 45 | ;; |
| 46 | *) |
| 47 | echo "Invalid platform! $OS_NAME" |
| 48 | usage |
| 49 | ;; |
| 50 | esac |
| 51 | |
| 52 | cd "$GNUTLS_BUILD_DIR" |
| 53 | |
| 54 | # Originally from: https://ftp.gnu.org/gnu/nettle/ |
| 55 | curl --retry 3 https://s3-us-west-2.amazonaws.com/s2n-public-test-dependencies/2021-01-04_nettle-3.7.tar.gz --output nettle-3.7.tar.gz |
| 56 | tar -xzf nettle-3.7.tar.gz |
| 57 | cd nettle-3.7 |
| 58 | ./configure --prefix="$GNUTLS_INSTALL_DIR"/nettle \ |
| 59 | --disable-openssl \ |
| 60 | --enable-shared |
| 61 | make -j $JOBS |
| 62 | make -j $JOBS install |
| 63 | cd .. |
| 64 | |
| 65 | # Install GnuTLS |
| 66 | # Originally from: https://www.gnupg.org/ftp/gcrypt/gnutls/v3.7/ |
| 67 | curl --retry 3 https://s3-us-west-2.amazonaws.com/s2n-public-test-dependencies/2022-01-18_gnutls-3.7.3.tar.xz --output gnutls-3.7.3.tar.xz |
| 68 | tar -xJf gnutls-3.7.3.tar.xz |
| 69 | cd gnutls-3.7.3 |
| 70 | PKG_CONFIG_PATH="$GNUTLS_INSTALL_DIR"/nettle/lib/pkgconfig:$PKG_CONFIG_PATH \ |
| 71 | ./configure --prefix="$GNUTLS_INSTALL_DIR" \ |
| 72 | --without-p11-kit \ |
| 73 | --with-included-libtasn1 \ |
| 74 | --with-included-unistring |
| 75 | make -j $JOBS |
| 76 | make -j $JOBS install |