deploylib.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #! /bin/bash
  2. Qtgccdir='/usr/lib/x86_64-linux-gnu/qt5'
  3. if [ ${#Qtgccdir} -lt 6 ]; then
  4. echo "Because not set gcc_64 , so auto find gcc_64 "
  5. optfiles=`find /opt -name 'gcc_64'`
  6. for entry in $optfiles
  7. do
  8. if [ ${entry:0-6:6} == "gcc_64" ]; then
  9. if [ -d $entry ]; then
  10. Qtgccdir="$entry"
  11. echo -e "\033[32m"" -----found gccdir:"$Qtgccdir"\033[0m"
  12. fi
  13. fi
  14. done
  15. fi
  16. if [ ${#Qtgccdir} -lt 6 ]; then
  17. if [ -d '/usr/lib/aarch64-linux-gnu/qt5' ]; then
  18. Qtgccdir='/usr/lib/aarch64-linux-gnu/qt5'
  19. else
  20. echo "if NVIDIA,please sudo apt install qt"
  21. fi
  22. fi
  23. if [ ${#Qtgccdir} -lt 6 ]; then
  24. echo -e "\033[31m"" -----not found gccdir: so exit""\033[0m"
  25. exit 1
  26. fi
  27. QtPlatformdir=$Qtgccdir/plugins/platforms
  28. QtLibDir=$Qtgccdir/lib
  29. RTPSLIBDIR=`pwd`/thirdpartylib/FastRTPS/lib/libamd64
  30. RTPSLIBARMDIR=`pwd`/thirdpartylib/FastRTPS/lib/libarm64
  31. echo $RTPSLIBDIR
  32. new_export="export LD_LIBRARY_PATH=$RTPSLIBDIR:\$LD_LIBRARY_PATH"
  33. new_export2="export LD_LIBRARY_PATH=$RTPSLIBARMDIR:\$LD_LIBRARY_PATH"
  34. reg_str="^\s*export\s*LD_LIBRARY_PATH=$RTPSLIBDIR:\$LD_LIBRARY_PATH"
  35. if grep -q $reg_str ~/.bashrc
  36. then
  37. echo $RTPSLIBDIR exists in LD_LIBRARAY_PATH
  38. else
  39. echo define LD_LIBRARY_PATH
  40. echo $new_export >> ~/.bashrc
  41. echo $new_export2 >> ~/.bashrc
  42. echo Please source .bashrc
  43. fi
  44. if [ "$#" -lt 1 ]; then
  45. echo "没有输入"
  46. echo "$1"
  47. exit
  48. fi
  49. ignore_lib_name=(
  50. libstdc++.so.*
  51. libm.so.*
  52. libgcc_s.so.*
  53. libc.so.*
  54. libpthread.so.*
  55. libGL.so.*
  56. libz.so.*
  57. libgthread*
  58. libglib*
  59. libexpat*
  60. libxcb*
  61. libdl.so.*
  62. libxshmfence*
  63. libglapi.so.*
  64. libXext.so.*
  65. libXdamage.so.*
  66. libXfixes.so.*
  67. libX11*
  68. libXxf86vm.so.*
  69. libdrm.so.*
  70. libpcre.so.*
  71. libXau.so.*
  72. libXdmcp.so.*
  73. )
  74. EXE="$1"
  75. PWD=`pwd`
  76. rm -rf app
  77. mkdir app
  78. cd app
  79. mkdir lib
  80. cd ..
  81. mkdir commonlib
  82. cd commonlib
  83. mkdir platforms
  84. cp $QtPlatformdir/libqxcb.so platforms
  85. cd platforms
  86. mkdir lib
  87. libfiles=`ldd libqxcb.so | awk '{ if(match($3,"^/"))printf("%s "),$3 }'`
  88. cp $libfiles $PWD/lib
  89. cd ..
  90. mkdir lib
  91. cp $QtLibDir/libQt5DBus.s* $PWD/lib
  92. cp $QtLibDir/libQt5XcbQpa.s* $PWD/lib
  93. rm -rf $PWD/platforms/lib
  94. cd platforms
  95. patchelf --set-rpath '$ORIGIN/../lib/' libqxcb.so
  96. patchelf --set-rpath '$ORIGIN' ./deploy/app/lib/libfastrtps.so*
  97. cd ..
  98. cd ..
  99. files=`ldd $EXE | awk '{ if(match($3,"^/"))printf("%s "),$3 }'`
  100. cp $files $PWD/app/lib
  101. cp $PWD/commonlib/lib/* $PWD/app/lib
  102. cp -r $PWD/commonlib/platforms $PWD/app
  103. cp $EXE $PWD/app/lib
  104. for x in ${ignore_lib_name[@]}
  105. do
  106. rm -f $PWD/app/lib/${x}
  107. done
  108. rm -rf commonlib
  109. cd app
  110. cd lib
  111. patchelf --set-rpath '$ORIGIN' $EXE
  112. if [ "$?" != 0 ];then
  113. echo -e "\e[31m deploy.sh: patchelf $EXE faile, Ensure patchelf tool installed\e[0m"
  114. exit 1
  115. fi
  116. cd ..
  117. cd ..
  118. cp -r app $PWD/deploy/
  119. rm -rf app