Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Pkg, LibGit2, CredentialsHandler
- function update_registry(name)
- tmpdir = mktempdir()
- tmpfile = joinpath(tmpdir, "tmp.tar.gz")
- CredentialsHandler.download("$(ENV["JULIA_PKG_SERVER"])/$(name).tar.gz", tmpfile)
- @info "Downloaded Registry tmp at ", tmpfile
- dest = joinpath(Pkg.depots1(), "registries")
- @static if Sys.iswindows()
- run(`$(joinpath(Sys.BINDIR, "7z.exe")) x -y $(tmpfile) -o$(tmpdir) -r`)
- run(`$(joinpath(Sys.BINDIR, "7z.exe")) x -y $(tmpfile[1:end-3]) -o$(tmpdir) -r`)
- else
- run(`tar -xzf $tmpfile -C $(tmpdir)`)
- end
- @info "Extraction successfull ?", isdir(joinpath(tmpdir, name))
- @info "Removing dest registry if exists ", joinpath(dest,name)
- isdir(joinpath(dest,name)) && rm(joinpath(dest,name), force = true, recursive = true)
- @info "Copying registry to ", joinpath(dest,name)
- cp(joinpath(tmpdir, name), joinpath(dest,name))
- @info "Removing temp registry at ", joinpath(tmpdir,name)
- rm(joinpath(tmpdir,name), force = true, recursive = true)
- @info "Setting remote..."
- try
- repo = LibGit2.init(normpath(joinpath(DEPOT_PATH[1],"registries",name)))
- LibGit2.set_remote_url(repo, "origin", ENV["JULIA_PKG_SERVER"]*"/registry/$name")
- catch ex
- @warn "Setting remote failed", ex
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement