34
34
# in the docker container.
35
35
#
36
36
# Usage:
37
- # ./build_and_launch_docker.sh [ [ -d | --code-dir dir ] [ -t | --reproduce-type type ] | [ -i | --sdk-installer installer ] | [ -s | --sgx-src-dir src_dir ] [ - h | --help ] ]
37
+ # ./build_and_launch_docker.sh [ [ -d | --code-dir dir ] [ -t | --reproduce-type type ] | [ -h | --help ] ]
38
38
#
39
39
# Options:
40
40
# -d, --code-dir:
48
48
# If no type is provided, all the code will be prepared. And the build steps will
49
49
# be triggered in the container. Then you can choose to build what you want in the container.
50
50
#
51
- # -i, --sdk-installer:
52
- # Specify the SDK installer used for AE reproducibility. If this option is not specified,
53
- # script will download the default SDK installer.
54
- #
55
- # -s, --sgx-src-dir:
56
- # Specify the local sgx source path if you have pulled the sgx source code via `$git clone`
57
- # or by other ways.
58
- # If this option is specified, script will not clone sgx source but start the build based on
59
- # the code base specified by this option.
60
- #
61
51
# -h, --help:
62
- # Show this usage message.
63
- #
52
+ # Show this usage message.#
64
53
#
65
54
66
55
set -e
@@ -73,41 +62,23 @@ type="all"
73
62
type_flag=0
74
63
mount_dir=" /linux-sgx"
75
64
76
- sdk_installer=" "
77
- sgx_src=" "
78
-
79
- default_sdk_installer=sgx_linux_x64_sdk_reproducible_2.11.100.1.bin
80
- default_sdk_installer_url=https://download.01.org/intel-sgx/sgx-linux/2.11/distro/nix_reproducibility/$default_sdk_installer
81
-
82
-
83
65
usage ()
84
66
{
85
67
echo "
86
68
The script is to automatically prepare the reproducible code, build docker image and launch the build
87
69
in the docker container.
88
-
89
70
Usage:
90
- $0 [ [ -d | --code-dir dir ] [ -t | --reproduce-type type ] | [ -i | --sdk-installer installer ] | [ -s | --sgx-src-dir src_dir ] [ -h | --help ] ]
91
-
71
+ $0 [ [ -d | --code-dir dir ] [ -t | --reproduce-type type ] | [ -h | --help ] ]
92
72
Options:
93
73
-d, --code-dir:
94
- Specify the directory you want to prepare the code and share to the reproducible container.
95
- If this option is not specified, will use the same directory as the script location.
74
+ Specify the directory you want to download the repo. If this option is
75
+ not specified, will use the same directory as the script location.
96
76
-t, --reproduce-type:
97
77
Specify the reproducibility type. Provided options: all|sdk|ae|ipp|binutils.
98
78
If one type is provided, the corresponding code will be prepared. And the correponding
99
79
build steps will also be executed in the container automatically.
100
80
If no type is provided, all the code will be prepared. And the build steps will not
101
81
be triggered in the container. Then you can choose to build what you want in the container.
102
- -i, --sdk-installer:
103
- Specify the SDK installer used for AE reproducibility.
104
- If this option is not provided, script will choose the default SDK installer to build AEs.
105
- Only valid when the reproduce type is 'ae'.
106
- -s, --sgx-src-dir:
107
- Specify the local sgx source path if you have pulled the sgx source code via \`\$ git clone\`
108
- or by other ways.
109
- If this option is specified, script will not clone sgx source but start the build based on
110
- the code base specified by this option.
111
82
-h, --help:
112
83
Show this usage message."
113
84
}
@@ -131,35 +102,12 @@ parse_cmd()
131
102
usage
132
103
exit
133
104
;;
134
- -i | --sdk-installer ) shift
135
- sdk_installer=" $1 "
136
- if [ ! -f " $sdk_installer " ]; then
137
- echo " The $sdk_installer doesn't exist."
138
- usage
139
- exit 1
140
- fi
141
- sdk_installer=" $( realpath $sdk_installer ) "
142
- ;;
143
- -s | --sgx-src-dir) shift
144
- sgx_src=" $1 "
145
- if [ ! -d " $sgx_src " ]; then
146
- echo " The $sgx_src doesn't exist."
147
- usage
148
- exit 1
149
- fi
150
- sgx_src=" $( realpath $sgx_src ) "
151
- ;;
152
105
* )
153
106
usage
154
107
exit 1
155
108
esac
156
109
shift
157
110
done
158
- if [ " $type " != " ae" ] && [ $type_flag == 1 ] && [ " $sdk_installer " != " " ]; then
159
- echo -e " \n ERROR: Option '--sdk-installer' is valid only if '--reproduce-type' is 'ae'."
160
- usage
161
- exit 1
162
- fi
163
111
mkdir -p " $code_dir " | exit
164
112
code_dir=" $( realpath $code_dir ) "
165
113
sgx_repo=" $code_dir /sgx"
@@ -168,29 +116,44 @@ parse_cmd()
168
116
169
117
prepare_sgx_src ()
170
118
{
171
- pushd .
172
119
if [ -d $sgx_repo ]; then
173
120
echo " Removing existing SGX code repo in $sgx_repo "
174
121
rm -rf $sgx_repo
175
122
fi
176
123
177
- # If user prepares the sgx code repo in the host machine, copy the code to $sgx_repo
178
- # Otherwise, pull the sgx source code.
179
- if [ " $sgx_src " != " " ]; then
180
- mkdir -p " $sgx_repo " && cp -a " $sgx_src /." " $sgx_repo "
181
- else
182
- git clone -b sgx_2.11_reproducible https://github.com/intel/linux-sgx.git $sgx_repo
183
- fi
124
+ git clone -b sgx_2.10_reproducible https://github.com/intel/linux-sgx.git $sgx_repo
125
+ cd $sgx_repo && ./download_prebuilt.sh && cd -
126
+ }
184
127
185
- cd " $sgx_repo " && make preparation
186
- popd
128
+ prepare_dcap_src ()
129
+ {
130
+ if [ ! -f $sgx_repo /Makefile ]; then
131
+ echo " Please download the source repo firstly."
132
+ exit -1
133
+ fi
134
+ cd ${sgx_repo} && make dcap_source && cd -
135
+ $sgx_repo /external/dcap_source/QuoteVerification/prepare_sgxssl.sh nobuild
136
+ }
187
137
138
+ prepare_openmp_src ()
139
+ {
140
+ openmp_dir=" $sgx_repo /external/openmp/"
141
+ if [ ! -d $openmp_dir /openmp_code/final ]; then
142
+ cd $openmp_dir && git submodule update -f --init --recursive -- openmp_code && cd -
143
+ fi
144
+ if [ ! -f $openmp_dir /openmp_code/final/runtime/src/sgx_stub.h ]; then
145
+ cd $openmp_dir /openmp_code && git apply ../0001-Enable-OpenMP-in-SGX.patch && cd -
146
+ fi
188
147
}
189
148
190
149
prepare_ipp_src ()
191
150
{
192
151
pushd .
193
152
ipp_dir=" $sgx_repo /external/ippcp_internal"
153
+ if [ -z " $( ls -A $ipp_dir /ipp-crypto) " ]; then
154
+ cd $ipp_dir && git submodule update -f --init --recursive -- ipp-crypto
155
+ fi
156
+
194
157
patch_log=" $( cd $ipp_dir /ipp-crypto && git log --oneline --grep=' Add mitigation support to assembly code' | cut -d' ' -f 3) "
195
158
196
159
if [ " $patch_log " != " mitigation" ]; then
@@ -215,25 +178,19 @@ prepare_binutils_src()
215
178
prepare_sdk_installer ()
216
179
{
217
180
# Used for 'ae' type repreducibility.
218
- # If user prepares the sdk installer, we copy it to the right place
219
- # Otherwise, we download one from 01.org
220
- if [ " $sdk_installer " != " " ]; then
221
- chmod +x " $sdk_installer " && cp " $sdk_installer " " $code_dir "
222
- else
223
- cd $code_dir && wget $default_sdk_installer_url && chmod +x $default_sdk_installer && cd -
224
- fi
181
+ sdk_installer=sgx_linux_x64_sdk_reproducible_2.10.100.1.bin
182
+ sdk_url=https://download.01.org/intel-sgx/sgx-linux/2.10/distro/nix_reproducibility/$sdk_installer
183
+ cd $code_dir && wget $sdk_url && chmod +x $sdk_installer && cd -
225
184
}
226
185
227
186
generate_cmd_script ()
228
187
{
229
- rm -f $code_dir /cmd.sh
188
+ rm -rf $code_dir /cmd.sh
230
189
231
190
cat > $code_dir /cmd.sh << EOF
232
191
#!/usr/bin/env bash
233
-
234
192
. ~/.bash_profile
235
193
nix-shell ~/shell.nix --run "$mount_dir /start_build.sh $type "
236
-
237
194
EOF
238
195
239
196
chmod +x $code_dir /cmd.sh
@@ -251,13 +208,18 @@ case $type in
251
208
" all" )
252
209
prepare_binutils_src
253
210
prepare_sgx_src
211
+ prepare_dcap_src
212
+ prepare_openmp_src
254
213
prepare_ipp_src
255
214
;;
256
215
" sdk" )
257
216
prepare_sgx_src
217
+ prepare_dcap_src
218
+ prepare_openmp_src
258
219
;;
259
220
" ae" )
260
221
prepare_sgx_src
222
+ prepare_dcap_src
261
223
prepare_sdk_installer
262
224
;;
263
225
" ipp" )
289
251
docker run -v $code_dir :$mount_dir -it --network none --rm sgx.build.env /bin/bash -c $mount_dir /cmd.sh
290
252
fi
291
253
292
-
293
-
0 commit comments