@@ -3,6 +3,7 @@ import GitHub: gh_get_json, DEFAULT_API
3
3
import SHA: sha256
4
4
using Pkg. TOML, Dates
5
5
using RegistryTools, Registrator
6
+ import LibGit2
6
7
7
8
"""
8
9
build_tarballs(ARGS, src_name, src_version, sources, script, platforms,
@@ -420,21 +421,38 @@ function download_sources(sources::Vector; verbose::Bool = false)
420
421
return output_sources
421
422
end
422
423
424
+ function _registered_packages (registry_url:: AbstractString )
425
+ tmp_dir = mktempdir ()
426
+ atexit (() -> rm (tmp_dir; force = true , recursive = true ))
427
+ registry_dir = joinpath (tmp_dir, " REGISTRY" )
428
+ LibGit2. clone (registry_url, registry_dir)
429
+ registry = TOML. parsefile (joinpath (registry_dir, " Registry.toml" ))
430
+ packages = Vector {String} (undef, 0 )
431
+ for p in registry[" packages" ]
432
+ push! (packages, p[2 ][" name" ])
433
+ end
434
+ rm (tmp_dir; force = true , recursive = true )
435
+ return packages
436
+ end
437
+
438
+ function _package_is_registered (registry_url:: AbstractString ,
439
+ package:: AbstractString )
440
+ registered_packages = _registered_packages (registry_url)
441
+ return package in registered_packages
442
+ end
443
+
423
444
function register_jll (name, build_version, dependencies;
424
445
deploy_repo= " JuliaBinaryWrappers/$(name) _jll.jl" ,
425
446
code_dir= joinpath (Pkg. devdir (), " $(name) _jll" ),
426
447
gh_auth= github_auth (;allow_anonymous= false ),
427
448
gh_username= gh_get_json (DEFAULT_API, " /user" ; auth= gh_auth)[" login" ])
428
- # Create fork (if it does not already exist)
429
- fork = GitHub. create_fork (" JuliaRegistries/General" ; auth= gh_auth)
430
-
431
449
# Calculate tree hash of wrapper code
432
450
wrapper_tree_hash = bytes2hex (Pkg. GitTools. tree_hash (code_dir))
433
451
434
452
# Use RegistryTools to push up a new `General` branch with this JLL package registered within it
435
453
# TODO : Update our fork periodically from upstream `General`.
436
454
cache = RegistryTools. RegistryCache (joinpath (Pkg. depots1 (), " registries_binarybuilder" ))
437
- registry_url = " https://$(gh_username) :$(gh_auth. token) @github.com/$(gh_username) /General"
455
+ registry_url = " https://$(gh_username) :$(gh_auth. token) @github.com/JuliaRegistries /General"
438
456
cache. registries[registry_url] = Base. UUID (" 23338594-aafe-5451-b93e-139f81909106" )
439
457
project = Pkg. Types. Project (build_project_dict (name, build_version, dependencies))
440
458
reg_branch = RegistryTools. register (
@@ -448,12 +466,19 @@ function register_jll(name, build_version, dependencies;
448
466
if haskey (reg_branch. metadata, " error" )
449
467
@error (reg_branch. metadata[" error" ])
450
468
else
469
+ upstream_registry_url = " https://github.com/JuliaRegistries/General"
470
+ name_jll = " $(name) _jll"
471
+ if _package_is_registered (upstream_registry_url, name_jll)
472
+ pr_title = " New version: $(name_jll) v$(build_version) "
473
+ else
474
+ pr_title = " New package: $(name_jll) v$(build_version) "
475
+ end
451
476
# Open pull request against JuliaRegistries/General
452
477
params = Dict (
453
478
" base" => " master" ,
454
- " head" => " $(gh_username) : $( reg_branch. branch)" ,
479
+ " head" => " $(reg_branch. branch) " ,
455
480
" maintainer_can_modify" => true ,
456
- " title" => " JLL Registration: $(deploy_repo) -v $(build_version) " ,
481
+ " title" => pr_title ,
457
482
" body" => """
458
483
Autogenerated JLL package registration
459
484
0 commit comments