| # Download a tarball from the specified URL to the specified target |
| # directory, untar it, and remove the tarball file. |
| # Usage: download.sh <url> <target_dir> |
| # <url> is the URL of the repository to download, in gzipped tarball format |
| # <target_dir> is the local name to call the untarred directory. The |
| # tarball will be downloaded to the directory above this, |
| # untarred while renaming to <target_dir>, and then the tarball |
| # Neither curl or wget are guaranteed to be included in all *nix systems, |
| # (but most have *one* of them). This tools tries its best to find one. |
| if type "wget" > /dev/null; then |
| if type "curl" > /dev/null; then |
| if [ "$DL_CMD" = "" ]; then |
| echo "ERROR: Either curl or wget are required to automatically install tools." |
| echo "Downloading $1 to $2" |
| tar -xf $2.tar.gz --strip-components 1 -C $2 |