deploy.sh 2.2 KB

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