generated from ThalesGroup/template-project
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·170 lines (155 loc) · 4.8 KB
/
build.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
##############################################################################
#
# This file is part of the "Luna OpenSSL for PQC" project.
#
# The " Luna OpenSSL for PQC " project is provided under the MIT license (see the
# following Web site for further details: https://mit-license.org/ ).
#
# Copyright © 2024 Thales Group
#
##############################################################################
#
# Description:
#
# script to build luna provider from coverity analysis
#
# dependencies (openssl, liboqs) are not subject to coverity analysis here
#
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo
echo "Usage:"
echo " $0 SA64client clean all"
echo " $0 SA64client build all"
echo
echo " Alternatives to option all:"
echo " provider|sautil|engineperf"
echo
echo " Legacy alternatives to option all:"
echo " engine"
echo
echo " Dependencies (openssl, liboqs) you want to build just once:"
echo " depends"
echo
exit 1
fi
product="$1"
goal="$2"
target="$3"
if [ -n "$4" ]; then
build_type="BLDTYPE=$4"
fi
# Use build_type=ci to skip the slow process of signing the jar files if you don't need signed jars
# Before running this script, create SA64.env and SA64client.env files containing all the required
# build environmnet variables such as OpenSSL and kernel versions. etc.
#
#Sample SA64.env file:
#
if [ ! -s "SA64.env" ]; then
cat << EOF > SA64.env
#Environment variables to build SA64 appliance
export PRODUCT=SA64
export ROOT_DIR=\$PWD/artifacts/\$product
export BLDDIR=\$ROOT_DIR/output
export PKG_EXPORT_DIR=\$ROOT_DIR/packages
export PRODUCT_PKG_DIR=\$ROOT_DIR/personalization-packages
export OPEN_SOURCE_DIR=\$PWD/../Open-Source
export VERSION=7.8.3
export RELEASE=2
export DEBUG=0
export openssl_VERSION=1.1.1q
export KERNEL_VERSION=3.10.0-1160.81.1.el7.x86_64
EOF
echo "Added the build environment varibales to a new SA64.env file. You can update it as you wish."
fi
# Sample SA64client.env file:
if [ ! -s "SA64client.env" ]; then
cat << EOF > SA64client.env
#Environment varibales to build SA64client
export PRODUCT=SA64client
export ROOT_DIR=\$PWD/artifacts/\$product
export BLDDIR=\$ROOT_DIR/output
export PKG_EXPORT_DIR=\$ROOT_DIR/packages/
export VERSION=7.8.3
export RELEASE=2
export OPEN_SOURCE_DIR=\$PWD/../Open-Source
export DEBUG=0
export openssl_VERSION=1.1.1q
export KERNEL_VERSION=3.10.0-1160.83.1.el7.x86_64
export JAR_SIGNING_STATION=nobody@localhost
export WIN_SIGNING_STATION=nobody@localhost
export JDK=\$JAVA_HOME
export JAVA_HOME=\$JAVA_HOME
export ANT_HOME=\$ANT_HOME
EOF
echo "Added the build environment variables to a new SA64client.env file. You can update it as you wish."
fi
if [ -s "./$product.env" ]; then
echo source "./$product.env"
file "./$product.env"
source "./$product.env"
else
echo "Please add all the required environment variables to the $product.env file, or export them before running this script."
echo
fi
if [ -z "$BLDDIR" ]; then
echo "Error! BLDDIR environment variable is not defined. Please set it in the $product.env file and try again."
echo "Usage: $0 SA64|SA64client clean|build|pkg target"
exit 1
fi
if [ -z "$PKG_EXPORT_DIR" ]; then
echo "Error! PKG_EXPORT_DIR environment variable is not defined. Please set it in the $product.env file and try again."
echo "Usage: $0 SA64|SA64client clean|build|pkg target"
exit 1
fi
echo "Building $product $BLDDIR $PKG_EXPORT_DIR"
mkdir -p "$BLDDIR" || exit 1
mkdir -p "$PKG_EXPORT_DIR" || exit 1
# build luna client
#make -j 1 $build_type PRODUCT="$product" GOAL="$goal" "$target"
# build all (not including dependencies {openssl,liboqs})
false
if [ "$goal" = "build" ]; then
# provider
if [ "$target" = "provider" -o "$target" = "all" ]; then
./gembuild provider-build
fi
# engine is a subset of provider, hence not a part of all
if [ "$target" = "engine" ]; then
./gembuild engine-build
fi
# sautil
if [ "$target" = "sautil" -o "$target" = "all" ]; then
./gembuild sautil-build
fi
# engineperf
if [ "$target" = "engineperf" -o "$target" = "all" ]; then
./gembuild engineperf-build
fi
# depends
if [ "$target" = "depends" ]; then
./generate.sh
fi
fi
# clean all
if [ "$goal" = "clean" ]; then
if [ "$target" = "provider" -o "$target" = "all" ]; then
make -C lunaProvider clean
fi
if [ "$target" = "engine" -o "$target" = "all" ]; then
make -C engine clean
fi
if [ "$target" = "sautil" -o "$target" = "all" ]; then
make -C gem-samples/sautil clean
fi
if [ "$target" = "engineperf" -o "$target" = "all" ]; then
make -C gem-samples/engineperf clean
fi
fi
rc=$?
echo "Build done for PRODUCT=$product GOAL=$goal $target $build_type"
if [ "$rc" -ne 0 ]; then
echo "Build failed with error code: $rc"
fi
exit $rc
#eof