Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created October 22, 2011 10:39
Show Gist options
  • Select an option

  • Save v6ak/1305856 to your computer and use it in GitHub Desktop.

Select an option

Save v6ak/1305856 to your computer and use it in GitHub Desktop.
#Oracle #JDK|#JRE #fetch #tool for #Gentoo
#!/bin/bash
# input URLs: e.g.: http://www.oracle.com/technetwork/java/javase/downloads/jre-7u1-download-513652.html
# (!) By using this script, you accept some license agreements automatically!
URL_REGEXP='http\:\/\/([a-z0-9]+)(\.[a-z0-9]+)*\/(([0-9a-zA-Z\./]|-)+)'
if [ "$#" == "0" ]; then # no URL given => get them from emerge
echo Getting URLs from emerge...
java_packages=$(grep -E '(sun|oracle)-(jre|jdk)' /var/lib/portage/world)
urls=$(
emerge -uf -- $java_packages 2>&1 | grep -o -E "$URL_REGEXP"
)
else # use given urls
urls=$*
fi
os=$(uname | tr "[:upper:]" "[:lower:]")
machine=$(uname -m | sed s/x86_64/x64/)
echo "Your system: $os-$machine"
echo "Downloading..."
for url in $urls; do # fetch all
wget --continue --directory-prefix "/usr/portage/distfiles/" -- $(
wget -nv -O - -- "$url" | grep -- "$os-$machine.tar.gz" | grep -o -E "$URL_REGEXP" # grep the location
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment