Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create and use versioned package dir by default. #5737

Merged
merged 1 commit into from
Feb 11, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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