deploywithfind.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. if [ -d '/usr/lib/x86_64-linux-gnu/qt5' ]; then
  25. echo " Qt in /usr/lib"
  26. Qtgccdir='/usr/lib/x86_64-linux-gnu/qt5'
  27. QtPlatformdir=$Qtgccdir/plugins/platforms
  28. QtLibDir=/usr/lib/x86_64-linux-gnu/
  29. else
  30. echo "please sudo apt install qt"
  31. fi
  32. fi
  33. if [ ${#Qtgccdir} -lt 6 ]; then
  34. echo -e "\033[31m"" -----not found gccdir: so exit""\033[0m"
  35. exit 1
  36. fi
  37. ignore_lib_name=(
  38. libstdc++.so.*
  39. libm.so.*
  40. libgcc_s.so.*
  41. #libc.so.*
  42. #libpthread.so.*
  43. #libGL.so.*
  44. libz.so.*
  45. libc.so.*
  46. libgthread*
  47. libglib*
  48. libexpat*
  49. #libxcb*
  50. #libdl.so.*
  51. libxshmfence*
  52. libglapi.so.*
  53. libXext.so.*
  54. libXdamage.so.*
  55. libXfixes.so.*
  56. #libX11*
  57. libXxf86vm.so.*
  58. libdrm.so.*
  59. libpcre.so.*
  60. #libXau.so.*
  61. #libXdmcp.so.*
  62. )
  63. EXE="$1"
  64. PWD=`pwd`
  65. rm -rf app
  66. mkdir app
  67. cd app
  68. mkdir lib
  69. cd ..
  70. mkdir commonlib
  71. cd commonlib
  72. mkdir platforms
  73. cp $QtPlatformdir/libqxcb.so platforms
  74. cd platforms
  75. mkdir lib
  76. libfiles=`ldd libqxcb.so | awk '{ if(match($3,"^/"))printf("%s "),$3 }'`
  77. cp $libfiles $PWD/lib
  78. cd ..
  79. mkdir lib
  80. cp $QtLibDir/libQt5DBus.* $PWD/lib
  81. cp $QtLibDir/libQt5XcbQpa.* $PWD/lib
  82. rm -rf $PWD/platforms/lib
  83. cd platforms
  84. cd ..
  85. cd ..
  86. files=`ldd $EXE | awk '{ if(match($3,"^/"))printf("%s "),$3 }'`
  87. cp $files $PWD/app/lib
  88. cp $PWD/commonlib/lib/* $PWD/app/lib
  89. cp -r $PWD/commonlib/platforms $PWD/app
  90. cp $EXE $PWD/app
  91. for x in ${ignore_lib_name[@]}
  92. do
  93. rm -f $PWD/app/lib/${x}
  94. done
  95. rm -rf commonlib
  96. cd app
  97. patchelf --set-rpath '$ORIGIN/lib/' $EXE
  98. if [ "$?" != 0 ];then
  99. echo -e "\e[31m deploy.sh: patchelf $EXE faile, Ensure patchelf tool installed\e[0m"
  100. exit 1
  101. fi
  102. cd platforms
  103. patchelf --set-rpath '$ORIGIN/../lib/' libqxcb.so
  104. if [ "$?" != 0 ];then
  105. echo -e "\e[31m deploy.sh: patchelf $EXE faile, Ensure patchelf tool installed\e[0m"
  106. # exit 1
  107. fi
  108. cd ..
  109. cd ..
  110. cp -r app $PWD/deploy/
  111. xlib=`ls ./deploy/app/lib/lib*`
  112. for fileName in $xlib
  113. do
  114. patchelf --set-rpath '$ORIGIN' $fileName
  115. done
  116. rm -rf app