Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Library/Homebrew/cask/artifact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -54,6 +55,8 @@ module Artifact
::Cask::Artifact::Vst3Plugin,
].freeze

LINUX_ONLY_ARTIFACTS = T.let([].freeze, T::Array[T.untyped])
LINUX_ONLY_ARTIFACTS = [
::Cask::Artifact::AppImage,
].freeze
end
end
15 changes: 15 additions & 0 deletions Library/Homebrew/cask/artifact/appimage.rb
Original file line number Diff line number Diff line change
@@ -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)
Pathname.new("#{config.appimagedir}/#{target}")
end
end
end
end
4 changes: 2 additions & 2 deletions Library/Homebrew/cask/cask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,11 @@ def supports_linux?

# Cache the os value before contains_os_specific_artifacts? refreshes the cask
# (the refresh clears @dsl.os in generic/non-OS-specific contexts)
os_value = @dsl.os
on_system_blocks_exist = @dsl.on_system_blocks_exist?

return false if contains_os_specific_artifacts?

os_value.present?
on_system_blocks_exist
end

sig { returns(T::Boolean) }
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/cask/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Config
DEFAULT_DIRS = T.let(
{
appdir: "/Applications",
appimagedir: "~/Applications",
keyboard_layoutdir: "/Library/Keyboard Layouts",
colorpickerdir: "~/Library/ColorPickers",
prefpanedir: "~/Library/PreferencePanes",
Expand Down Expand Up @@ -49,6 +50,7 @@ def self.from_args(args)
args = T.unsafe(args)
new(explicit: {
appdir: args.appdir,
appimagedir: args.appimagedir,
keyboard_layoutdir: args.keyboard_layoutdir,
colorpickerdir: args.colorpickerdir,
prefpanedir: args.prefpanedir,
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/cask/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class DSL
ORDINARY_ARTIFACT_CLASSES = [
Artifact::Installer,
Artifact::App,
Artifact::AppImage,
Artifact::Artifact,
Artifact::AudioUnitPlugin,
Artifact::Binary,
Expand Down
4 changes: 4 additions & 0 deletions Library/Homebrew/cli/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def self.global_cask_options
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]}`).",
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/extend/os/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
30 changes: 30 additions & 0 deletions Library/Homebrew/extend/os/mac/cask/installer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# typed: strict
# frozen_string_literal: true

module OS
module Mac
module Cask
module Installer
extend T::Helpers

requires_ancestor { ::Cask::Installer }

sig { void }
def check_stanza_os_requirements
return if artifacts.all? { |artifact| supported_artifact?(artifact) }

raise ::Cask::CaskError, "Linux is required for this software."
end

private

sig { params(artifact: ::Cask::Artifact::AbstractArtifact).returns(T::Boolean) }
def supported_artifact?(artifact)
::Cask::Artifact::LINUX_ONLY_ARTIFACTS.exclude?(artifact.class)
end
end
end
end
end

Cask::Installer.prepend(OS::Mac::Cask::Installer)
3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/cask/cask.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/cask/config.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/install_cmd.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/reinstall.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Library/Homebrew/sorbet/rbi/dsl/homebrew/cmd/upgrade_cmd.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading