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
@@ -122,6 +123,10 @@ function is_stable(v::VersionNumber)
122123 return v. prerelease == () && v. build == ()
123124end
124125
126+ function tarball_git_tree_sha1 (tarball_path:: AbstractString )
127+ return open (Tar. tree_hash, ` $(exe7z ()) x $tarball_path -so` )
128+ end
129+
125130# Get list of tags from the Julia repo
126131function get_tags ()
127132 @info (" Probing for tag list..." )
@@ -160,6 +165,22 @@ function main(out_path)
160165 number_urls_success += 1
161166 println (stdout , " ✓" )
162167
168+ if endswith (filename, " .dmg" )
169+ kind = " archive"
170+ extension = " dmg"
171+ elseif endswith (filename, " .exe" )
172+ kind = " installer"
173+ extension = " exe"
174+ elseif endswith (filename, " .tar.gz" )
175+ kind = " archive"
176+ extension = " tar.gz"
177+ elseif endswith (filename, " .zip" )
178+ kind = " archive"
179+ extension = " zip"
180+ else
181+ error (" Unsupported file extension in filename: $(filename) " )
182+ end
183+
163184 tarball_hash_path = hit_file_cache (" $(filename) .sha256" ) do tarball_hash_path
164185 open (filepath, " r" ) do io
165186 open (tarball_hash_path, " w" ) do hash_io
@@ -169,6 +190,17 @@ function main(out_path)
169190 end
170191 tarball_hash = String (read (tarball_hash_path))
171192
193+ tarball_git_tree_hash = if extension == " tar.gz"
194+ tarball_git_tree_hash_path = hit_file_cache (" $(filename) .git-tree-sha1" ) do tree_hash_path
195+ open (tree_hash_path, " w" ) do hash_io
196+ write (hash_io, tarball_git_tree_sha1 (filepath))
197+ end
198+ end
199+ String (read (tarball_git_tree_hash_path))
200+ else
201+ nothing
202+ end
203+
172204 # Initialize overall version key, if needed
173205 if ! haskey (meta, version)
174206 meta[version] = Dict (
@@ -196,21 +228,6 @@ function main(out_path)
196228 end
197229
198230 # 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
214231 file_dict = Dict (
215232 " triplet" => triplet (platform),
216233 " os" => meta_os (platform),
@@ -222,6 +239,9 @@ function main(out_path)
222239 " extension" => extension,
223240 " url" => url,
224241 )
242+ if tarball_git_tree_hash != = nothing
243+ file_dict[" git-tree-sha1" ] = tarball_git_tree_hash
244+ end
225245 # Add in `.asc` signature content, if applicable
226246 if asc_signature != = nothing
227247 file_dict[" asc" ] = asc_signature
0 commit comments