Skip to content

Commit 74b24b6

Browse files
authored
Replace the reproducible script and README with 2.10 reproducible branch. (#618)
Signed-off-by: Zhang Lili Z <[email protected]>
1 parent 33f4499 commit 74b24b6

File tree

2 files changed

+47
-93
lines changed

2 files changed

+47
-93
lines changed

linux/reproducibility/README.md

+8-14
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,21 @@ In order to reproduce the enclave build, there are three requirements:1. stable
3131
```
3232
$ ./build_and_launch_docker.sh
3333
```
34-
c) Below command triggers the reproducible build for 'ae' using a specified reproducible SGX SDK installer and code repo. Of course, you need to prepare the SGX SDK installer and SGX source repo beforehand.
35-
```
36-
$ ./build_and_launch_docker.sh --reproduce-type ae --code-dir ~/code_dir --sdk-installer {prepared_sdk_installer} --sgx-src-dir {prepared_sgx_src}
37-
```
3834
3935
4036
**Note**:
4137
To reproduce QVE, you need to apply below patch to the [build_and_launch_docker.sh](./build_and_launch_docker.sh) before start the reproducible build with the script.
4238
```
4339
diff --git a/linux/reproducibility/build_and_launch_docker.sh b/linux/reproducibility/build_and_launch_docker.sh
44-
index b85eda85..f8bc6812 100755
40+
index c43c76af..bb49b48b 100755
4541
--- a/linux/reproducibility/build_and_launch_docker.sh
4642
+++ b/linux/reproducibility/build_and_launch_docker.sh
47-
@@ -188,6 +188,7 @@ prepare_sgx_src()
43+
@@ -136,6 +136,7 @@ prepare_dcap_src()
44+
exit -1
4845
fi
49-
50-
cd "$sgx_repo" && make preparation
51-
+ mkdir dcap-trunk/ && mv external/dcap_source/ dcap-trunk/ && ln -sfr dcap-trunk/dcap_source external/dcap_source
52-
popd
53-
54-
}
46+
cd ${sgx_repo} && make dcap_source && cd -
47+
+ cd $sgx_repo && mkdir dcap-trunk/ && mv external/dcap_source/ dcap-trunk/ && ln -sfr dcap-trunk/dcap_source external/dcap_source && cd -
48+
$sgx_repo/external/dcap_source/QuoteVerification/prepare_sgxssl.sh nobuild
49+
}
5550
```
56-
57-
51+

linux/reproducibility/build_and_launch_docker.sh

+39-79
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# in the docker container.
3535
#
3636
# 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 ] ]
3838
#
3939
# Options:
4040
# -d, --code-dir:
@@ -48,19 +48,8 @@
4848
# If no type is provided, all the code will be prepared. And the build steps will
4949
# be triggered in the container. Then you can choose to build what you want in the container.
5050
#
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-
#
6151
# -h, --help:
62-
# Show this usage message.
63-
#
52+
# Show this usage message.#
6453
#
6554

6655
set -e
@@ -73,41 +62,23 @@ type="all"
7362
type_flag=0
7463
mount_dir="/linux-sgx"
7564

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-
8365
usage()
8466
{
8567
echo "
8668
The script is to automatically prepare the reproducible code, build docker image and launch the build
8769
in the docker container.
88-
8970
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 ] ]
9272
Options:
9373
-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.
9676
-t, --reproduce-type:
9777
Specify the reproducibility type. Provided options: all|sdk|ae|ipp|binutils.
9878
If one type is provided, the corresponding code will be prepared. And the correponding
9979
build steps will also be executed in the container automatically.
10080
If no type is provided, all the code will be prepared. And the build steps will not
10181
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.
11182
-h, --help:
11283
Show this usage message."
11384
}
@@ -131,35 +102,12 @@ parse_cmd()
131102
usage
132103
exit
133104
;;
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-
;;
152105
* )
153106
usage
154107
exit 1
155108
esac
156109
shift
157110
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
163111
mkdir -p "$code_dir" | exit
164112
code_dir="$(realpath $code_dir)"
165113
sgx_repo="$code_dir/sgx"
@@ -168,29 +116,44 @@ parse_cmd()
168116

169117
prepare_sgx_src()
170118
{
171-
pushd .
172119
if [ -d $sgx_repo ]; then
173120
echo "Removing existing SGX code repo in $sgx_repo"
174121
rm -rf $sgx_repo
175122
fi
176123

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+
}
184127

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+
}
187137

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
188147
}
189148

190149
prepare_ipp_src()
191150
{
192151
pushd .
193152
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+
194157
patch_log="$( cd $ipp_dir/ipp-crypto && git log --oneline --grep='Add mitigation support to assembly code' | cut -d' ' -f 3)"
195158

196159
if [ "$patch_log" != "mitigation" ]; then
@@ -215,25 +178,19 @@ prepare_binutils_src()
215178
prepare_sdk_installer()
216179
{
217180
# 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 -
225184
}
226185

227186
generate_cmd_script()
228187
{
229-
rm -f $code_dir/cmd.sh
188+
rm -rf $code_dir/cmd.sh
230189

231190
cat > $code_dir/cmd.sh << EOF
232191
#!/usr/bin/env bash
233-
234192
. ~/.bash_profile
235193
nix-shell ~/shell.nix --run "$mount_dir/start_build.sh $type"
236-
237194
EOF
238195

239196
chmod +x $code_dir/cmd.sh
@@ -251,13 +208,18 @@ case $type in
251208
"all")
252209
prepare_binutils_src
253210
prepare_sgx_src
211+
prepare_dcap_src
212+
prepare_openmp_src
254213
prepare_ipp_src
255214
;;
256215
"sdk")
257216
prepare_sgx_src
217+
prepare_dcap_src
218+
prepare_openmp_src
258219
;;
259220
"ae")
260221
prepare_sgx_src
222+
prepare_dcap_src
261223
prepare_sdk_installer
262224
;;
263225
"ipp")
@@ -289,5 +251,3 @@ else
289251
docker run -v $code_dir:$mount_dir -it --network none --rm sgx.build.env /bin/bash -c $mount_dir/cmd.sh
290252
fi
291253

292-
293-

0 commit comments

Comments
 (0)