Skip to content

Instantly share code, notes, and snippets.

@KristofferC
Last active August 26, 2016 12:57
Show Gist options
  • Save KristofferC/63720b50b7a93cfca82e6a98bcf1c6c9 to your computer and use it in GitHub Desktop.
Save KristofferC/63720b50b7a93cfca82e6a98bcf1c6c9 to your computer and use it in GitHub Desktop.
# Assume that we currently read a version string
function read_version(f::IO)
version = chomp(readline(f))
@assert ismatch(Base.VERSION_REGEX, version)
readline(f) # skip underlined version
sha = chomp(readline(f))
requires = String[]
while !eof(f)
line = chomp(readline(f))
isempty(line) && break
push!(requires, line)
end
return version, sha, requires
end
using Base.Pkg.Types
import Base.Pkg.Reqs
function available(path = "METADATA_compressed")
pkgs = Dict{String,Dict{VersionNumber,Available}}()
for pkg in readdir(path)
!endswith(pkg, ".versions") && continue
pkg_name = split(pkg, ".version")[1]
f = open(joinpath(path, pkg), "r")
url = chomp(readline(f))
readline(f)
while !eof(f)
ver, sha, requires = read_version(f)
haskey(pkgs, pkg_name) || (pkgs[pkg_name] = Dict{VersionNumber,Available}())
pkgs[pkg_name][convert(VersionNumber, ver)] = Available(sha, Reqs.parse(requires))
end
end
return pkgs
end
v = "v0.5"
cd(joinpath(Pkg.dir(), "..", v)) do
@time available()
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment