install-sgx-sdk.bin.tmpl 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. PKG_NAME="Intel SGX SDK"
  34. if test $(id -u) -ne 0; then
  35. echo "Root privilege is required to install $PKG_NAME."
  36. exit 4
  37. fi
  38. PATH=/usr/bin:/bin
  39. umask 022
  40. SDKPKG=`mktemp -t sgx-sdk-pkg.XXXXXX`
  41. SDK_TEMP_FOLDER=`mktemp -d sgx-sdk-XXXXXX -p /tmp`
  42. trap "rm -rf $SDKPKG $SDK_TEMP_FOLDER 2>/dev/null; exit 3" HUP INT QUIT TERM
  43. # The number of lines in this script (plus 1). Using this number to
  44. # calculate the start address of the payload.
  45. NR_SCRIPT_LINES=@linenum@
  46. # Run /usr/bin/md5sum on the binary payload to get the MD5 check sum.
  47. CHKSUM=@md5sum@
  48. # Get the install payload from this shell script.
  49. echo -n "Unpacking $PKG_NAME ..."
  50. tail -n +$NR_SCRIPT_LINES "$0" > $SDKPKG
  51. echo " done."
  52. echo -n "Verifying the integrity of the install package ..."
  53. if test $(md5sum $SDKPKG | awk '{print $1}') != $CHKSUM; then
  54. echo " The install package appears to be corrupted."
  55. exit 1
  56. fi
  57. echo " done."
  58. echo -n "Installing $PKG_NAME ..."
  59. tar zxf $SDKPKG -C $SDK_TEMP_FOLDER >/dev/null 2>&1
  60. retcode=$? # Save the return code
  61. # Clean-up the temporary tarball.
  62. rm -f $SDKPKG 2>/dev/null
  63. if test $retcode -ne 0; then
  64. echo " failed."
  65. exit 2
  66. fi
  67. echo " done."
  68. pushd ${SDK_TEMP_FOLDER}
  69. source scripts/installConfig
  70. make install
  71. popd
  72. ${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}/scripts/install.sh
  73. rm -fr ${SDK_TEMP_FOLDER}
  74. exit 0