11module VersionsJSONUtil
22
3- using HTTP, JSON, Pkg. BinaryPlatforms, WebCacheUtilities, SHA, Lazy
3+ using HTTP, JSON, Pkg. BinaryPlatforms, WebCacheUtilities, SHA, Lazy, Tar
44import Pkg. BinaryPlatforms: triplet, arch
5+ import Pkg. PlatformEngines: exe7z
56
67" Wrapper types to define three jlext methods for portable, tarball and installer Windows"
78struct WindowsPortable
@@ -109,6 +110,11 @@ julia_platforms = [
109110 FreeBSD (:x86_64 ),
110111]
111112
113+ const tarball_git_tree_sha1_skiplist = [
114+ # Corrupt gzip stream: `7z` reports a CRC failure for the embedded tarball.
115+ " https://julialang-s3.julialang.org/bin/linux/x86/0.7/julia-0.7.0-alpha-linux-i686.tar.gz" ,
116+ ]
117+
112118function vnum_maybe (x:: AbstractString )
113119 try
114120 return VersionNumber (x)
@@ -122,6 +128,10 @@ function is_stable(v::VersionNumber)
122128 return v. prerelease == () && v. build == ()
123129end
124130
131+ function tarball_git_tree_sha1 (tarball_path:: AbstractString )
132+ return open (Tar. tree_hash, ` $(exe7z ()) x $tarball_path -so` )
133+ end
134+
125135# Get list of tags from the Julia repo
126136function get_tags ()
127137 @info (" Probing for tag list..." )
@@ -160,6 +170,22 @@ function main(out_path)
160170 number_urls_success += 1
161171 println (stdout , " ✓" )
162172
173+ if endswith (filename, " .dmg" )
174+ kind = " archive"
175+ extension = " dmg"
176+ elseif endswith (filename, " .exe" )
177+ kind = " installer"
178+ extension = " exe"
179+ elseif endswith (filename, " .tar.gz" )
180+ kind = " archive"
181+ extension = " tar.gz"
182+ elseif endswith (filename, " .zip" )
183+ kind = " archive"
184+ extension = " zip"
185+ else
186+ error (" Unsupported file extension in filename: $(filename) " )
187+ end
188+
163189 tarball_hash_path = hit_file_cache (" $(filename) .sha256" ) do tarball_hash_path
164190 open (filepath, " r" ) do io
165191 open (tarball_hash_path, " w" ) do hash_io
@@ -169,6 +195,17 @@ function main(out_path)
169195 end
170196 tarball_hash = String (read (tarball_hash_path))
171197
198+ tarball_git_tree_hash = if extension == " tar.gz" && ! (url in tarball_git_tree_sha1_skiplist)
199+ tarball_git_tree_hash_path = hit_file_cache (" $(filename) .git-tree-sha1" ) do tree_hash_path
200+ open (tree_hash_path, " w" ) do hash_io
201+ write (hash_io, tarball_git_tree_sha1 (filepath))
202+ end
203+ end
204+ String (read (tarball_git_tree_hash_path))
205+ else
206+ nothing
207+ end
208+
172209 # Initialize overall version key, if needed
173210 if ! haskey (meta, version)
174211 meta[version] = Dict (
@@ -196,21 +233,6 @@ function main(out_path)
196233 end
197234
198235 # Build up metadata about this file
199- if endswith (filename, " .dmg" )
200- kind = " archive"
201- extension = " dmg"
202- elseif endswith (filename, " .exe" )
203- kind = " installer"
204- extension = " exe"
205- elseif endswith (filename, " .tar.gz" )
206- kind = " archive"
207- extension = " tar.gz"
208- elseif endswith (filename, " .zip" )
209- kind = " archive"
210- extension = " zip"
211- else
212- error (" Unsupported file extension in filename: $(filename) " )
213- end
214236 file_dict = Dict (
215237 " triplet" => triplet (platform),
216238 " os" => meta_os (platform),
@@ -222,6 +244,9 @@ function main(out_path)
222244 " extension" => extension,
223245 " url" => url,
224246 )
247+ if tarball_git_tree_hash != = nothing
248+ file_dict[" git-tree-sha1" ] = tarball_git_tree_hash
249+ end
225250 # Add in `.asc` signature content, if applicable
226251 if asc_signature != = nothing
227252 file_dict[" asc" ] = asc_signature
0 commit comments