From 7f48a7b023ddcbbf009793769a993f89f917cf19 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 13 Feb 2008 13:38:41 -0600 Subject: [PATCH] add support for curl --- misc/factor.sh | 90 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 60 insertions(+), 30 deletions(-) diff --git a/misc/factor.sh b/misc/factor.sh index 5d7e7d0b94..600d5eec84 100755 --- a/misc/factor.sh +++ b/misc/factor.sh @@ -14,16 +14,36 @@ NO_UI= GIT_PROTOCOL=${GIT_PROTOCOL:="git"} GIT_URL=${GIT_URL:=$GIT_PROTOCOL"://factorcode.org/git/factor.git"} +test_program_installed() { + if ! [[ -n `type -p $1` ]] ; then + return 0; + fi + return 1; +} ensure_program_installed() { - echo -n "Checking for $1..." - result=`type -p $1` - if ! [[ -n $result ]] ; then - echo "not found!" - echo "Install $1 and try again." - exit 1 - fi - echo "found!" + installed=0; + for i in $* ; + do + echo -n "Checking for $i..." + test_program_installed $1 + if [[ $? -eq 0 ]]; then + echo -n "not " + else + installed=$(( $installed + 1 )) + fi + echo "found!" + done + if [[ $installed -eq 0 ]] ; then + echo -n "Install " + if [[ $# -eq 1 ]] ; then + echo -n $1 + else + echo -n "any of [ $* ]" + fi + echo " and try again." + exit 1 + fi } check_ret() { @@ -47,11 +67,20 @@ check_gcc_version() { echo "ok." } +set_downloader() { + test_program_installed wget + if [[ $? -ne 0 ]] ; then + DOWNLOAD=wget + else + DOWNLOAD="curl -O" + fi +} + check_installed_programs() { ensure_program_installed chmod ensure_program_installed uname ensure_program_installed git - ensure_program_installed wget + ensure_program_installed wget curl ensure_program_installed gcc ensure_program_installed make case $OS in @@ -238,32 +267,33 @@ delete_boot_images() { echo "Deleting old images..." rm $BOOT_IMAGE > /dev/null 2>&1 rm $BOOT_IMAGE.* > /dev/null 2>&1 - rm staging.*.image > /dev/null 2>&1 + rm staging.*.image > /dev/null 2>&1 } get_boot_image() { - wget http://factorcode.org/images/latest/$BOOT_IMAGE - check_ret wget + get_url http://factorcode.org/images/latest/$BOOT_IMAGE +} + +get_url() { + if [[ $DOWNLOAD -eq "" ]] ; then + set_downloader; + fi + echo "HI" + echo $DOWNLOAD $1 ; + $DOWNLOAD $1 + check_ret $DOWNLOAD } maybe_download_dlls() { if [[ $OS == winnt ]] ; then - wget http://factorcode.org/dlls/freetype6.dll - check_ret wget - wget http://factorcode.org/dlls/zlib1.dll - check_ret wget - wget http://factorcode.org/dlls/OpenAL32.dll - check_ret wget - wget http://factorcode.org/dlls/alut.dll - check_ret wget - wget http://factorcode.org/dlls/ogg.dll - check_ret wget - wget http://factorcode.org/dlls/theora.dll - check_ret wget - wget http://factorcode.org/dlls/vorbis.dll - check_ret wget - wget http://factorcode.org/dlls/sqlite3.dll - check_ret wget + get_url http://factorcode.org/dlls/freetype6.dll + get_url http://factorcode.org/dlls/zlib1.dll + get_url http://factorcode.org/dlls/OpenAL32.dll + get_url http://factorcode.org/dlls/alut.dll + get_url http://factorcode.org/dlls/ogg.dll + get_url http://factorcode.org/dlls/theora.dll + get_url http://factorcode.org/dlls/vorbis.dll + get_url http://factorcode.org/dlls/sqlite3.dll chmod 777 *.dll check_ret chmod fi @@ -321,7 +351,7 @@ install_libraries() { } usage() { - echo "usage: $0 install|install-x11|self-update|quick-update|update|bootstrap|wget-bootstrap" + echo "usage: $0 install|install-x11|self-update|quick-update|update|bootstrap|net-bootstrap" echo "If you are behind a firewall, invoke as:" echo "env GIT_PROTOCOL=http $0 " } @@ -333,6 +363,6 @@ case "$1" in quick-update) update; refresh_image ;; update) update; update_bootstrap ;; bootstrap) get_config_info; bootstrap ;; - wget-bootstrap) get_config_info; delete_boot_images; get_boot_image; bootstrap ;; + net-bootstrap) get_config_info; delete_boot_images; get_boot_image; bootstrap ;; *) usage ;; esac