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
34 changes: 34 additions & 0 deletions Library/Homebrew/cask/artifact/appimage.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# 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

sig {
override.params(
force: T::Boolean,
adopt: T::Boolean,
command: T.class_of(SystemCommand),
_options: T.anything,
).void
}
def link(force: false, adopt: false, command: SystemCommand, **_options)
super
return if source.executable?

if source.writable?
FileUtils.chmod "+x", source
else
command.run!("chmod", args: ["+x", source], sudo: true)
end
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 @@ -216,12 +216,12 @@ 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?

# Casks with OS-specific blocks rely on the os stanza for Linux support
return os_value.present? if dsl!.on_os_blocks_exist?
return on_system_blocks_exist.present? if dsl!.on_system_blocks_exist?

# Platform-agnostic casks: reject macOS-only artifacts and manual installers
artifacts.none? do |a|
Expand Down
1 change: 1 addition & 0 deletions Library/Homebrew/cask/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,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 @@ -37,6 +37,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?
1 change: 1 addition & 0 deletions Library/Homebrew/extend/os/linux/cask/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module ClassMethods
vst3_plugindir: "~/.vst3",
fontdir: "#{ENV.fetch("HOMEBREW_XDG_DATA_HOME", "~/.local/share")}/fonts",
appdir: "~/.config/apps",
appimagedir: "~/Applications",
}.freeze, T::Hash[Symbol, String])

sig { returns(T::Hash[Symbol, T.any(LazyObject, String)]) }
Expand Down
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