From 08a9b44b72684535524f978b7798d8cc06059ec8 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 25 Mar 2025 11:08:21 +0000 Subject: [PATCH] linux/bundle/skipper: add support for Linux casks. Don't unconditionally skip Linux casks but instead check if they are supported on Linux. --- .../extend/os/linux/bundle/skipper.rb | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/extend/os/linux/bundle/skipper.rb b/Library/Homebrew/extend/os/linux/bundle/skipper.rb index 6e1b266c66..f4bcbe28f9 100644 --- a/Library/Homebrew/extend/os/linux/bundle/skipper.rb +++ b/Library/Homebrew/extend/os/linux/bundle/skipper.rb @@ -6,17 +6,30 @@ module OS module Bundle module Skipper module ClassMethods + sig { params(entry: Homebrew::Bundle::Dsl::Entry).returns(T::Boolean) } def macos_only_entry?(entry) - [:cask, :mas].include?(entry.type) + entry.type == :mas end - def macos_only_tap?(entry) - entry.type == :tap && entry.name == "homebrew/cask" + sig { params(entry: Homebrew::Bundle::Dsl::Entry).returns(T::Boolean) } + def macos_only_cask?(entry) + return false if entry.type != :cask + + cask = ::Cask::CaskLoader.load(entry.name) + installer = ::Cask::Installer.new(cask) + installer.check_stanza_os_requirements + + true + rescue ::Cask::CaskError + false end def skip?(entry, silent: false) - if macos_only_entry?(entry) || macos_only_tap?(entry) - ::Kernel.puts Formatter.warning "Skipping #{entry.type} #{entry.name} (on Linux)" unless silent + if macos_only_entry?(entry) || macos_only_cask?(entry) + unless silent + $stdout.puts Formatter.warning "Skipping #{entry.type} #{entry.name} (unsupported on Linux)" + end + true else super(entry)