Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. using Pkg, LibGit2, CredentialsHandler
  2.  
  3. function update_registry(name)
  4. tmpdir = mktempdir()
  5. tmpfile = joinpath(tmpdir, "tmp.tar.gz")
  6. CredentialsHandler.download("$(ENV["JULIA_PKG_SERVER"])/$(name).tar.gz", tmpfile)
  7. @info "Downloaded Registry tmp at ", tmpfile
  8. dest = joinpath(Pkg.depots1(), "registries")
  9. @static if Sys.iswindows()
  10. run(`$(joinpath(Sys.BINDIR, "7z.exe")) x -y $(tmpfile) -o$(tmpdir) -r`)
  11. run(`$(joinpath(Sys.BINDIR, "7z.exe")) x -y $(tmpfile[1:end-3]) -o$(tmpdir) -r`)
  12. else
  13. run(`tar -xzf $tmpfile -C $(tmpdir)`)
  14. end
  15.  
  16. @info "Extraction successfull ?", isdir(joinpath(tmpdir, name))
  17.  
  18. @info "Removing dest registry if exists ", joinpath(dest,name)
  19. isdir(joinpath(dest,name)) && rm(joinpath(dest,name), force = true, recursive = true)
  20.  
  21. @info "Copying registry to ", joinpath(dest,name)
  22. cp(joinpath(tmpdir, name), joinpath(dest,name))
  23.  
  24. @info "Removing temp registry at ", joinpath(tmpdir,name)
  25. rm(joinpath(tmpdir,name), force = true, recursive = true)
  26.  
  27. @info "Setting remote..."
  28. try
  29. repo = LibGit2.init(normpath(joinpath(DEPOT_PATH[1],"registries",name)))
  30. LibGit2.set_remote_url(repo, "origin", ENV["JULIA_PKG_SERVER"]*"/registry/$name")
  31. catch ex
  32. @warn "Setting remote failed", ex
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement