summaryrefslogtreecommitdiff
path: root/tools/binary-repo-lib.sh
diff options
context:
space:
mode:
authorJosh Suereth <joshua.suereth@gmail.com>2012-01-25 21:33:59 -0500
committerJosh Suereth <joshua.suereth@gmail.com>2012-01-25 21:33:59 -0500
commitc94d342b385fa510882721b8b7f2070750c60f0e (patch)
treee08152b3ddc44ac0cba9e2720886d0e09acb38f9 /tools/binary-repo-lib.sh
parent40246d4a0c269fd6ffb3bd04669ff3f1cfb387d1 (diff)
downloadscala-c94d342b385fa510882721b8b7f2070750c60f0e.tar.gz
scala-c94d342b385fa510882721b8b7f2070750c60f0e.tar.bz2
scala-c94d342b385fa510882721b8b7f2070750c60f0e.zip
Added caching to binary resolution.
* Duplicated binary repo cache in ~/.sbt/cache/scala/ * Resolved to cache before copying to local dir if jar is misisng * Does *not* check SHA in cache currently
Diffstat (limited to 'tools/binary-repo-lib.sh')
-rwxr-xr-xtools/binary-repo-lib.sh27
1 files changed, 24 insertions, 3 deletions
diff --git a/tools/binary-repo-lib.sh b/tools/binary-repo-lib.sh
index 4221e3205c..3a75593f21 100755
--- a/tools/binary-repo-lib.sh
+++ b/tools/binary-repo-lib.sh
@@ -7,6 +7,8 @@ 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"
+# 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() {
@@ -126,6 +128,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 +160,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 +174,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