-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathsetup-initial-patch.sh
executable file
·53 lines (42 loc) · 1.11 KB
/
setup-initial-patch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -ex
ROOT=$(pwd)
# Function to clean things up if any portion of the script fails.
function cleanup() {
# shellcheck disable=SC2181
if [ "0" != "${?}" ]; then
cd "${ROOT}"
git reset go
rm -rf go
fi
}
trap cleanup EXIT
function usage() {
echo "Sets up new Go version for FIPS support. If you provide the flag -r you can specify a replacement for the openssl-fips backend."
}
replacement=""
while getopts "r:" o; do
case "${o}" in
r)
replacement=${OPTARG}
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
./scripts/setup-go-submodule.sh "${1}"
# Enter the submodule directory.
cd ./go
ORIGINAL_GIT_SHA=$(git rev-parse HEAD)
echo $replacement
# Build the Go toolchain before applying patches. This allows us to use this toolchain in later steps
# when running `go mod` commands.
pushd ./src
./make.bash
popd
"${ROOT}"/scripts/apply-initial-patch.sh
"${ROOT}"/scripts/create-secondary-patch.sh "${replacement}"
# Clean things up again after we've generated the patch.
git reset --hard "${ORIGINAL_GIT_SHA}"