diff --git a/bootstrap.sh b/bootstrap.sh index df2c06bb9..1243829c5 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -33,7 +33,7 @@ function ask_remove_dir () { function ask_append_shell_config () { config_string="$1" - + shell_config_file="" # use order outlined by http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup if [ -f "$HOME/.bash_profile" ]; then @@ -60,6 +60,13 @@ function ask_append_shell_config () { return 1 } +function check_and_exit () { + if [ ! "$?" = "0" ]; then + echo "Error: problem running boostrap.sh. Exiting." + exit 1 + fi +} + if [ "--clone" = "$1" ]; then tusk_install_command="clone" git_clone=1 @@ -72,6 +79,8 @@ github_path=$(echo "$github_project" | tr '-' '/') install_directory="/usr/local/narwhal" tmp_zip="/tmp/narwhal.zip" +unset NARWHAL_ENGINE + PATH_SAVED="$PATH" ask_remove_dir "/usr/local/share/objj" @@ -109,22 +118,37 @@ if [ "$install_narwhal" ]; then install_directory="`cd \`dirname $input\`; pwd`/`basename $input`" fi + if [ -d "$install_directory" ]; then + echo "================================================================================" + echo "Directory exists at $install_directory. Delete it?" + if prompt; then + rm -rf "$install_directory" + fi + fi + if [ "$git_clone" ]; then git_repo="git://github.com/$github_path.git" echo "Cloning Narwhal from \"$git_repo\"..." git clone "$git_repo" "$install_directory" else zip_ball="http://github.com/$github_path/zipball/master" + echo "Downloading Narwhal from \"$zip_ball\"..." curl -L -o "$tmp_zip" "$zip_ball" + check_and_exit + echo "Installing Narwhal..." unzip "$tmp_zip" -d "$install_directory" + check_and_exit rm "$tmp_zip" + check_and_exit - mv $install_directory/$github_project-*/* $install_directory/. - rm -rf $install_directory/$github_project-* + mv "$install_directory/$github_project-"*/* "$install_directory/." + check_and_exit + rm -rf "$install_directory/$github_project-"* + check_and_exit fi - + export PATH="$install_directory/bin:$PATH" fi @@ -156,7 +180,7 @@ if [ `uname` = "Darwin" ]; then echo "This is optional but will make building and running Objective-J much faster." if prompt; then tusk $tusk_install_command narwhal-jsc - + if ! (cd "$install_directory/packages/narwhal-jsc" && make webkit); then echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" echo "WARNING: building narwhal-jsc failed. Hit enter to continue." @@ -175,9 +199,9 @@ export PATH="$PATH_SAVED" if ! which "narwhal" > /dev/null; then echo "================================================================================" echo "You must add Narwhal's \"bin\" directory to your PATH environment variable. Do this automatically now?" - + export_path_string="export PATH=\"$install_directory/bin:\$PATH\"" - + if ! ask_append_shell_config "$export_path_string"; then echo "Add \"$install_directory/bin\" to your PATH environment variable in your shell configuration file (e.x. .profile, .bashrc, .bash_profile)." echo "For example:" @@ -193,7 +217,7 @@ if [ "$CAPP_BUILD" ]; then rm -rf "$CAPP_BUILD" fi fi -else +else echo "================================================================================" echo "Before building Cappuccino we recommend you set the \$CAPP_BUILD environment variable to a path where you wish to build Cappuccino." echo "If you have previously set \$CAPP_BUILD and built Cappuccino you may want to delete the directory before rebuilding."