Skip to content

Instantly share code, notes, and snippets.

@KristofferC
Created August 26, 2016 12:46
Show Gist options
  • Save KristofferC/df418a78e3485658c1a533b66191de89 to your computer and use it in GitHub Desktop.
Save KristofferC/df418a78e3485658c1a533b66191de89 to your computer and use it in GitHub Desktop.
# Fileformat #
##############
# url to package
#
# version x <-
# ------- |
# sha1 |
# req 1 |
# req 2 |
# ... |
# req n |
# new line ----
function convert_folder(indir, outdir)
!isdir(indir) && return
open(joinpath(outdir, splitdir(indir)[end] * ".versions"), "w") do new_verfile
print(new_verfile, readchomp(joinpath(indir, "url")), "\n\n")
versions_path = joinpath(indir, "versions")
!isdir(versions_path) && return
first = true
for ver in readdir(versions_path)
!first && print(new_verfile, "\n")
first = false
ismatch(Base.VERSION_REGEX, ver) || continue
version_path = joinpath(versions_path, ver)
print(new_verfile, ver, "\n")
print(new_verfile, "-"^length(ver), "\n")
print(new_verfile, readstring(joinpath(version_path, "sha1")))
req_path = joinpath(version_path, "requires")
if isfile(req_path)
for line in readlines(req_path)
isempty(chomp(line)) && continue
print(new_verfile, line)
end
end
end
end
end
function convert_all(indir, outdir)
!isdir(outdir) && error("Invalid dir, does not exist")
for package in readdir(indir)
startswith(package, ".") && continue
convert_folder(joinpath(indir, package), outdir)
end
end
v = "v0.5"
cd(joinpath(Pkg.dir(), "..", v)) do
indir = joinpath("METADATA")
outdir = joinpath("METADATA_compressed")
!isdir(outdir) && mkdir(outdir)
convert_all(indir, outdir)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment