createTarball.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (C) 2011-2016 Intel Corporation. All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. #
  9. # * Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # * Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in
  13. # the documentation and/or other materials provided with the
  14. # distribution.
  15. # * Neither the name of Intel Corporation nor the names of its
  16. # contributors may be used to endorse or promote products derived
  17. # from this software without specific prior written permission.
  18. #
  19. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  23. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  24. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  25. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  26. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  27. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  28. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. #
  31. #
  32. set -e
  33. SCRIPT_DIR=$(dirname "$0")
  34. ROOT_DIR="${SCRIPT_DIR}/../../../../"
  35. BUILD_DIR="${ROOT_DIR}/build/linux"
  36. LINUX_INSTALLER_DIR="${ROOT_DIR}/linux/installer"
  37. LINUX_INSTALLER_COMMON_DIR="${LINUX_INSTALLER_DIR}/common"
  38. INSTALL_PATH=${SCRIPT_DIR}/output
  39. # Cleanup
  40. rm -fr ${INSTALL_PATH}
  41. # Get the architecture of the build from generated binary
  42. get_arch()
  43. {
  44. local a=$(readelf -h $BUILD_DIR/sgx_sign | sed -n '2p' | awk '/:/{print $6}')
  45. test $a = 02 && echo 'x64' || echo 'x86'
  46. }
  47. ARCH=$(get_arch)
  48. # Get the configuration for this package
  49. source ${SCRIPT_DIR}/installConfig.${ARCH}
  50. generate_pkgconfig_files() {
  51. local TEMPLATE_FOLDER=${SCRIPT_DIR}/pkgconfig/template
  52. local TARGET_FOLDER=${SCRIPT_DIR}/pkgconfig/${ARCH}
  53. local VERSION="$1"
  54. # Create pkgconfig folder for this architecture
  55. rm -fr ${TARGET_FOLDER}
  56. mkdir -p ${TARGET_FOLDER}
  57. # Copy the template files into the folder
  58. for pkgconfig_file in $(ls -1 ${TEMPLATE_FOLDER}); do
  59. sed -e "s:@LIB_FOLDER_NAME@:$LIB_DIR:" \
  60. -e "s:@SGX_VERSION@:$VERSION:" \
  61. ${TEMPLATE_FOLDER}/$pkgconfig_file > ${TARGET_FOLDER}/$pkgconfig_file
  62. done
  63. }
  64. # Get SGX version
  65. SGX_VERSION=$(awk '/STRFILEVER/ {print $3}' ${ROOT_DIR}/common/inc/internal/se_version.h|sed 's/^\"\(.*\)\"$/\1/')
  66. # Generate pkgconfig files
  67. generate_pkgconfig_files $SGX_VERSION
  68. # Fetch the gen_source script
  69. cp ${LINUX_INSTALLER_COMMON_DIR}/gen_source/gen_source.py ${SCRIPT_DIR}
  70. # Copy the files according to the BOM
  71. python ${SCRIPT_DIR}/gen_source.py --bom=BOMs/sdk_base.txt
  72. python ${SCRIPT_DIR}/gen_source.py --bom=BOMs/sdk_${ARCH}.txt --cleanup=false
  73. python ${SCRIPT_DIR}/gen_source.py --bom=../licenses/BOM_license.txt --cleanup=false
  74. # Create the tarball
  75. pushd ${INSTALL_PATH} &> /dev/null
  76. tar -zcvf ${TARBALL_NAME} *
  77. popd &> /dev/null