freedombone-utils-cmake 3.2KB

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