freedombone-utils-cmake 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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-2018 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. # shellcheck disable=SC2154
  34. if [ ! -d "$rootdir$INSTALL_DIR" ]; then
  35. chroot "$rootdir" mkdir -p "$INSTALL_DIR"
  36. fi
  37. chroot "$rootdir" apt-get -yq install build-essential
  38. if [ -d /repos/cmake ]; then
  39. mkdir "$rootdir$INSTALL_DIR/cmake"
  40. cp -r -p /repos/cmake/. "$rootdir$INSTALL_DIR/cmake"
  41. cd "$rootdir$INSTALL_DIR/cmake" || exit 678346836
  42. git pull
  43. else
  44. git clone "$CMAKE_REPO" "$rootdir$INSTALL_DIR/cmake"
  45. fi
  46. cd "$rootdir$INSTALL_DIR/cmake" || exit 734634684
  47. git checkout $CMAKE_COMMIT -b $CMAKE_COMMIT
  48. cat <<EOF > "$rootdir/root/install_cmake"
  49. cd $INSTALL_DIR/cmake
  50. ./bootstrap
  51. make
  52. if [ ! "$?" = "0" ]; then
  53. exit 72581
  54. fi
  55. make install
  56. EOF
  57. chroot "$rootdir" chmod +x /root/install_cmake
  58. chroot "$rootdir" /root/install_cmake
  59. chroot "$rootdir" rm /root/install_cmake
  60. }
  61. function install_cmake {
  62. if [ "$INSTALLING_MESH" ]; then
  63. mesh_install_cmake
  64. return
  65. fi
  66. if [ -d "$INSTALL_DIR/cmake" ]; then
  67. if ! grep -q "CMake commit:$CMAKE_COMMIT" "$COMPLETION_FILE"; then
  68. set_repo_commit "$INSTALL_DIR/cmake" "CMake commit" "$CMAKE_COMMIT" "$CMAKE_REPO"
  69. cd "$INSTALL_DIR/cmake" || exit 36873638
  70. ./bootstrap
  71. if ! make; then
  72. exit 72581
  73. fi
  74. make install
  75. fi
  76. fi
  77. if [[ $(is_completed "${FUNCNAME[0]}") == "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" || exit 374893758
  88. git pull
  89. else
  90. git_clone "$CMAKE_REPO" "$INSTALL_DIR/cmake"
  91. fi
  92. cd "$INSTALL_DIR/cmake" || exit 3467384
  93. git checkout "$CMAKE_COMMIT" -b "$CMAKE_COMMIT"
  94. ./bootstrap
  95. if ! make; then
  96. exit 72581
  97. fi
  98. make install
  99. mark_completed "${FUNCNAME[0]}"
  100. }
  101. # NOTE: deliberately there is no "exit 0"