Skip to content

Commit

Permalink
Merge pull request #5737 from JuliaLang/kms/versioned_pkg_dir_julia0.2
Browse files Browse the repository at this point in the history
Create and use versioned package dir by default.
  • Loading branch information
kmsquire committed Feb 11, 2014
2 parents 1db2f80 + 647460a commit 6bdd2a8
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ Miscellaneous changes
* `julia-release-*` executables renamed to `julia-*`,
and `libjulia-release` renamed to `libjulia` ([#4177]).

* Packages will now be installed in `.julia/vX.Y`, where
X.Y is the current Julia version.

Bugfixes and performance updates
--------------------------------

Expand Down
26 changes: 24 additions & 2 deletions base/pkg/cache.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
module Cache

using Base.Git, ..Types
import Base.Git, ..Dir
using ..Types

path(pkg::String) = abspath(".cache", pkg)

function mkcachedir()
cache = joinpath(realpath("."), ".cache")
if isdir(cache)
return
end

@windows_only mkdir(cache)
@unix_only begin
if Dir.isversioned(pwd())
rootcache = joinpath(realpath(".."), ".cache")
if !isdir(rootcache)
mkdir(rootcache)
end
run(`ln -s $rootcache $cache`)
return
end
mkdir(cache)
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")
Expand Down
11 changes: 7 additions & 4 deletions base/pkg/dir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import ..Pkg: DEFAULT_META, META_BRANCH

const DIR_NAME = ".julia"

_pkgroot() = abspath(get(ENV,"JULIA_PKGDIR",joinpath(homedir(),DIR_NAME)))
isversioned(p::String) = ((x,y) = (VERSION.major, VERSION.minor); basename(p) == "v$x.$y")

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...)
Expand Down

0 comments on commit 6bdd2a8

Please sign in to comment.