Skip to content
Browse files

Reverted d8c0ec4 because it broke Apple computers.

  • Loading branch information...
1 parent 64c8a7e commit bab2f9600d2ac16807988f1908aba20477a169ff Caleb James DeLisle committed Nov 15, 2012
Showing with 38 additions and 58 deletions.
  1. +38 −58 do
View
96 do
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/bin/bash
# You may redistribute this program and/or modify it under the terms of
# the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
@@ -14,74 +14,54 @@
CMAKE_DOWNLOAD=http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
CMAKE_SHA256=2b59897864d6220ff20aa8eac64cac8994e004898a1c0f899c8cb4d7b7570b46
+[ `dirname $0` ] && cd `dirname $0`
+
# get a sha256sum implementation.
getsha256sum() {
- local testhash=4ee73c05d5158b0fdfec9f5e52cab3fa85b98d6992a221bbff28fdbd935e8afc
- local testfile=test/$testhash
- local program
- for program in 'sha256sum' 'gsha256sum' 'shasum -a 256' 'openssl sha256'; do
- if $program $testfile 2>/dev/null | grep -qs "$testhash"; then
- SHA256SUM=$program
- return 0
- fi
+ expected=4ee73c05d5158b0fdfec9f5e52cab3fa85b98d6992a221bbff28fdbd935e8afc
+ testFile=test/$expected
+ for hasher in sha256sum gsha256sum 'shasum -a 256' 'openssl sha256'
+ do
+ #echo "trying ${hasher} ${testFile}"
+ ${hasher} ${testFile} 2>/dev/null | grep -q ${expected} && SHA256SUM=${hasher} && break
done
- echo "Couldn't find a working sha256 tool."
- return 1
+ [ ! "${SHA256SUM}" ] && echo "couldn't find working sha256 hasher." && exit 1
}
-cd "$(dirname "$0")"
-mkdir -p build
-cd build
-
-CMAKE=$PWD/cmake-build/bin/cmake
+getsha256sum
-if [ ! -x "$CMAKE" ]; then
- CMAKE=$(which cmake)
+if [ ! -d build ]; then
+ mkdir build;
fi
+cd build
-if ! { [ -x "$CMAKE" ] && "$CMAKE" --version |
- egrep 'version 2\.8\.([2-9]|[1-9][0-9]+)(\.|$)'; }; then
+CMAKE=`which cmake`
+if [ -f cmake-build/bin/cmake ]; then
+ CMAKE=`pwd`/cmake-build/bin/cmake
+fi
- set -e # exit if a command fails
- rm -rf cmake-build
+[ ${CMAKE} ] && ${CMAKE} --version | grep 2.8.[2-9] ||
+while true; do
+ [ -d cmake-build ] && rm -r cmake-build
mkdir cmake-build
cd cmake-build
- getsha256sum
-
- if which wget >&/dev/null; then
- wget "$CMAKE_DOWNLOAD" -O cmake.tar.gz
- elif which curl >&/dev/null; then
- curl "$CMAKE_DOWNLOAD" -o cmake.tar.gz
- else
- echo "Please download the following file to 'cmake.tar.gz'"
- echo " $CMAKE_DOWNLOAD"
- exit 1
- fi
-
- if ! $SHA256SUM cmake.tar.gz | grep -qs "$CMAKE_SHA256"; then
- echo "Checksum of cmake.tar.gz incorrect"
- exit 1
- fi
-
- tar -xf cmake.tar.gz
- find . -mindepth 1 -maxdepth 1 -type d -exec mv {} build \;
- build/configure
- make
- CMAKE="$PWD/bin/cmake"
+ APP=`which wget || which curl || echo 'none'`
+ [[ "$APP" == 'none' ]] && echo 'Need wget curl' && exit -1;
+ [[ "$APP" == `which wget` ]] && $APP ${CMAKE_DOWNLOAD}
+ [[ "$APP" == `which curl` ]] && $APP ${CMAKE_DOWNLOAD} > cmake.tar.gz
+ ${SHA256SUM} ./*.tar.gz | grep ${CMAKE_SHA256} || exit -1
+ tar -xf *.tar.gz
+ find ./ -mindepth 1 -maxdepth 1 -type d -exec mv {} build \;
+ ./build/configure && make || exit -1
+ CMAKE=`pwd`/bin/cmake
cd ..
- set +e
-fi
-
-set -e
-
-$CMAKE ..
-
-make
-
-# I'm not drunk enough to understand this.
-make test || rm cjdroute &&
-[ -f admin/angel/cjdroute2 ] && [ ! -f ../cjdroute ] || rm ../cjdroute && cp admin/angel/cjdroute2 ../cjdroute &&
-[ -f admin/angel/cjdns ] && [ ! -f ../cjdns ] || rm ../cjdns && cp admin/angel/cjdns ../ &&
-echo -e "\033[1;32mBuild completed successfully, type ./cjdroute to begin setup.\033[0m"
+ break
+done
+
+${CMAKE} .. && make &&
+ make test || rm cjdroute &&
+ [ -f admin/angel/cjdroute2 ] && [ ! -f ../cjdroute ] || rm ../cjdroute && cp admin/angel/cjdroute2 ../cjdroute &&
+ [ -f admin/angel/cjdns ] && [ ! -f ../cjdns ] || rm ../cjdns && cp admin/angel/cjdns ../ &&
+ echo -e "\033[1;32mBuild completed successfully, type ./cjdroute to begin setup.\033[0m"

0 comments on commit bab2f96

Please sign in to comment.
Something went wrong with that request. Please try again.