|
299 | 299 | @__stdin = $stdin.clone |
300 | 300 |
|
301 | 301 | # Link original API cache files to test cache directory. |
302 | | - Pathname("#{ENV.fetch("HOMEBREW_CACHE")}/api").glob("*.json").each do |path| |
303 | | - FileUtils.ln_s path, HOMEBREW_CACHE/"api/#{path.basename}" |
| 302 | + source_api_cache = Pathname("#{ENV.fetch("HOMEBREW_CACHE")}/api") |
| 303 | + |
| 304 | + source_api_cache.glob("*.json").each do |path| |
| 305 | + target = HOMEBREW_CACHE/"api/#{path.basename}" |
| 306 | + FileUtils.ln_s path, target unless target.exist? |
304 | 307 | end |
305 | | - Pathname("#{ENV.fetch("HOMEBREW_CACHE")}/api").glob("*.txt").each do |path| |
306 | | - FileUtils.cp path, HOMEBREW_CACHE/"api/#{path.basename}" |
| 308 | + source_api_cache.glob("*.txt").each do |path| |
| 309 | + target = HOMEBREW_CACHE/"api/#{path.basename}" |
| 310 | + FileUtils.cp path, target unless target.exist? |
307 | 311 | end |
308 | | - Pathname("#{ENV.fetch("HOMEBREW_CACHE")}/api/internal").glob("*.{json,txt}").each do |path| |
309 | | - target = HOMEBREW_CACHE/"api/internal/#{path.basename}" |
310 | | - target.dirname.mkpath |
| 312 | + |
| 313 | + source_api_internal_cache = source_api_cache/"internal" |
| 314 | + target_api_internal_cache = HOMEBREW_CACHE/"api/internal" |
| 315 | + target_api_internal_cache.mkpath |
| 316 | + |
| 317 | + # The real cache can hold package API files for multiple OS tags. Fan out |
| 318 | + # from one source so generated test-cache aliases do not collide. |
| 319 | + package_paths = source_api_internal_cache.glob("packages.*.jws.json") |
| 320 | + package_path = package_paths.find do |path| |
| 321 | + path.basename.to_s == "packages.#{Homebrew::SimulateSystem.current_tag}.jws.json" |
| 322 | + end || package_paths.first |
| 323 | + |
| 324 | + source_api_internal_cache.glob("*.{json,txt}").each do |path| |
| 325 | + next if path.basename.to_s.start_with?("packages.") |
| 326 | + |
| 327 | + target = target_api_internal_cache/path.basename |
| 328 | + next if target.exist? |
| 329 | + |
311 | 330 | (path.extname == ".txt") ? FileUtils.cp(path, target) : FileUtils.ln(path, target) |
312 | | - next unless path.basename.to_s.start_with?("packages.") |
| 331 | + end |
313 | 332 |
|
| 333 | + if package_path |
314 | 334 | [:generic, :linux, :macos, *MacOSVersion::SYMBOLS.keys].product([:arm, :intel]).each do |system, arch| |
315 | 335 | tag = Utils::Bottles::Tag.new(system:, arch:) |
316 | 336 | next unless tag.valid_combination? |
317 | 337 |
|
318 | | - target = HOMEBREW_CACHE/"api/internal/packages.#{tag}.jws.json" |
319 | | - FileUtils.ln path, target unless target.exist? |
| 338 | + target = target_api_internal_cache/"packages.#{tag}.jws.json" |
| 339 | + FileUtils.ln package_path, target unless target.exist? |
320 | 340 | end |
321 | 341 | end |
322 | 342 |
|
|
0 commit comments