_cmake.sh 2.6 KB

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