get-prebuilt-packages.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/env bash
  2. # get-prebuilt-packages.sh v1.10 (c)2016-2024 Henri Beauchamp.
  3. # Released under the GPL (v2 or later, at your convenience) License:
  4. # http://www.gnu.org/copyleft/gpl.html
  5. script=`readlink -f "$0" || echo "$0"`
  6. cd `dirname "$script" || echo .`
  7. cd ..
  8. if echo "$*" | grep "\-h" &>/dev/null ; then
  9. echo "This script allows to download the pre-built library packages used to build"
  10. echo "the Cool VL Viewer, thus ensuring you will be able to build it even after"
  11. echo "the packages would be pulled off from the corresponding sites (simply place"
  12. echo "the downloaded packages inside the temporary directory where the build system"
  13. echo "normally stores them)."
  14. echo "Usage: $0 [-s]|[-f]|[-c]|[-l]|[-m]|[-w][-t]|[-h|--help]]"
  15. echo "With: -s : skip packages from Second Life sites."
  16. echo " -c : skip packages from Cool VL Viewer site (sldev.free.fr)."
  17. echo " -l : skip Linux packages."
  18. echo " -m : skip MacOS-X packages."
  19. echo " -w : skip Windows packages."
  20. echo " -t : downloads go into /var/tmp$HOME/install.cache/"
  21. echo " -h, --help : this help..."
  22. echo "Unless the -t option is specified, the packages will be downloaded into a"
  23. echo "'prebuilt-packages' directory that will be created (if not already present)"
  24. echo "inside the sources tree."
  25. exit 0
  26. fi
  27. if ! [ -f install.xml ] ; then
  28. echo "This script shall be ran from the sources tree of the Cool VL Viewer !"
  29. exit 1
  30. fi
  31. if ! which curl &>/dev/null ; then
  32. echo "Could not find curl !"
  33. exit 1
  34. fi
  35. NOGREP1A="xxxxx"
  36. NOGREP1B="xxxxx"
  37. NOGREP2="xxxxx"
  38. NOGREP3="xxxxx"
  39. NOGREP4="xxxxx"
  40. NOGREP5="xxxxx"
  41. if echo "$*" | grep "\-s" &>/dev/null ; then
  42. NOGREP1A="amazonaws\.com"
  43. NOGREP1B="github\.com"
  44. fi
  45. if echo "$*" | grep "\-c" &>/dev/null ; then
  46. NOGREP2="sldev\.free\.fr"
  47. fi
  48. if echo "$*" | grep "\-l" &>/dev/null ; then
  49. NOGREP3="\-linux"
  50. fi
  51. if echo "$*" | grep "\-m" &>/dev/null ; then
  52. NOGREP4="\-darwin"
  53. fi
  54. if echo "$*" | grep "\-w" &>/dev/null ; then
  55. NOGREP5="\-win"
  56. fi
  57. files=`grep '\<uri\>' install.xml | grep -v "$NOGREP1A" | grep -v "$NOGREP1B" | grep -v "$NOGREP2" | grep -v "$NOGREP3" | grep -vi "$NOGREP4" | grep -vi "$NOGREP5" | sort | uniq | sed -e 's/ //g' -e 's/<uri>//' -e 's:</uri>::'`
  58. if [ "$files" == "" ] ; then
  59. echo "Nothing to download..."
  60. exit 0
  61. fi
  62. DEST="prebuilt-packages"
  63. if echo "$*" | grep "\-t" &>/dev/null ; then
  64. DEST="/var/tmp$HOME/install.cache"
  65. fi
  66. mkdir -p $DEST
  67. if ! [ -d "$DEST" ] ; then
  68. echo "Cannot create directory $DEST !"
  69. exit 1
  70. fi
  71. cd $DEST
  72. for i in $files ; do
  73. echo "-------------------------------------------------------------------------------"
  74. echo "Downloading: $i"
  75. curl -O "$i"
  76. if [ "$?" != "0" ] ; then
  77. echo "Failed to download: $i"
  78. fi
  79. done
  80. echo "-------------------------------------------------------------------------------"
  81. echo "Done !"