Changeset 1157 in svn for autobuild/scripts/download


Ignore:
Timestamp:
2012-10-29T12:42:35Z (3 years ago)
Author:
Xuefer
Message:

use simple and stupid rules to download files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • autobuild/scripts/download

    r913 r1157  
    99        return 0
    1010    fi
    11     begin "Downloading $url to $file"; {
     11    begin "from $url"; {
    1212        if type aria2c >/dev/null 2>/dev/null; then
    1313            (
     
    2525        rm -f "$file.tmp"
    2626    };
    27     [[ -z $ret ]] && end || end "not found"
     27    [[ $ret -eq 0 ]] && end || end "not found"
    2828   
    2929    return $ret
     
    4040}
    4141
    42 downloadPhp() {
    43     local filename
    44     local arch
    45     local compiler
    46     local nts
    47     local downloaded
    48     local type
    49     local snapVersion
     42download_x() {
     43    local filename=$1
     44    shift
    5045
    51     case "$phpVersion" in
    52     *-dev-*)
    53         type="snaps"
    54         snapVersion=-${phpVersion##*-}
    55         phpVersion=${phpVersion%-*}
    56         filename="php$phpVersion$snapVersion.tar.bz2"
    57         filename=${filename/0.-dev-/-}
    58         download "$sourceDir/php-$phpVersion$snapVersion.tar.bz2" "http://snaps.php.net/$filename"
    59         ;;
    60     *)
    61         type="releases"
    62         filename="php-$phpVersion.tar.bz2"
    63         target="$sourceDir/$filename"
    64         download "$target" "http://$mirror/get/$filename/from/$mirror/mirror" \
    65         || download "$target" "http://museum.php.net/php5/$filename"
    66         ;;
    67     esac
    68 
    69     downloaded=
    70     for nts in '' '-nts'; do
    71         case "$phpVersion" in
    72         4.*|5.0.*|5.1.*)
    73             ;;
    74         *)
    75             for compiler in "${compilers[@]}"; do
    76                 for arch in "${arches[@]}"; do
    77                     filename=php-$phpVersion$nts-Win32-$compiler-$arch$snapVersion.zip
    78                     download "$sourceDir/$filename" "http://windows.php.net/downloads/$type/$filename"
    79                     if [[ -s "$sourceDir/$filename" ]]; then
    80                         downloaded=1
    81                     fi
    82                 done
    83             done
    84         esac
    85     done
    86     if [[ -z $downloaded ]]; then
    87         filename=php-$phpVersion-Win32.zip
    88         target="$sourceDir/$filename"
    89         download "$target" "http://$mirror/get/$filename/from/$mirror/mirror" \
    90         || download "$target" "http://museum.php.net/php5/$filename"
    91     fi
     46    local url
     47    local ret=1
     48    begin "Downloading $filename"; {
     49        while [ $# -gt 0 ]; do
     50            url=$1
     51            shift
     52            if download "$sourceDir/$filename" $url; then
     53                ret=0
     54                break
     55            fi
     56        done
     57    };
     58    [[ $ret -eq 0 ]] && end "downloaded" || end "not found"
     59    return $ret
    9260}
    9361
    9462trap cleanup exit
    9563
    96 case $# in
    97 0)
    98     foreachPhpVersion downloadPhp
    99     ;;
    100 1)
    101     loadPhpVersion "$1"
    102     downloadPhp
    103     ;;
    104 esac
    105 
    106 exit 0
     64phpFiles_foreach download_x
Note: See TracChangeset for help on using the changeset viewer.