travis-download.inc.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # common functions to get avr-gcc tools
  2. #
  3. MAKE_PACKAGE=make_4.1-6_amd64.deb
  4. WGET_FLAGS="--retry-connrefused --tries=3 --timeout=60 --continue"
  5. # download and unpack package
  6. function download_arduino()
  7. {
  8. cd $LOCAL_TOOLS_DIR
  9. # check if tools are already in place
  10. if [ -d arduino-$1/hardware/tools/avr ]; then
  11. echo "Arduino version $1 already downloaded and extracted, skipping"
  12. return
  13. fi
  14. echo "Downloading Arduino version $1"
  15. # default package extension
  16. local arduExt="tar.xz"
  17. # for packages in version <1.6 extension is .tgz
  18. local regex="1\.[05]"
  19. if [[ "$1" =~ $regex ]]; then arduExt="tgz"; fi
  20. # download package
  21. wget $WGET_FLAGS "http://downloads.arduino.cc/arduino-$1-linux64.$arduExt"
  22. if [ $? -ne 0 ]; then
  23. echo "ERROR: Can't download Arduino"
  24. rm arduino-$1-linux64.$arduExt*
  25. exit 1
  26. fi
  27. # try to check md5sum, but Arduino provide only checksums for version 1.6 and greater
  28. wget $WGET_FLAGS https://downloads.arduino.cc/arduino-$1.md5sum.txt
  29. if [ $? -eq -0 ]; then
  30. cat arduino-$1.md5sum.txt|grep "linux64"|md5sum -c
  31. if [ $? -ne 0 ]; then
  32. echo "ERROR: md5sum for downloaded Arduino doesn't match"
  33. rm arduino-$1.md5sum.txt*
  34. exit 1
  35. fi
  36. rm arduino-$1.md5sum.txt*
  37. fi
  38. # extract only avr-gcc
  39. tar xf arduino-$1-linux64.$arduExt --wildcards '*/hardware/tools/avr/'
  40. # clean up
  41. rm arduino-$1-linux64.$arduExt*
  42. }
  43. function download_make4()
  44. {
  45. cd $LOCAL_TOOLS_DIR
  46. # check for existence
  47. if [ -x usr/bin/make ]; then
  48. echo "Make already in place, skipping"
  49. return
  50. fi
  51. # download
  52. wget http://archive.ubuntu.com/ubuntu/pool/main/m/make-dfsg/$MAKE_PACKAGE
  53. if [ $? -ne 0 ]; then
  54. echo "ERROR: Can't download make4"
  55. exit 1
  56. fi
  57. # unpack
  58. dpkg-deb -x $MAKE_PACKAGE $LOCAL_TOOLS_DIR
  59. # clean up
  60. rm ${MAKE_PACKAGE}*
  61. }
  62. function download_avr_toolchain()
  63. {
  64. cd $LOCAL_TOOLS_DIR
  65. # check if tools are already in place
  66. if [ -d avr8-gnu-toolchain-linux_x86_64 ]; then
  67. echo "AVR 8-bit Toolchain already downloaded and extracted, skipping"
  68. return
  69. fi
  70. echo "Downloading AVR 8-bit Toolchain"
  71. # download package
  72. wget $WGET_FLAGS --content-disposition "https://www.microchip.com/mymicrochip/filehandler.aspx?ddocname=en605750"
  73. if [ $? -ne 0 ]; then
  74. echo "ERROR: Can't download AVR 8-bit Toolchain"
  75. rm avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz*
  76. exit 1
  77. fi
  78. # unpack
  79. tar xf avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz
  80. # clean up
  81. rm avr8-gnu-toolchain-*-linux.any.x86_64.tar.gz*
  82. }