diff --git a/Library/Homebrew/cask/artifact.rb b/Library/Homebrew/cask/artifact.rb index 02b1298b55..abaaeb0ccd 100644 --- a/Library/Homebrew/cask/artifact.rb +++ b/Library/Homebrew/cask/artifact.rb @@ -2,6 +2,7 @@ # frozen_string_literal: true require "cask/artifact/app" +require "cask/artifact/appimage" require "cask/artifact/artifact" # generic 'artifact' stanza require "cask/artifact/audio_unit_plugin" require "cask/artifact/binary" diff --git a/Library/Homebrew/cask/artifact/appimage.rb b/Library/Homebrew/cask/artifact/appimage.rb new file mode 100644 index 0000000000..cb934e7b29 --- /dev/null +++ b/Library/Homebrew/cask/artifact/appimage.rb @@ -0,0 +1,15 @@ +# typed: strict +# frozen_string_literal: true + +require "cask/artifact/symlinked" + +module Cask + module Artifact + class AppImage < Symlinked + sig { params(target: T.any(String, Pathname)).returns(Pathname) } + def resolve_target(target) + config.appimagedir/target + end + end + end +end diff --git a/Library/Homebrew/cask/config.rb b/Library/Homebrew/cask/config.rb index 68b0f91e95..cb4a21445c 100644 --- a/Library/Homebrew/cask/config.rb +++ b/Library/Homebrew/cask/config.rb @@ -15,6 +15,7 @@ module Cask DEFAULT_DIRS = T.let( { appdir: "/Applications", + appimagedir: "~/Applications", keyboard_layoutdir: "/Library/Keyboard Layouts", colorpickerdir: "~/Library/ColorPickers", prefpanedir: "~/Library/PreferencePanes", @@ -47,6 +48,7 @@ module Cask args = T.unsafe(args) new(explicit: { appdir: args.appdir, + appimagedir: args.appimagedir, keyboard_layoutdir: args.keyboard_layoutdir, colorpickerdir: args.colorpickerdir, prefpanedir: args.prefpanedir, diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index 22a55c4f1f..cf6e53b46c 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -34,6 +34,7 @@ module Cask ORDINARY_ARTIFACT_CLASSES = [ Artifact::Installer, Artifact::App, + Artifact::AppImage, Artifact::Artifact, Artifact::AudioUnitPlugin, Artifact::Binary, diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 9d6e4b3314..0cad1e9e29 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -63,6 +63,10 @@ module Homebrew description: "Target location for Applications " \ "(default: `#{Cask::Config::DEFAULT_DIRS[:appdir]}`).", }], + [:flag, "--appimagedir=", { + description: "Target location for AppImages " \ + "(default: `#{Cask::Config::DEFAULT_DIRS[:appimagedir]}`).", + }], [:flag, "--keyboard-layoutdir=", { description: "Target location for Keyboard Layouts " \ "(default: `#{Cask::Config::DEFAULT_DIRS[:keyboard_layoutdir]}`).", diff --git a/Library/Homebrew/extend/os/cask/installer.rb b/Library/Homebrew/extend/os/cask/installer.rb index a7a6e0c277..f435378b2a 100644 --- a/Library/Homebrew/extend/os/cask/installer.rb +++ b/Library/Homebrew/extend/os/cask/installer.rb @@ -2,3 +2,4 @@ # frozen_string_literal: true require "extend/os/linux/cask/installer" if OS.linux? +require "extend/os/mac/cask/installer" if OS.mac? diff --git a/Library/Homebrew/extend/os/mac/cask/installer.rb b/Library/Homebrew/extend/os/mac/cask/installer.rb new file mode 100644 index 0000000000..6e4076a656 --- /dev/null +++ b/Library/Homebrew/extend/os/mac/cask/installer.rb @@ -0,0 +1,29 @@ +# typed: strict +# frozen_string_literal: true + +module OS + module Mac + module Cask + module Installer + extend T::Helpers + + requires_ancestor { ::Cask::Installer } + + MAC_INVALID_ARTIFACTS = [ + ::Cask::Artifact::AppImage, + ].freeze + + sig { void } + def check_stanza_os_requirements + return unless artifacts.any? do |artifact| + MAC_INVALID_ARTIFACTS.include?(artifact.class) + end + + raise ::Cask::CaskError, "Linux is required for this software." + end + end + end + end +end + +Cask::Installer.prepend(OS::Mac::Cask::Installer)