Skip to content

Commit

Permalink
feat: allow font install on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
SMillerDev committed Dec 5, 2024
1 parent 526d311 commit e5c2c8c
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Library/Homebrew/cask/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,5 @@ def to_json(*options)
end
end
end

require "extend/os/cask/config"
17 changes: 14 additions & 3 deletions Library/Homebrew/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def fetch(quiet: nil, timeout: nil)
satisfy_cask_and_formula_dependencies
end

sig { void }
def stage
odebug "Cask::Installer#stage"

Expand All @@ -88,6 +89,7 @@ def stage
raise e
end

sig { void }
def install
start_time = Time.now
odebug "Cask::Installer#install"
Expand Down Expand Up @@ -134,6 +136,7 @@ def install
raise
end

sig { void }
def check_deprecate_disable
deprecate_disable_type = DeprecateDisable.type(@cask)
return if deprecate_disable_type.nil?
Expand All @@ -150,6 +153,7 @@ def check_deprecate_disable
end
end

sig { void }
def check_conflicts
return unless @cask.conflicts_with

Expand All @@ -166,6 +170,7 @@ def check_conflicts
end
end

sig { void }
def uninstall_existing_cask
return unless @cask.installed?

Expand Down Expand Up @@ -194,6 +199,7 @@ def download(quiet: nil, timeout: nil)
timeout:)
end

sig { void }
def verify_has_sha
odebug "Checking cask has checksum"
return if @cask.sha256 != :no_check
Expand All @@ -211,6 +217,12 @@ def primary_container
end
end

sig { returns(ArtifactSet) }
def artifacts
@cask.artifacts
end

sig { params(to: Pathname).void }
def extract_primary_container(to: @cask.staged_path)
odebug "Extracting primary container"

Expand Down Expand Up @@ -240,7 +252,6 @@ def extract_primary_container(to: @cask.staged_path)

sig { params(predecessor: T.nilable(Cask)).void }
def install_artifacts(predecessor: nil)
artifacts = @cask.artifacts
already_installed_artifacts = []

odebug "Installing artifacts"
Expand Down Expand Up @@ -299,6 +310,7 @@ def check_macos_requirements
raise CaskError, @cask.depends_on.macos.message(type: :cask)
end

sig { void }
def check_arch_requirements
return if @cask.depends_on.arch.nil?

Expand All @@ -314,6 +326,7 @@ def check_arch_requirements
"but you are running #{@current_arch}."
end

sig { returns(T::Array[T.untyped]) }
def cask_and_formula_dependencies
return @cask_and_formula_dependencies if @cask_and_formula_dependencies

Expand Down Expand Up @@ -487,8 +500,6 @@ def finalize_upgrade

sig { params(clear: T::Boolean, successor: T.nilable(Cask)).void }
def uninstall_artifacts(clear: false, successor: nil)
artifacts = @cask.artifacts

odebug "Uninstalling artifacts"
odebug "#{::Utils.pluralize("artifact", artifacts.length, include_count: true)} defined", artifacts

Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/cask/quarantine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,5 @@ def self.app_management_permissions_granted?(app:, command:)
end
end
end

require "extend/os/cask/quarantine"
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/os/cask/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# typed: strict
# frozen_string_literal: true

require "extend/os/linux/cask/config" if OS.linux?
4 changes: 4 additions & 0 deletions Library/Homebrew/extend/os/cask/quarantine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# typed: strict
# frozen_string_literal: true

require "extend/os/linux/cask/quarantine" if OS.linux?
34 changes: 34 additions & 0 deletions Library/Homebrew/extend/os/linux/cask/config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# typed: strict
# frozen_string_literal: true

module OS
module Linux
module Cask
module Config
extend T::Helpers

requires_ancestor { ::Cask::Config }

DEFAULT_DIRS = T.let({
vst_plugindir: "~/.vst",
vst3_plugindir: "~/.vst3",
fontdir: "#{ENV.fetch("XDG_DATA_HOME", "~/.local/share")}/fonts",
appdir: nil,
keyboard_layoutdir: nil,
colorpickerdir: nil,
prefpanedir: nil,
qlplugindir: nil,
mdimporterdir: nil,
servicedir: nil,
dictionarydir: nil,
screen_saverdir: nil,
input_methoddir: nil,
internet_plugindir: nil,
audio_unit_plugindir: nil,
}.freeze, T::Hash[Symbol, T.nilable(String)])
end
end
end
end

Cask::Config.prepend(OS::Linux::Cask::Config)
4 changes: 3 additions & 1 deletion Library/Homebrew/extend/os/linux/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ module Installer

sig { void }
def check_stanza_os_requirements
raise ::Cask::CaskError, "macOS is required for this software."
raise ::Cask::CaskError, "macOS is required for this software." unless artifacts.reject do |k|
k.is_a?(::Cask::Artifact::Font)

Check warning on line 17 in Library/Homebrew/extend/os/linux/cask/installer.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/cask/installer.rb#L17

Added line #L17 was not covered by tests
end.empty?
end
end
end
Expand Down
26 changes: 26 additions & 0 deletions Library/Homebrew/extend/os/linux/cask/quarantine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# typed: strict
# frozen_string_literal: true

module OS
module Linux
module Cask
module Quarantine
extend T::Helpers

requires_ancestor { ::Cask::Quarantine }

sig { returns(Symbol) }
def self.check_quarantine_support
:linux

Check warning on line 14 in Library/Homebrew/extend/os/linux/cask/quarantine.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/cask/quarantine.rb#L14

Added line #L14 was not covered by tests
end

sig { returns(T::Boolean) }
def self.available?
false

Check warning on line 19 in Library/Homebrew/extend/os/linux/cask/quarantine.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/extend/os/linux/cask/quarantine.rb#L19

Added line #L19 was not covered by tests
end
end
end
end
end

Cask::Quarantine.prepend(OS::Linux::Cask::Quarantine)

0 comments on commit e5c2c8c

Please sign in to comment.