summaryrefslogtreecommitdiff
path: root/tools/binary-repo-lib.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/binary-repo-lib.sh')
-rwxr-xr-xtools/binary-repo-lib.sh30
1 files changed, 26 insertions, 4 deletions
diff --git a/tools/binary-repo-lib.sh b/tools/binary-repo-lib.sh
index 4221e3205c..4c5497e803 100755
--- a/tools/binary-repo-lib.sh
+++ b/tools/binary-repo-lib.sh
@@ -7,6 +7,9 @@ remote_urlbase="http://typesafe.artifactoryonline.com/typesafe/scala-sha-bootstr
libraryJar="$(pwd)/lib/scala-library.jar"
desired_ext=".desired.sha1"
push_jar="$(pwd)/tools/push.jar"
+if [[ "$OSTYPE" == *Cygwin* || "$OSTYPE" == *cygwin* ]]; then push_jar="$(cygpath -m "$push_jar")"; fi
+# Cache dir has .sbt in it to line up with SBT build.
+cache_dir="${HOME}/.sbt/cache/scala"
# Checks whether or not curl is installed and issues a warning on failure.
checkCurl() {
@@ -48,7 +51,7 @@ curlDownload() {
checkCurl
local jar=$1
local url=$2
- if [[ "$OSTYPE" == *Cygwin* ]]; then
+ if [[ "$OSTYPE" == *Cygwin* || "$OSTYPE" == *cygwin* ]]; then
jar=$(cygpath -m $1)
fi
http_code=$(curl --write-out '%{http_code}' --silent --fail --output "$jar" "$url")
@@ -126,6 +129,25 @@ pushJarFiles() {
else
echo "Binary changes have been pushed. You may now submit the new *${desired_ext} files to git."
fi
+}
+
+# Pulls a single binary artifact from a remote repository.
+# Argument 1 - The uri to the file that should be downloaded.
+# Argument 2 - SHA of the file...
+# Returns: Cache location.
+pullJarFileToCache() {
+ local uri=$1
+ local sha=$2
+ local cache_loc=$cache_dir/$uri
+ local cdir=$(dirname $cache_loc)
+ if [[ ! -d $cdir ]]; then
+ mkdir -p $cdir
+ fi
+ # TODO - Check SHA of local cache is accurate.
+ if [[ ! -f $cache_loc ]]; then
+ curlDownload $cache_loc ${remote_urlbase}/${uri}
+ fi
+ echo "$cache_loc"
}
# Pulls a single binary artifact from a remote repository.
@@ -139,8 +161,9 @@ pullJarFile() {
local jar_name=${jar#$jar_dir/}
local version=${sha1% ?$jar_name}
local remote_uri=${version}/${jar#$basedir/}
- echo "Downloading from ${remote_urlbase}/${remote_uri}"
- curlDownload $jar ${remote_urlbase}/${remote_uri}
+ echo "Resolving [${remote_uri}]"
+ local cached_file=$(pullJarFileToCache $remote_uri $version)
+ cp $cached_file $jar
}
# Pulls binary artifacts from the remote repository.
@@ -152,7 +175,6 @@ pullJarFiles() {
jar=${sha%$desired_ext}
local valid=$(isJarFileValid $jar)
if [[ "$valid" != "OK" ]]; then
- echo "Obtaining [$jar] from binary repository..."
pullJarFile $jar $basedir
fi
done