deploy.sh 2.1 KB

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