2
0

getlib.sh.in 919 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/sh
  2. ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
  3. TAR=@TAR@
  4. ZCAT=@ZCAT@
  5. BZIP=@BZIP@
  6. XZ=@XZ@
  7. WGET=@WGET@
  8. CURL=@CURL@
  9. if [ -f "$WGET" ]; then
  10. DOWNLOAD_CMD=$WGET
  11. elif [ -f "$CURL" ]; then
  12. DOWNLOAD_CMD="$CURL -L -O"
  13. fi
  14. if [ -n "`echo $1 | grep '://'`" ]; then
  15. base=$1/
  16. tarfile=$2
  17. else
  18. base=http://files.freeswitch.org/downloads/libs/
  19. tarfile=$1
  20. fi
  21. uncompressed=`echo $tarfile | sed 's/\(\(\.tar\.gz\|\.tar\.bz2\|\.tar\.xz\)\|\(\.tgz\|\.tbz2\)\)$//'`
  22. case `echo $tarfile | sed 's/^.*\.//'` in
  23. bz2|tbz2) UNZIPPER=$BZIP ;;
  24. xz) UNZIPPER=$XZ ;;
  25. gz|tgz|*) UNZIPPER=$ZCAT ;;
  26. esac
  27. if [ ! -d $tarfile ]; then
  28. if [ ! -f $tarfile ]; then
  29. rm -fr $uncompressed
  30. $DOWNLOAD_CMD $base$tarfile
  31. if [ ! -f $tarfile ]; then
  32. echo cannot find $tarfile
  33. exit 1
  34. fi
  35. fi
  36. if [ ! -d $uncompressed ]; then
  37. $UNZIPPER -c -d $tarfile | $TAR -xf -
  38. fi
  39. fi
  40. exit 0