Polish gRPC and remote attestation demos

1. Disable zlib _explictly_ when building libcurl in remote attestaion demo.
The reason for this is that zlib may be implictly linked by the build system of
libcurl but not the zlib library is not copied into the Occlum FS image.
2. Use `make -j$(nproc)`
3. Fix typos
This commit is contained in:
He Sun 2019-12-16 16:18:49 +08:00 committed by Tate, Hongliang Tian
parent 0f08fbf962
commit 6d7597c25e
8 changed files with 45 additions and 44 deletions

@ -1,6 +1,7 @@
#!/bin/sh
install_dir=/usr/local/occlum/x86_64-linux-musl/
export PATH=$PATH:$install_dir/bin
INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl/
GRPC_SRC_DIR=$PWD/grpc
export PATH=$PATH:$INSTALL_DIR/bin
git clone https://github.com/grpc/grpc.git
cd grpc
@ -12,54 +13,52 @@ then
fi
# Install c-ares
cd third_party/cares/cares
cd $GRPC_SRC_DIR/third_party/cares/cares
git submodule update --init .
git checkout tags/cares-1_15_0
mkdir -p build
cd build
cmake ../ \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \
-DCMAKE_INSTALL_PREFIX=$install_dir
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
if [ $? -ne 0 ]
then
echo "cares cmake failed"
exit 1
fi
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "cares make failed"
exit 1
fi
make install
cd ../../../..
# Install zlib
cd third_party/zlib
cd $GRPC_SRC_DIR/third_party/zlib
git submodule update --init .
git checkout tags/v1.2.11
mkdir -p build
cd build
cmake ../ \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \
-DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_INSTALL_PREFIX=$install_dir \
-DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE
if [ $? -ne 0 ]
then
echo "zlib cmake failed"
exit 1
fi
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "zlib make failed"
exit 1
fi
make install
cd ../../..
# Install protobuf
cd third_party/protobuf
cd $GRPC_SRC_DIR/third_party/protobuf
git submodule update --init .
git checkout tags/v3.10.0
cd cmake
@ -68,7 +67,7 @@ cd build
cmake ../ \
-Dprotobuf_BUILD_TESTS=OFF -DBUILD_SHARED_LIBS=TRUE \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \
-DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_INSTALL_PREFIX=$install_dir \
-DCMAKE_CXX_COMPILER=occlum-g++ -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE
if [ $? -ne 0 ]
@ -77,27 +76,26 @@ then
exit 1
fi
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "protobuf make failed"
exit 1
fi
make install
cd ../../../..
cp $install_dir/bin/protoc /usr/bin
cp $INSTALL_DIR/bin/protoc /usr/bin
# Install gRPC
cd cmake
cd $GRPC_SRC_DIR/cmake
mkdir -p build
cd build
cmake ../.. \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=occlum-gcc \
-DCMAKE_CXX_COMPILER=occlum-g++ -DgRPC_INSTALL=ON -DgRPC_PROTOBUF_PROVIDER=package \
-DgRPC_ZLIB_PROVIDER=package -DgRPC_CARES_PROVIDER=package \
-DgRPC_SSL_PROVIDER=package -DCMAKE_PREFIX_PATH=$install_dir \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCMAKE_INSTALL_PREFIX=$install_dir
-DgRPC_SSL_PROVIDER=package -DCMAKE_PREFIX_PATH=$INSTALL_DIR \
-DCMAKE_NO_SYSTEM_FROM_IMPORTED=TRUE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
if [ $? -ne 0 ]
then
@ -105,7 +103,7 @@ then
exit 1
fi
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "grpc make failed"

@ -14,7 +14,7 @@ then
echo "./config command failed."
exit 1
fi
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "make command failed."

@ -1,15 +1,17 @@
#!/bin/sh
DEMO_DIR=$PWD
cd grpc/examples/cpp/helloworld
git apply ../../../../Makefile.patch
cd $DEMO_DIR/grpc/examples/cpp/helloworld
git apply $DEMO_DIR/Makefile.patch
if [ $? -ne 0 ]
then
echo "patch failed"
exit 1
fi
cp ../../protos/helloworld.proto .
cd ../../../../
cp $DEMO_DIR/grpc/examples/protos/helloworld.proto .
cd $DEMO_DIR
mkdir -p client
mkdir -p server

@ -1,12 +1,12 @@
#!/bin/sh
install_dir=/usr/local/occlum/x86_64-linux-musl
INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$install_dir/bin
export PATH=$PATH:$INSTALL_DIR/bin
cd client
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "demo make failed"

@ -1,11 +1,11 @@
#!/bin/bash
install_dir=/usr/local/occlum/x86_64-linux-musl
INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$install_dir/bin
export PATH=$PATH:$INSTALL_DIR/bin
cd client
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "demo make failed"
@ -26,9 +26,9 @@ fi
mkdir -p image/etc
cp /etc/resolv.conf image/etc
cp ../greeter_client image/bin
cp $install_dir/lib/libprotobuf.so.3.10.0.0 image/lib
cp $install_dir/lib/libcares.so.2 image/lib
cp $install_dir/lib/libz.so.1 image/lib
cp $INSTALL_DIR/lib/libprotobuf.so.3.10.0.0 image/lib
cp $INSTALL_DIR/lib/libcares.so.2 image/lib
cp $INSTALL_DIR/lib/libz.so.1 image/lib
if [ $? -ne 0 ]
then
echo "libraries copied failed"

@ -1,12 +1,12 @@
#!/bin/sh
install_dir=/usr/local/occlum/x86_64-linux-musl
INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$install_dir/bin
export PATH=$PATH:$INSTALL_DIR/bin
cd server
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "demo make failed"

@ -1,10 +1,10 @@
#!/bin/bash
install_dir=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$install_dir/bin
INSTALL_DIR=/usr/local/occlum/x86_64-linux-musl
export PATH=$PATH:$INSTALL_DIR/bin
cd server
make -j8
make -j$(nproc)
if [ $? -ne 0 ]
then
echo "demo make failed"
@ -25,9 +25,9 @@ fi
mkdir -p image/etc
cp /etc/resolv.conf image/etc
cp ../greeter_server image/bin
cp $install_dir/lib/libprotobuf.so.3.10.0.0 image/lib
cp $install_dir/lib/libcares.so.2 image/lib
cp $install_dir/lib/libz.so.1 image/lib
cp $INSTALL_DIR/lib/libprotobuf.so.3.10.0.0 image/lib
cp $INSTALL_DIR/lib/libcares.so.2 image/lib
cp $INSTALL_DIR/lib/libz.so.1 image/lib
if [ $? -ne 0 ]
then
echo "libraries copied failed"

@ -32,7 +32,7 @@ if [ ! -d "$CURLDIR" ] ; then
mv curl-curl-7_29_0 curl && \
echo "Download curl successfully" || exit 1
else
echo "The openssl code is already existent"
echo "The curl code is already existent"
fi
# Download other dependencies
@ -88,7 +88,8 @@ if [ ! -f "$INSTALLDIR/lib/libcurl.so" ] ; then
echo "Building curl ..."
CC=occlum-gcc CXX=occlum-g++ ./configure \
--prefix=$INSTALLDIR \
--with-ssl=$INSTALLDIR && \
--with-ssl=$INSTALLDIR \
--without-zlib && \
make -j${nproc} && \
sudo make install && \
echo "Build curl successfully" || exit 1