#! /bin/bash -- # # download.sh: downloader for StaticPython which autodetects the OS # by pts@fazekas.hu at Mon May 23 16:06:56 CEST 2011 # # Example usage: # # curl http://pts-mini-gpl.googlecode.com/svn/trunk/staticpython/d.sh | # bash /dev/stdin python2.7-static # if test $Argc != 1 || test $(1/\//) != $1 { echo "Usage: $0: {python2.7-static|stackless2.7-static|stacklessco2.7-static}" > !2 exit 1 } if test $[uname] = Darwin { global URL := ""https://raw.githubusercontent.com/pts/staticpython/master/release.darwin/$1"" } else { global URL := ""https://raw.githubusercontent.com/pts/staticpython/master/release/$1"" } echo "info: downloading: $URL" if type -p curl >/dev/null !2 > !1 { curl -o "$1.download" $URL || exit 2 } else { wget -O "$1.download" $URL || exit 2 } chmod +x "$1.download" || exit 2 mv "$1.download" $1 || exit 2 echo "info: download OK, run with: ./$1" (CommandList children: [ (If arms: [ (if_arm cond: [ (Sentence child: (AndOr children: [ (C {(test)} {($ VSub_Pound "$#")} {(KW_Bang "!") (Lit_Other "=")} {(1)}) (C {(test)} { (DQ (BracedVarSub token: suffix_op: (PatSub pat: {(EscapedLiteralPart token:)} replace: {(SQ )} do_all: False do_prefix: False do_suffix: False ) spids: [46 51] ) ) } {(KW_Bang "!") (Lit_Other "=")} {(DQ ($ VSub_Number "$1"))} ) ] op_id: Op_DPipe ) terminator: ) ] action: [ (SimpleCommand words: [ {(echo)} { (DQ ("Usage: ") ($ VSub_Number "$0") (": {python2.7-static|stackless2.7-static|stacklessco2.7-static}") ) } ] redirects: [(Redir op_id:Redir_GreatAnd fd:-1 arg_word:{(2)} spids:[73])] ) (C {(exit)} {(1)}) ] spids: [-1 62] ) ] spids: [-1 81] ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} { (DQ (CommandSubPart command_list: (CommandList children:[(C {(uname)})]) left_token: spids: [88 90] ) ) } {(Lit_Other "=")} {(Darwin)} ) terminator: ) ] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:URL) op: Equal rhs: { (DQ ( "https://raw.githubusercontent.com/pts/staticpython/master/release.darwin/" ) ($ VSub_Number "$1") ) } spids: [101] ) ] spids: [101] ) ] spids: [-1 98] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:URL) op: Equal rhs: { (DQ ("https://raw.githubusercontent.com/pts/staticpython/master/release/") ($ VSub_Number "$1") ) } spids: [110] ) ] spids: [110] ) ] spids: [107 116] ) (C {(echo)} {(DQ ("info: downloading: ") ($ VSub_Name "$URL"))}) (If arms: [ (if_arm cond: [ (Sentence child: (SimpleCommand words: [{(type)} {(-p)} {(curl)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(/dev/null)} spids: [133] ) (Redir op_id:Redir_GreatAnd fd:2 arg_word:{(1)} spids:[136]) ] ) terminator: ) ] action: [ (AndOr children: [ (C {(curl)} {(-o)} {(DQ ($ VSub_Number "$1") (.download))} {(DQ ($ VSub_Name "$URL"))}) (C {(exit)} {(2)}) ] op_id: Op_DPipe ) ] spids: [-1 140] ) ] else_action: [ (AndOr children: [ (C {(wget)} {(-O)} {(DQ ($ VSub_Number "$1") (.download))} {(DQ ($ VSub_Name "$URL"))}) (C {(exit)} {(2)}) ] op_id: Op_DPipe ) ] spids: [162 184] ) (AndOr children: [ (C {(chmod)} {(Lit_Other "+") (x)} {(DQ ($ VSub_Number "$1") (.download))}) (C {(exit)} {(2)}) ] op_id: Op_DPipe ) (AndOr children: [ (C {(mv)} {(DQ ($ VSub_Number "$1") (.download))} {(DQ ($ VSub_Number "$1"))}) (C {(exit)} {(2)}) ] op_id: Op_DPipe ) (C {(echo)} {(DQ ("info: download OK, run with: ./") ($ VSub_Number "$1"))}) ] )