Skip to content

Commit

Permalink
use curl with retry option and prepend Travis-CI to curl's user-agent
Browse files Browse the repository at this point in the history
- the user-agent helps us to distinguish automated
  downloads from real user downloads
  • Loading branch information
MartinNowak committed Dec 8, 2014
1 parent a4d8b27 commit 43286a1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions lib/travis/build/script/d.rb
Expand Up @@ -26,32 +26,33 @@ def setup
sh.fold("compiler-download") do sh.fold("compiler-download") do
sh.echo "Installing compiler and dub", ansi: :yellow sh.echo "Installing compiler and dub", ansi: :yellow


sh.cmd 'alias curl="curl -fsSL --retry 3 -A \'Travis-CI $(curl --version | head -n 1)\'"'
case compiler_cmd case compiler_cmd
when 'dmd' when 'dmd'
binpath, libpath = {'linux' => ['dmd2/linux/bin64', 'dmd2/linux/lib64'], binpath, libpath = {'linux' => ['dmd2/linux/bin64', 'dmd2/linux/lib64'],
'osx' => ['dmd2/linux/bin', 'dmd2/linux/lib']}[os] 'osx' => ['dmd2/linux/bin', 'dmd2/linux/lib']}[os]


sh.cmd "curl -fsSL #{compiler_url} > ~/dmd.zip" sh.cmd "curl #{compiler_url} > ~/dmd.zip"
sh.cmd "unzip -q -d ~ ~/dmd.zip" sh.cmd "unzip -q -d ~ ~/dmd.zip"
when 'ldc2' when 'ldc2'
binpath, libpath = 'ldc/bin', 'ldc/lib' binpath, libpath = 'ldc/bin', 'ldc/lib'


sh.cmd "mkdir ${HOME}/ldc", echo: false sh.cmd "mkdir ${HOME}/ldc", echo: false
sh.cmd "curl -fsSL #{compiler_url} | tar --strip-components=1 -C ~/ldc -Jxf -" sh.cmd "curl #{compiler_url} | tar --strip-components=1 -C ~/ldc -Jxf -"
when 'gdc' when 'gdc'
binpath, libpath = 'gdc/bin', 'gdc/lib' binpath, libpath = 'gdc/bin', 'gdc/lib'


sh.cmd "mkdir ${HOME}/gdc", echo: false sh.cmd "mkdir ${HOME}/gdc", echo: false
sh.cmd "curl -fsSL #{compiler_url} | tar --strip-components=1 -C ~/gdc -Jxf -" sh.cmd "curl #{compiler_url} | tar --strip-components=1 -C ~/gdc -Jxf -"
sh.cmd 'curl -fsSL https://raw.githubusercontent.com/D-Programming-GDC/GDMD/master/dmd-script > '+ sh.cmd 'curl https://raw.githubusercontent.com/D-Programming-GDC/GDMD/master/dmd-script > '+
"~/#{binpath}/gdmd && chmod +x ~/#{binpath}/gdmd" "~/#{binpath}/gdmd && chmod +x ~/#{binpath}/gdmd"
end end


sh.cmd 'LATEST_DUB=$('+ sh.cmd 'LATEST_DUB=$('+
'curl -fsSL https://api.github.com/repos/D-Programming-Language/dub/tags | '+ 'curl https://api.github.com/repos/D-Programming-Language/dub/tags | '+
'sed -n \'s|.*"name": "v\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)".*|\1|p\' |'+ 'sed -n \'s|.*"name": "v\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)".*|\1|p\' |'+
'sort | tail -n 1)', echo: false 'sort | tail -n 1)', echo: false
sh.cmd "curl -fsSL http://code.dlang.org/files/dub-${LATEST_DUB}-#{os}-x86_64.tar.gz | tar -C ~/#{binpath} -xzf -" sh.cmd "curl http://code.dlang.org/files/dub-${LATEST_DUB}-#{os}-x86_64.tar.gz | tar -C ~/#{binpath} -xzf -"
sh.cmd "export PATH=\"${HOME}/#{binpath}:${PATH}\"" sh.cmd "export PATH=\"${HOME}/#{binpath}:${PATH}\""
sh.cmd "export LD_LIBRARY_PATH=\"${HOME}/#{libpath}:${LD_LIBRARY_PATH}\"" sh.cmd "export LD_LIBRARY_PATH=\"${HOME}/#{libpath}:${LD_LIBRARY_PATH}\""
end end
Expand Down

0 comments on commit 43286a1

Please sign in to comment.