freedombone-utils-cmake 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Some things need a recent build of CMake to compile
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. CMAKE_REPO="https://github.com/Kitware/CMake"
  31. CMAKE_COMMIT='d6734eeb875ceca5d810e829ca90541918dca2b4'
  32. function mesh_install_cmake {
  33. if [ ! -d $rootdir$INSTALL_DIR ]; then
  34. chroot "$rootdir" mkdir -p $INSTALL_DIR
  35. fi
  36. chroot "$rootdir" apt-get -yq install build-essential
  37. if [ -d /repos/cmake ]; then
  38. mkdir $rootdir$INSTALL_DIR/cmake
  39. cp -r -p /repos/cmake/. $rootdir$INSTALL_DIR/cmake
  40. cd $rootdir$INSTALL_DIR/cmake
  41. git pull
  42. else
  43. git clone $CMAKE_REPO $rootdir$INSTALL_DIR/cmake
  44. fi
  45. cd $rootdir$INSTALL_DIR/cmake
  46. git checkout $CMAKE_COMMIT -b $CMAKE_COMMIT
  47. cat <<EOF > $rootdir/root/install_cmake
  48. cd $INSTALL_DIR/cmake
  49. ./bootstrap
  50. make
  51. if [ ! "$?" = "0" ]; then
  52. exit 72581
  53. fi
  54. make install
  55. EOF
  56. chroot "$rootdir" chmod +x /root/install_cmake
  57. chroot "$rootdir" /root/install_cmake
  58. chroot "$rootdir" rm /root/install_cmake
  59. }
  60. function install_cmake {
  61. if [ $INSTALLING_MESH ]; then
  62. mesh_install_cmake
  63. return
  64. fi
  65. if [ -d $INSTALL_DIR/cmake ]; then
  66. if ! grep -q "CMake commit:$CMAKE_COMMIT" $COMPLETION_FILE; then
  67. set_repo_commit $INSTALL_DIR/cmake "CMake commit" "$CMAKE_COMMIT" $CMAKE_REPO
  68. cd $INSTALL_DIR/cmake
  69. ./bootstrap
  70. make
  71. if [ ! "$?" = "0" ]; then
  72. exit 72581
  73. fi
  74. make install
  75. fi
  76. fi
  77. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  78. return
  79. fi
  80. if [ ! -d $INSTALL_DIR ]; then
  81. mkdir -p $INSTALL_DIR
  82. fi
  83. apt-get -yq install build-essential
  84. if [ -d /repos/cmake ]; then
  85. mkdir $INSTALL_DIR/cmake
  86. cp -r -p /repos/cmake/. $INSTALL_DIR/cmake
  87. cd $INSTALL_DIR/cmake
  88. git pull
  89. else
  90. git_clone $CMAKE_REPO $INSTALL_DIR/cmake
  91. fi
  92. cd $INSTALL_DIR/cmake
  93. git checkout $CMAKE_COMMIT -b $CMAKE_COMMIT
  94. ./bootstrap
  95. make
  96. if [ ! "$?" = "0" ]; then
  97. exit 72581
  98. fi
  99. make install
  100. mark_completed $FUNCNAME
  101. }
  102. # NOTE: deliberately there is no "exit 0"