From 80f106b715c1296d09b6c21e03ea496f039bdfac Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Thu, 30 Jan 2014 16:47:59 -0500 Subject: [PATCH 1/2] Revert "Revert "Create and use versioned package dir by default."" This reverts commit d869093994976156c7beed631b0e87a9466288b7. --- base/pkg/cache.jl | 29 +++++++++++++++++++++++++++-- base/pkg/dir.jl | 10 ++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/base/pkg/cache.jl b/base/pkg/cache.jl index 12cb1c2072c54..537cfb76f67e7 100644 --- a/base/pkg/cache.jl +++ b/base/pkg/cache.jl @@ -3,10 +3,35 @@ module Cache import ..Git using ..Types -path(pkg::String) = abspath(".cache", pkg) +import ..Dir: pkgroot, path + +function mkcachedir() + cache = realpath(abspath(".cache")) + if isdir(cache) + return + end + + @windows_only mkdir(cache) + @unix_only begin + rootcache = realpath(joinpath(pkgroot(), ".cache")) + if rootcache == cache + mkdir(cache) + elseif isdir(rootcache) + try + ln(rootcache, cache) + catch + mkdir(cache) + end + else + mkdir(rootcache) + mkcachedir() + end + end +end + function prefetch{S<:String}(pkg::String, url::String, sha1s::Vector{S}) - isdir(".cache") || mkdir(".cache") + isdir(".cache") || mkcachedir() cache = path(pkg) if !isdir(cache) info("Cloning cache of $pkg from $url") diff --git a/base/pkg/dir.jl b/base/pkg/dir.jl index 362874e2606a1..adfb28748dc4d 100644 --- a/base/pkg/dir.jl +++ b/base/pkg/dir.jl @@ -5,13 +5,15 @@ import ..Git const DIR_NAME = ".julia" +pkgroot() = abspath(get(ENV,"JULIA_PKGDIR",joinpath(homedir(),DIR_NAME))) + function path() - b = abspath(get(ENV,"JULIA_PKGDIR",joinpath(homedir(),DIR_NAME))) + b = pkgroot() x, y = VERSION.major, VERSION.minor d = joinpath(b,"v$x.$y") - isdir(d) && return d - d = joinpath(b,"v$x") - isdir(d) && return d + if isdir(d) || !isdir(b) || !isdir(joinpath(b, "METADATA")) + return d + end return b end path(pkg::String...) = normpath(path(),pkg...) From 3dce623efa44375dd99ff35488032eeb65f36e44 Mon Sep 17 00:00:00 2001 From: Isaiah Norton Date: Thu, 30 Jan 2014 16:39:10 -0500 Subject: [PATCH 2/2] Fix Pkg.Cache paths, closes #5615 and #5612 --- base/pkg/cache.jl | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/base/pkg/cache.jl b/base/pkg/cache.jl index 537cfb76f67e7..90a29f3ae2f3c 100644 --- a/base/pkg/cache.jl +++ b/base/pkg/cache.jl @@ -3,17 +3,19 @@ module Cache import ..Git using ..Types -import ..Dir: pkgroot, path +import ..Dir: pkgroot + +path(pkg::String) = abspath(".cache", pkg) function mkcachedir() - cache = realpath(abspath(".cache")) + cache = joinpath(realpath("."), ".cache") if isdir(cache) return end @windows_only mkdir(cache) @unix_only begin - rootcache = realpath(joinpath(pkgroot(), ".cache")) + rootcache = joinpath(realpath(pkgroot()), ".cache") if rootcache == cache mkdir(cache) elseif isdir(rootcache)