Debian Codegraph @

crt/s2n/codebuild/bin/install_al_dependencies.sh

raw symbols SCIP
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 set -eu
17 source ./codebuild/bin/s2n_setup_env.sh
18
19 al2023_main(){
20 case "$S2N_LIBCRYPTO" in
21 "default") echo "Using default system libcrypto";;
22 *) echo "${S2N_LIBCRYPTO} is not installed on this platform."; exit 1;;
23 esac
24 common_packages
25 al2023_packages
26 versions
27 }
28
29 al2_main() {
30 echo "Installing AL2 packages"
31 common_packages
32 al2_packages
33 symlink_all_the_things
34
35 case "$S2N_LIBCRYPTO" in
36 "openssl-1.1.1")
37 yum erase -y openssl-devel || true
38 yum install -y openssl11-static openssl11-libs openssl11-devel
39 ;;
40 "default") echo "Using default system libcrypto";;
41 *) echo "Unknown libcrypto: ${S2N_LIBCRYPTO}"; exit 1;;
42 esac
43 versions
44 }
45
46 common_packages(){
47 # Borrowed from https://github.com/aws/aws-codebuild-docker-images/blob/master/al2/x86_64/standard/5.0/Dockerfile#L24
48 mono
49 yum groupinstall -y "Development tools"
50 yum install -y clang git cmake3 iproute net-tools nettle-devel nettle which sudo psmisc
51 yum install -y python3-pip tcpdump unzip zlib-devel libtool ninja-build valgrind wget
52 rm /etc/yum.repos.d/mono-centos7-stable.repo
53 }
54
55 al2023_packages(){
56 # Openssl 3.0 headers and go
57 yum install -y openssl-devel golang
58 # TODO: cmake isn't finding awslc https://github.com/aws/s2n-tls/issues/4633
59 #./codebuild/bin/install_awslc.sh $(mktemp -d) /usr/local/awsc 0
60 }
61
62 al2_packages() {
63 # Latest AL2 image had dependency issues related to NodeJS.
64 # We don't use NodeJS, so just remove it.
65 yum erase -y nodejs || true
66 yum update -y
67 yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm || true
68 yum install amazon-linux-extras
69
70 # Who owns this package? It needs updating to not install modules under python2.7
71 PYTHON=$(which python2) amazon-linux-extras install -y ruby2.6 rust1 python3.8
72 PYTHON=$(which python2) amazon-linux-extras enable epel
73 PYTHON=$(which python2) amazon-linux-extras enable corretto8
74 yum install -y openssh-clients
75 }
76
77 mono() {
78 rpm --import https://download.mono-project.com/repo/xamarin.gpg
79 curl https://download.mono-project.com/repo/centos7-stable.repo | tee /etc/yum.repos.d/mono-centos7-stable.repo
80 }
81
82 symlink_all_the_things() {
83 # Package owners should be doing this.
84 # Note the version number at the end allows for upgrades to supersede these.
85 update-alternatives --install /usr/bin/pip pip3 /usr/bin/pip3 300
86 update-alternatives --install /usr/bin/ninja ninja /usr/bin/ninja-build 170
87 update-alternatives --install /usr/bin/cmake cmake /usr/bin/cmake3 313
88 update-alternatives --install /usr/bin/gcc-7 gcc /usr/bin/gcc 700
89 update-alternatives --install /usr/bin/g++-7 g++ /usr/bin/g++ 700
90 update-alternatives --install /usr/bin/g++-7 g++ /usr/bin/g++ 700
91 }
92
93 versions(){
94 gcc --version
95 cmake --version
96 python3 --version
97 }
98
99 if [[ ${DISTRO} != "amazon linux" ]]; then
100 echo "Target Amazon Linux, but running on $DISTRO: Nothing to do."
101 exit 0;
102 else
103 if [[ ${VERSION_ID} == '2' ]]; then
104 al2_main;
105 elif [[ ${VERSION_ID} == '2023' ]]; then
106 al2023_main;
107 fi
108 fi