do 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #!/bin/sh
  2. # You may redistribute this program and/or modify it under the terms of
  3. # the GNU General Public License as published by the Free Software Foundation,
  4. # either version 3 of the License, or (at your option) any later version.
  5. #
  6. # This program is distributed in the hope that it will be useful,
  7. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. # GNU General Public License for more details.
  10. #
  11. # You should have received a copy of the GNU General Public License
  12. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. CMAKE_DOWNLOAD=http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
  14. CMAKE_SHA256=2b59897864d6220ff20aa8eac64cac8994e004898a1c0f899c8cb4d7b7570b46
  15. [ `dirname $0` ] && cd `dirname $0`
  16. # get a sha256sum implementation.
  17. getsha256sum() {
  18. expected=4ee73c05d5158b0fdfec9f5e52cab3fa85b98d6992a221bbff28fdbd935e8afc
  19. testFile=test/$expected
  20. for hasher in sha256sum gsha256sum 'shasum -a 256' 'openssl sha256'
  21. do
  22. #echo "trying ${hasher} ${testFile}"
  23. ${hasher} ${testFile} 2>/dev/null | grep -q ${expected} && SHA256SUM=${hasher} && break
  24. done
  25. [ ! "${SHA256SUM}" ] && echo "couldn't find working sha256 hasher." && exit 1
  26. }
  27. getsha256sum
  28. if [ ! -d build ]; then
  29. mkdir build;
  30. fi
  31. cd build
  32. CMAKE=`which cmake`
  33. if [ -f cmake-build/bin/cmake ]; then
  34. CMAKE=`pwd`/cmake-build/bin/cmake
  35. fi
  36. [ ${CMAKE} ] && ${CMAKE} --version | grep '2.8.\([2-9]\|10\)' ||
  37. while true; do
  38. [ -d cmake-build ] && rm -r cmake-build
  39. mkdir cmake-build
  40. cd cmake-build
  41. APP=`which wget || which curl || echo 'none'`
  42. [ "$APP" = 'none' ] && echo 'Need wget curl' && exit 1;
  43. [ "$APP" = `which wget` ] && $APP ${CMAKE_DOWNLOAD}
  44. [ "$APP" = `which curl` ] && $APP ${CMAKE_DOWNLOAD} > cmake.tar.gz
  45. ${SHA256SUM} ./*.tar.gz | grep ${CMAKE_SHA256} || exit 1
  46. tar -xzf *.tar.gz
  47. find ./ -mindepth 1 -maxdepth 1 -type d -exec mv {} build \;
  48. ./build/configure && make || exit 1
  49. CMAKE=`pwd`/bin/cmake
  50. cd ..
  51. break
  52. done
  53. (
  54. ${CMAKE} .. && make || exit 1;
  55. make test || [ "${FORCE}" != "" ] || exit 1;
  56. [ -f admin/angel/cjdroute2 ] && [ -f admin/angel/cjdns ] || exit 1;
  57. [ ! -f ../cjdroute ] || rm ../cjdroute || exit 1;
  58. [ ! -f ../cjdns ] || rm ../cjdns || exit 1;
  59. cp admin/angel/cjdroute2 ../cjdroute || exit 1;
  60. cp admin/angel/cjdns ../ || exit 1;
  61. echo -e "\033[1;32mBuild completed successfully, type ./cjdroute to begin setup.\033[0m"
  62. ) || echo -e "\033[1;31mFailed to build cjdns.\033[0m"