Skip to content

Commit 5479708

Browse files
dougchlrstewartgoatgoose
authored
chore(ci): make the awslc fips install script version aware (#5100)
Co-authored-by: Lindsay Stewart <[email protected]> Co-authored-by: Sam Clark <[email protected]>
1 parent 161deb1 commit 5479708

File tree

3 files changed

+95
-45
lines changed

3 files changed

+95
-45
lines changed

codebuild/bin/install_awslc_fips.sh

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env bash
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
set -eu
5+
6+
usage() {
7+
echo "install_awslc_fips.sh build_dir install_dir version"
8+
exit 1
9+
}
10+
11+
check_dep(){
12+
if [[ ! -f "$(which $1)" ]]; then
13+
echo "Could not find $1"
14+
exit 1
15+
fi
16+
}
17+
18+
clone(){
19+
git clone https://github.com/awslabs/aws-lc.git --branch "$AWSLC_BRANCH" --depth 1 $BUILD_DIR
20+
cd "$BUILD_DIR"
21+
}
22+
23+
build() {
24+
echo "Building with shared library=$1"
25+
cmake $BUILD_DIR \
26+
-Bbuild \
27+
-GNinja \
28+
-DBUILD_SHARED_LIBS=$1 \
29+
-DCMAKE_BUILD_TYPE=relwithdebinfo \
30+
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
31+
-DCMAKE_C_COMPILER=$(which clang) \
32+
-DCMAKE_CXX_COMPILER=$(which clang++) \
33+
-DFIPS="true"
34+
ninja -j "$(nproc)" -C build install
35+
ninja -C build clean
36+
}
37+
38+
# main
39+
if [ "$#" -ne "3" ]; then
40+
usage
41+
fi
42+
43+
# Ensure tooling is available
44+
check_dep clang
45+
check_dep ninja
46+
check_dep go
47+
48+
BUILD_DIR=$1
49+
INSTALL_DIR=$2
50+
VERSION=$3
51+
52+
# Map version to a specific feature branch/tag.
53+
case $VERSION in
54+
"2022")
55+
AWSLC_BRANCH=AWS-LC-FIPS-2.0.17
56+
;;
57+
"2024")
58+
AWSLC_BRANCH=AWS-LC-FIPS-3.0.0
59+
;;
60+
*)
61+
echo "Unknown version: $VERSION"
62+
usage
63+
;;
64+
esac
65+
66+
clone
67+
# Static lib
68+
build false
69+
# Shared lib
70+
build true
71+
72+
rm -rf $BUILD_DIR
73+
+4-45
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,7 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
# 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-
3+
# SPDX-License-Identifier: Apache-2.0
154
set -eu
16-
pushd "$(pwd)"
175

186
usage() {
197
echo "install_awslc_fips_2022.sh build_dir install_dir"
@@ -24,38 +12,9 @@ if [ "$#" -ne "2" ]; then
2412
usage
2513
fi
2614

15+
CBPATH=$(dirname $0)
2716
BUILD_DIR=$1
2817
INSTALL_DIR=$2
2918

30-
if [[ ! -f "$(which clang)" ]]; then
31-
echo "Could not find clang"
32-
exit 1
33-
fi
34-
35-
AWSLC_VERSION=AWS-LC-FIPS-2.0.17
36-
37-
mkdir -p "$BUILD_DIR" || true
38-
cd "$BUILD_DIR"
39-
# --branch can also take tags and detaches the HEAD at that commit in the resulting repository
40-
# --depth 1 Create a shallow clone with a history truncated to 1 commit
41-
git clone https://github.com/awslabs/aws-lc.git --branch "$AWSLC_VERSION" --depth 1
42-
43-
build() {
44-
shared=$1
45-
cmake . \
46-
-Bbuild \
47-
-GNinja \
48-
-DBUILD_SHARED_LIBS="${shared}" \
49-
-DCMAKE_BUILD_TYPE=relwithdebinfo \
50-
-DCMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
51-
-DCMAKE_C_COMPILER=$(which clang) \
52-
-DCMAKE_CXX_COMPILER=$(which clang++) \
53-
-DFIPS=1
54-
ninja -j "$(nproc)" -C build install
55-
ninja -C build clean
56-
}
57-
58-
build 0
59-
build 1
19+
$CBPATH/install_awslc_fips.sh $@ 2022
6020

61-
exit 0
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
# SPDX-License-Identifier: Apache-2.0
4+
set -eu
5+
6+
usage() {
7+
echo "install_awslc_fips_2024.sh build_dir install_dir"
8+
exit 1
9+
}
10+
11+
if [ "$#" -ne "2" ]; then
12+
usage
13+
fi
14+
15+
CBPATH=$(dirname $0)
16+
17+
$CBPATH/install_awslc_fips.sh $@ 2024
18+

0 commit comments

Comments
 (0)