install.sh 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (C) 2011-2018 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. source ${SCRIPT_DIR}/installConfig
  35. # Generate the script to preload Intel(R) SGX ptrace library for gdb
  36. SDK_DST_PATH=${SGX_PACKAGES_PATH}/${SDK_PKG_NAME}
  37. SDK_LIB_PATH=${SDK_DST_PATH}/${LIB_DIR}
  38. if [ "$1" == "BIN" ]; then
  39. GDB_SCRIPT=${SDK_DST_PATH}/bin/sgx-gdb
  40. else
  41. GDB_SCRIPT=/usr/bin/sgx-gdb
  42. fi
  43. generate_gdb_script()
  44. {
  45. cat > $GDB_SCRIPT <<EOF
  46. #!/usr/bin/env bash
  47. #
  48. # Copyright (C) 2011-2018 Intel Corporation. All rights reserved.
  49. #
  50. # Redistribution and use in source and binary forms, with or without
  51. # modification, are permitted provided that the following conditions
  52. # are met:
  53. #
  54. # * Redistributions of source code must retain the above copyright
  55. # notice, this list of conditions and the following disclaimer.
  56. # * Redistributions in binary form must reproduce the above copyright
  57. # notice, this list of conditions and the following disclaimer in
  58. # the documentation and/or other materials provided with the
  59. # distribution.
  60. # * Neither the name of Intel Corporation nor the names of its
  61. # contributors may be used to endorse or promote products derived
  62. # from this software without specific prior written permission.
  63. #
  64. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  65. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  66. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  67. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  68. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  69. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  70. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  71. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  72. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  73. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  74. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  75. #
  76. #
  77. shopt -s expand_aliases
  78. GDB_SGX_PLUGIN_PATH=$SDK_LIB_PATH/gdb-sgx-plugin
  79. SGX_LIBRARY_PATH=$SDK_LIB_PATH
  80. if [ -f /usr/local/bin/gdb ]
  81. then
  82. GDB=/usr/local/bin/gdb
  83. elif [ -f /usr/bin/gdb ]
  84. then
  85. GDB=/usr/bin/gdb
  86. else
  87. GDB=gdb
  88. fi
  89. export PYTHONPATH=\$GDB_SGX_PLUGIN_PATH
  90. LD_PRELOAD=\$SGX_LIBRARY_PATH/libsgx_ptrace.so \$GDB -iex "directory \$GDB_SGX_PLUGIN_PATH" -iex "source \$GDB_SGX_PLUGIN_PATH/gdb_sgx_plugin.py" -iex "set environment LD_PRELOAD" -iex "add-auto-load-safe-path /usr/lib" "\$@"
  91. EOF
  92. chmod +x $GDB_SCRIPT
  93. }
  94. generate_gdb_script
  95. generate_uninstall_script()
  96. {
  97. cat > $SDK_DST_PATH/uninstall.sh <<EOF
  98. #!/usr/bin/env bash
  99. #
  100. # Copyright (C) 2011-2018 Intel Corporation. All rights reserved.
  101. #
  102. # Redistribution and use in source and binary forms, with or without
  103. # modification, are permitted provided that the following conditions
  104. # are met:
  105. #
  106. # * Redistributions of source code must retain the above copyright
  107. # notice, this list of conditions and the following disclaimer.
  108. # * Redistributions in binary form must reproduce the above copyright
  109. # notice, this list of conditions and the following disclaimer in
  110. # the documentation and/or other materials provided with the
  111. # distribution.
  112. # * Neither the name of Intel Corporation nor the names of its
  113. # contributors may be used to endorse or promote products derived
  114. # from this software without specific prior written permission.
  115. #
  116. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  117. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  118. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  119. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  120. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  121. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  122. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  123. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  124. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  125. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  126. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  127. #
  128. #
  129. if test \$(id -u) -ne 0; then
  130. echo "Root privilege is required."
  131. exit 1
  132. fi
  133. # Removing the simulation runtime libraries
  134. rm -f /usr/lib/libsgx_uae_service_sim.so
  135. rm -f /usr/lib/libsgx_urts_sim.so
  136. # Removing pkg-config files
  137. rm -f /usr/lib/pkgconfig/libsgx_uae_service.pc
  138. rm -f /usr/lib/pkgconfig/libsgx_urts.pc
  139. rm -f /usr/lib/pkgconfig/libsgx_uae_service_sim.pc
  140. rm -f /usr/lib/pkgconfig/libsgx_urts_sim.pc
  141. # Removing sgx-gdb script
  142. rm -f $GDB_SCRIPT
  143. # Removing the SDK folder
  144. rm -fr $SDK_DST_PATH
  145. EOF
  146. }
  147. generate_uninstall_script_for_bin()
  148. {
  149. cat > $SDK_DST_PATH/uninstall.sh <<EOF
  150. #!/usr/bin/env bash
  151. #
  152. # Copyright (C) 2011-2018 Intel Corporation. All rights reserved.
  153. #
  154. # Redistribution and use in source and binary forms, with or without
  155. # modification, are permitted provided that the following conditions
  156. # are met:
  157. #
  158. # * Redistributions of source code must retain the above copyright
  159. # notice, this list of conditions and the following disclaimer.
  160. # * Redistributions in binary form must reproduce the above copyright
  161. # notice, this list of conditions and the following disclaimer in
  162. # the documentation and/or other materials provided with the
  163. # distribution.
  164. # * Neither the name of Intel Corporation nor the names of its
  165. # contributors may be used to endorse or promote products derived
  166. # from this software without specific prior written permission.
  167. #
  168. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  169. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  170. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  171. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  172. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  173. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  174. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  175. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  176. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  177. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  178. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  179. #
  180. #
  181. # Removing the SDK folder
  182. rm -fr $SDK_DST_PATH 2> /dev/null
  183. if [ \$? -ne 0 ]; then
  184. echo "Superuser privilege is required."
  185. exit 1
  186. fi
  187. echo "Intel(R) SGX SDK uninstalled."
  188. EOF
  189. }
  190. if [ "$1" == "BIN" ]; then
  191. generate_uninstall_script_for_bin
  192. else
  193. generate_uninstall_script
  194. fi
  195. chmod +x $SDK_DST_PATH/uninstall.sh
  196. echo -e "uninstall.sh script generated in $SDK_DST_PATH\n"
  197. echo -e "Installation is successful! The SDK package can be found in $SDK_DST_PATH"
  198. rm -fr $SDK_DST_PATH/scripts
  199. exit 0