aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@linaro.org>2021-10-10 18:40:34 +0800
committerFathi Boudra <fathi.boudra@linaro.org>2021-10-13 09:03:54 +0000
commit73371259137832377dacb4dd92851cbacfd88cdb (patch)
tree94e4d558cb43b35f960a8ed99bd5f717717a7287
parent3078abc79eff13235fb4f454865f549c42b87792 (diff)
uadk: enhance build scripts
Enhance build scripts to build new binaries and libraries. Since there're depencies among them. * Add to build OpenSSL. * Add to build openssl-uadk that is depended on OpenSSL. * Add the feature of package binaries and libraries with commit version. If a new building is triggered, the scripts should check whether there's a same prebuilt version. If it's founded, use the prebuilt one directly. Otherwise, trigger a new building and remove all prebuilt packages. * Since both UADK and openssl-uadk are monitored by CI, add a mutex lock to prevent them to compete accessing hardware. * Add to load UACCE kernel module. While UADK is configured as v1 or v2, the UACCE kernel module should be configured with different parameters. So the scripts should load kernel module by itself. * Add more checking on errors. * Change the way to configure UADK. Otherwise, it impacts the building process of openssl-uadk. * Both OpenSSL and openssl-uadk are build as dynamic libraries. UADK is built in both static library and dynamic library. * Only verify UADK v2. UADK v1 is only built without verifying. * The scripts could be shared between UADK and openssl-uadk repository. It could reduce the complexity of building process. Signed-off-by: Haojian Zhuang <haojian.zhuang@linaro.org> Change-Id: Ie9196fc84f2fbc0c0a1843745067050d8d76524c
-rwxr-xr-xuadk/builders.sh351
1 files changed, 328 insertions, 23 deletions
diff --git a/uadk/builders.sh b/uadk/builders.sh
index b45ff8a144..60fe4fef76 100755
--- a/uadk/builders.sh
+++ b/uadk/builders.sh
@@ -1,9 +1,314 @@
#!/bin/bash -e
+export UADK_VER_ENV="v2"
+LOCK_FILE="/var/lock/uadk-lock"
+BIN_DIR="usr/local/bin"
+INC_DIR="usr/local/include"
+LIB_DIR="usr/local/lib"
+
+lock() {
+ exit_code=1
+ pending=0
+ while [ "$exit_code" != 0 ]; do
+ exit_code=0
+ mkdir ${LOCK_FILE} &> /dev/null || exit_code=$?
+ #mkdir ${LOCK_FILE} || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ if [ "$pending" = 0 ]; then
+ # Some script is accessing hardware
+ echo "Wait for other building script finishing."
+ pending=1
+ fi
+ fi
+ done
+}
+
+unlock() {
+ if [ -d ${LOCK_FILE} ]; then
+ rmdir ${LOCK_FILE}
+ echo "Release lock"
+ fi
+}
+
+ctrlc_handler() {
+ echo "Ctrl-C caught...performing clean up"
+ unlock
+ # Exit with error code
+ exit 2
+}
+
+# Check whether prebuilt package exists.
+# If it exists, install binaries and libraries directly.
+check_prebuilt_package() {
+ exit_code=0
+ cd ${WORKSPACE}
+ case $1 in
+ "openssl")
+ if [ -d ${WORKSPACE}/openssl ]; then
+ cd ${WORKSPACE}/openssl
+ git checkout OpenSSL_1_1_1a || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ cd ${WORKSPACE}
+ rm -fr ${WORKSPACE}/openssl
+ git clone https://github.com/openssl/openssl.git
+ cd ${WORKSPACE}/openssl
+ fi
+ else
+ git clone https://github.com/openssl/openssl.git
+ cd ${WORKSPACE}/openssl
+ fi
+ git checkout OpenSSL_1_1_1a
+ COMMIT=`git log HEAD^..HEAD | grep commit`
+ NAME=`ls ../openssl-*.tar.xz`
+ NAME=${NAME#*openssl-}
+ ;;
+ "uadk")
+ # Always fetch latest code
+ rm -fr uadk
+ git clone --depth 1 https://github.com/Linaro/uadk.git
+ cd ${WORKSPACE}/uadk
+ # depth is 1
+ COMMIT=`git log | grep commit`
+ NAME=`ls ../uadk-*.tar.xz`
+ NAME=${NAME#*uadk-}
+ ;;
+ "ssluadk")
+ # Always fetch latest code
+ rm -fr openssl-uadk
+ git clone --depth 1 https://github.com/Linaro/openssl-uadk.git
+ cd ${WORKSPACE}/openssl-uadk
+ # depth is 1
+ COMMIT=`git log | grep commit`
+ NAME=`ls ../ssluadk-*.tar.xz`
+ NAME=${NAME#*ssluadk-}
+ ;;
+ *)
+ echo "Invalid package name: $1"
+ return 1
+ ;;
+ esac
+ NAME=`echo ${NAME} | cut -b 1-8`
+ if [ -z ${NAME} ]; then
+ echo "Can not find package ${NAME}."
+ return 1
+ fi
+ COMMIT=${COMMIT#*commit }
+ COMMIT=`echo ${COMMIT} | cut -b 1-8`
+ if [ ${NAME} = ${COMMIT} ]; then
+ echo "Prebuilt package ${NAME} is found."
+ cd ${WORKSPACE}
+ case $1 in
+ "openssl")
+ rm -fr ${WORKSPACE}/openssl
+ tar -xJf openssl-${NAME}.tar.xz
+ cd ${WORKSPACE}/openssl
+ make install &> /dev/null
+ ;;
+ "uadk")
+ rm -fr ${WORKSPACE}/uadk-shared-v2
+ rm -fr ${WORKSPACE}/uadk-static-v2
+ tar -xJf uadk-${NAME}.tar.xz
+ ;;
+ "ssluadk")
+ rm -fr ${WORKSPACE}/openssl-uadk
+ tar -xJf ssluadk-${NAME}.tar.xz
+ cd ${WORKSPACE}/openssl-uadk
+ make install &> /dev/null
+ ;;
+ esac
+ return 0
+ fi
+ echo "Package name ${NAME} could not match commit name ${COMMIT}."
+ return 1
+}
+
+build_uadk() {
+ exit_code=0
+ check_prebuilt_package uadk || exit_code=$?
+ if [ "$exit_code" = 0 ]; then
+ return 0
+ fi
+
+ autoreconf -vfi
+
+ # static build for v2
+ exit_code=0
+ ./configure \
+ --host aarch64-linux-gnu \
+ --target aarch64-linux-gnu \
+ --prefix=${WORKSPACE}/uadk-static-v2/usr/local \
+ --includedir=${WORKSPACE}/uadk-static-v2/${INC_DIR}/uadk \
+ --enable-static --disable-shared --with-static_drv
+ make -j$(nproc) || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to build UADK statically."
+ return $exit_code
+ fi
+ make install
+ exit_code=0
+ sudo \
+ LD_LIBRARY_PATH=${WORKSPACE}/uadk-static-v2/usr/local/lib/ \
+ PATH=${WORKSPACE}/uadk-static-v2/usr/local/bin:${PATH} \
+ C_INCLUDE_PATH=${WORKSPACE}/uadk-static-v2/usr/local/include/ \
+ ${WORKSPACE}/uadk/test/sanity_test.sh || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to run UADK tests with static build."
+ fi
+
+ sh cleanup.sh
+ autoreconf -vfi
+
+ # shared build for v2
+ exit_code=0
+ ./configure \
+ --host aarch64-linux-gnu \
+ --target aarch64-linux-gnu \
+ --prefix=${WORKSPACE}/uadk-shared-v2/usr/local \
+ --includedir=${WORKSPACE}/uadk-shared-v2/${INC_DIR}/uadk \
+ --disable-static --enable-shared
+ make -j$(nproc) || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to build UADK statically."
+ return $exit_code
+ fi
+ make install
+ exit_code=0
+ sudo \
+ LD_LIBRARY_PATH=${WORKSPACE}/uadk-shared-v2/usr/local/lib/ \
+ PATH=${WORKSPACE}/uadk-shared-v2/usr/local/bin:${PATH} \
+ C_INCLUDE_PATH=${WORKSPACE}/uadk-shared-v2/usr/local/include/ \
+ ${WORKSPACE}/uadk/test/sanity_test.sh || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to run UADK tests with dynamic build."
+ fi
+
+ # get the first 8 bytes of commit number
+ COMMIT=`git log | grep commit`
+ COMMIT=${COMMIT#*commit }
+ COMMIT=`echo ${COMMIT} | cut -b 1-8`
+ cd ${WORKSPACE}
+ # clean old packages
+ rm -f uadk-*.tar.xz
+ # create new package
+ tar -cJf uadk-${COMMIT}.tar.xz uadk-*-v*/
+ return 0
+}
+
+build_openssl() {
+ exit_code=0
+ check_prebuilt_package openssl || exit_code=$?
+ if [ "$exit_code" = 0 ]; then
+ return 0
+ fi
+
+ ./config --prefix=${LIB_ROOT}/usr/local
+ exit_code=0
+ make -j$(nproc) || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to build OpenSSL ($exit_code)"
+ return $exit_code
+ fi
+ make install || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to install OpenSSL ($exit_code)"
+ return $exit_code
+ fi
+
+ # get the first 8 bytes of commit number
+ COMMIT=`git log HEAD^..HEAD | grep commit`
+ COMMIT=${COMMIT#*commit }
+ COMMIT=`echo ${COMMIT} | cut -b 1-8`
+ cd ${WORKSPACE}
+ # clean old packages
+ rm -f openssl-*.tar.xz || exit_code=$?
+ echo "rm ssl $exit_code"
+ # create new package
+ tar -cJf openssl-${COMMIT}.tar.xz openssl || exit_code=$?
+ echo "tar ssl $exit_code"
+ return 0
+}
+
+build_uadk_openssl() {
+ exit_code=0
+ check_prebuilt_package ssluadk || exit_code=$?
+ if [ "$exit_code" = 0 ]; then
+ return 0
+ fi
+
+ cd ${WORKSPACE}/openssl-uadk
+ autoreconf -i -f -v
+ ./configure --prefix=${LIB_ROOT}/usr/local \
+ --libdir=${LIB_ROOT}/${LIB_DIR}/engines-1.1
+
+ exit_code=0
+ LD_LIBRARY_PATH=${LIB_ROOT}/${LIB_DIR}:${LIB_ROOT}/${LIB_DIR}/engines-1.1 \
+ PATH=${LIB_ROOT}/${BIN_DIR}:${PATH} \
+ C_INCLUDE_PATH=${LIB_ROOT}/${INC_DIR} \
+ make || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to build openssl-uadk ($exit_code)"
+ return $exit_code
+ fi
+ exit_code=0
+ make install || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to install openssl-uadk ($exit_code)"
+ return $exit_code
+ fi
+ exit_code=0
+ sudo \
+ LD_LIBRARY_PATH=${LIB_ROOT}/${LIB_DIR}:${LIB_ROOT}/${LIB_DIR}/engines-1.1 \
+ PATH=${LIB_ROOT}/${BIN_DIR}/:${PATH} \
+ C_INCLUDE_PATH=${LIB_ROOT}/${INC_DIR}/ \
+ openssl engine -t uadk || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to verify openssl-uadk engine ($exit_code)"
+ return $exit_code
+ fi
+ exit_code=0
+ sudo \
+ LD_LIBRARY_PATH=${LIB_ROOT}/${LIB_DIR}:${LIB_ROOT}/${LIB_DIR}/engines-1.1 \
+ PATH=${LIB_ROOT}/${BIN_DIR}/:${PATH} \
+ C_INCLUDE_PATH=${LIB_ROOT}/${INC_DIR}/ \
+ sanity_test.sh || exit_code=$?
+ if [ "$exit_code" != 0 ]; then
+ echo "Fail to verify openssl-uadk sanity test ($exit_code)"
+ return $exit_code
+ fi
+
+ # get the first 8 bytes of commit number
+ COMMIT=`git log | grep commit`
+ COMMIT=${COMMIT#*commit }
+ COMMIT=`echo ${COMMIT} | cut -b 1-8`
+ cd ${WORKSPACE}
+ # clean old packages
+ rm -f ssluadk-*.tar.xz
+ # create new package
+ tar -cJf ssluadk-${COMMIT}.tar.xz openssl-uadk || exit_code=$?
+ return $exit_code
+}
+
+# Initialize trap to call ctrlc_handler function when signal 2 (SIGINT) is
+# received.
+trap "ctrlc_handler" 2
+
if [ -z "${WORKSPACE}" ]; then
# Local build
export WORKSPACE=${PWD}
fi
+LIB_ROOT=${WORKSPACE}/uadk-shared-v2
+
+# Prevent multiple building scripts to access hardware
+lock
+
+# Load UACCE kernel modules, since there're different configurations of
+# UACCE kernel modules for UADK v1 and UADK v2.
+sh /home/buildslave/uadk-kernel/launch_uacce.sh || exit_code=$?
+if [ "$exit_code" != 0 ]; then
+ unlock
+ echo "Error while load UACCE modules."
+ exit 1
+fi
echo "#${BUILD_NUMBER}-${ghprbActualCommit:0:8}" > ${WORKSPACE}/version.txt
@@ -11,26 +316,26 @@ echo "#${BUILD_NUMBER}-${ghprbActualCommit:0:8}" > ${WORKSPACE}/version.txt
#sudo apt update -q=2
#sudo apt install -q=2 --yes --no-install-recommends zlib1g-dev libnuma-dev
-cd ${WORKSPACE}/uadk
-autoreconf -vfi
-
-# shared build for v2
-./conf.sh && make -j$(nproc)
-make install DESTDIR=${WORKSPACE}/uadk-shared-v2 && make clean
-sudo \
- LD_LIBRARY_PATH=${WORKSPACE}/uadk-shared-v2/usr/local/lib/ \
- PATH=${WORKSPACE}/uadk-shared-v2/usr/local/bin:${PATH} \
- C_INCLUDE_PATH=${WORKSPACE}/uadk-shared-v2/usr/local/include/ \
- ${WORKSPACE}/uadk/test/sanity_test.sh
-
-# static build for v2
-./conf.sh --static && make -j$(nproc)
-make install DESTDIR=${WORKSPACE}/uadk-static-v2 && make clean
-sudo \
- LD_LIBRARY_PATH=${WORKSPACE}/uadk-static-v2/usr/local/lib/ \
- PATH=${WORKSPACE}/uadk-static-v2/usr/local/bin:${PATH} \
- C_INCLUDE_PATH=${WORKSPACE}/uadk-static-v2/usr/local/include/ \
- ${WORKSPACE}/uadk/test/sanity_test.sh
-
-cd ${WORKSPACE}
-tar -cJf uadk.tar.xz uadk-*-v*/
+exit_code=0
+
+# Build UADK
+build_uadk || exit_code=$?
+if [ "$exit_code" != 0 ]; then
+ unlock
+ exit 1
+fi
+# Build OPENSSL
+build_openssl || exit_code=$?
+if [ "$exit_code" != 0 ]; then
+ unlock
+ exit 1
+fi
+# Build UADK-OPENSSL
+build_uadk_openssl || exit_code=$?
+if [ "$exit_code" != 0 ]; then
+ unlock
+ exit 1
+fi
+
+unlock
+echo "Run build script successfully!"