_cmake.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/bash
  2. Mode=prod
  3. error_flag=0
  4. function version {
  5. echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }';
  6. }
  7. function install_ {
  8. echo -e "$(tput setaf 10)\nInstall / Update cmake :$(tput sgr0)"
  9. if [ -x "$(command -v cmake)" ];then flag=1; else flag=0;fi
  10. case $flag in
  11. 0)
  12. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/cmake_3.26.4-1_amd64.deb
  13. sudo dpkg -i cmake_3.26.4-1_amd64.deb
  14. rm cmake_3.26.4-1_amd64.deb
  15. ;;
  16. 1)
  17. cmake_v="$(cmake --version | grep "version" | awk '{print $3}')"
  18. echo "cmake version : $cmake_v"
  19. sleep 2
  20. if ! [ $(version $cmake_v) -ge $(version "3.18") ]
  21. then
  22. echo -e "cmake need update=> cmake_3.27.9"
  23. sudo apt-get -qq remove --purge cmake -y
  24. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/cmake_3.27.9-1_amd64.deb
  25. sudo dpkg -i cmake_3.27.9-1_amd64.deb
  26. rm cmake_3.27.9-1_amd64.deb
  27. else
  28. echo -e "cmake version ok."
  29. sleep 2
  30. fi
  31. ;;
  32. *) echo "Error";;
  33. esac
  34. echo "Done"
  35. }
  36. function rollback {
  37. echo -e "$(tput setaf 10)\nInstall / Update cmake :$(tput sgr0)"
  38. if [ -x "$(command -v cmake)" ];then flag=1; else flag=0;fi
  39. case $flag in
  40. 0)
  41. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/cmake_3.16.3-1_amd64.deb
  42. sudo dpkg -i cmake_3.16.3-1_amd64.deb
  43. rm cmake_3.16.3-1_amd64.deb
  44. ;;
  45. 1)
  46. cmake_v="$(cmake --version | grep "version" | awk '{print $3}')"
  47. echo "cmake version : $cmake_v"
  48. sleep 2
  49. if [ $(version $cmake_v) -gt $(version "3.18") ]
  50. then
  51. echo -e "cmake need rollback to cmake_3.16.3"
  52. sudo apt-get -qq remove --purge cmake -y
  53. wget -c -q --show-progress http://folivier.homelinux.org/cube/pack/cmake_3.16.3-1_amd64.deb
  54. sudo dpkg -i cmake_3.16.3-1_amd64.deb
  55. rm cmake_3.16.3-1_amd64.deb
  56. else
  57. echo -e "cmake version ok."
  58. sleep 2
  59. fi
  60. ;;
  61. *) echo "Error";;
  62. esac
  63. echo "Done"
  64. }
  65. function cmake_source {
  66. echo -e "$(tput setaf 12)Cmake kitware build:$(tput sgr0)"
  67. sleep 2
  68. sudo apt-get install checkinstall -y
  69. wget -c https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4.tar.gz
  70. tar xvfz cmake-3.26.4.tar.gz
  71. cd cmake-3.26.4
  72. ./bootstrap
  73. make -j6
  74. sudo checkinstall --pkgname=cmake --pkgversion="3.26.4" --default
  75. hash -r
  76. }
  77. Mode=${Mode^^}
  78. if [ -z $1 ];then install_ && exit;fi
  79. if [ $1 = "rollback" ];then rollback;fi
  80. if [ $1 = "BUILD" ];then cmake_source;fi