feat: allow cask binaries on linux
This commit is contained in:
parent
6de67b6c45
commit
975fe8a83f
@ -62,7 +62,7 @@ module Cask
|
||||
end
|
||||
|
||||
ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'"
|
||||
create_filesystem_link(command:)
|
||||
create_filesystem_link(command)
|
||||
end
|
||||
|
||||
def unlink(command: nil, **)
|
||||
@ -72,14 +72,10 @@ module Cask
|
||||
Utils.gain_permissions_remove(target, command:)
|
||||
end
|
||||
|
||||
def create_filesystem_link(command: nil)
|
||||
Utils.gain_permissions_mkpath(target.dirname, command:)
|
||||
sig { params(command: T.class_of(SystemCommand)).void }
|
||||
def create_filesystem_link(command); end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
command.run! "/bin/ln", args: ["-h", "-f", "-s", "--", source, target],
|
||||
sudo: !target.dirname.writable?
|
||||
|
||||
add_altname_metadata(source, target.basename, command:)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
require "extend/os/cask/artifact/symlinked"
|
||||
|
@ -312,16 +312,17 @@ module Cask
|
||||
# ```ruby
|
||||
# sha256 arm: "7bdb497080ffafdfd8cc94d8c62b004af1be9599e865e5555e456e2681e150ca",
|
||||
# intel: "b3c1c2442480a0219b9e05cf91d03385858c20f04b764ec08a3fa83d1b27e7b2"
|
||||
# linux: "1a2aee7f1ddc999993d4d7d42a150c5e602bc17281678050b8ed79a0500cc90f"
|
||||
# ```
|
||||
#
|
||||
# @api public
|
||||
def sha256(arg = nil, arm: nil, intel: nil)
|
||||
def sha256(arg = nil, arm: nil, intel: nil, linux: nil)
|
||||
should_return = arg.nil? && arm.nil? && intel.nil?
|
||||
|
||||
set_unique_stanza(:sha256, should_return) do
|
||||
@on_system_blocks_exist = true if arm.present? || intel.present?
|
||||
@on_system_blocks_exist = true if arm.present? || intel.present? || linux.present?
|
||||
|
||||
val = arg || on_arch_conditional(arm:, intel:)
|
||||
val = arg || on_system_conditional(macos: on_arch_conditional(arm:, intel:), linux:)
|
||||
case val
|
||||
when :no_check
|
||||
val
|
||||
@ -352,6 +353,25 @@ module Cask
|
||||
end
|
||||
end
|
||||
|
||||
# Sets the cask's os strings.
|
||||
#
|
||||
# ### Example
|
||||
#
|
||||
# ```ruby
|
||||
# os macos: "darwin", linux: "tux"
|
||||
# ```
|
||||
#
|
||||
# @api public
|
||||
def os(macos: nil, linux: nil)
|
||||
should_return = macos.nil? && linux.nil?
|
||||
|
||||
set_unique_stanza(:os, should_return) do
|
||||
@on_system_blocks_exist = true
|
||||
|
||||
on_system_conditional(macos:, linux:)
|
||||
end
|
||||
end
|
||||
|
||||
# Declare dependencies and requirements for a cask.
|
||||
#
|
||||
# NOTE: Multiple dependencies can be specified.
|
||||
|
@ -20,4 +20,7 @@ module OnSystem::MacOSAndLinux
|
||||
.returns(T.type_parameter(:U))
|
||||
}
|
||||
def on_macos(&block); end
|
||||
|
||||
sig { params(arm: T.nilable(String), intel: T.nilable(String)).returns(T.nilable(String)) }
|
||||
def on_arch_conditional(arm: nil, intel: nil); end
|
||||
end
|
||||
|
5
Library/Homebrew/extend/os/cask/artifact/symlinked.rb
Normal file
5
Library/Homebrew/extend/os/cask/artifact/symlinked.rb
Normal file
@ -0,0 +1,5 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "extend/os/mac/cask/artifact/symlinked" if OS.mac?
|
||||
require "extend/os/linux/cask/artifact/symlinked" if OS.linux?
|
26
Library/Homebrew/extend/os/linux/cask/artifact/symlinked.rb
Normal file
26
Library/Homebrew/extend/os/linux/cask/artifact/symlinked.rb
Normal file
@ -0,0 +1,26 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
module OS
|
||||
module Linux
|
||||
module Cask
|
||||
module Artifact
|
||||
module Symlinked
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { ::Cask::Artifact::Symlinked }
|
||||
|
||||
sig { params(command: T.class_of(SystemCommand)).void }
|
||||
def create_filesystem_link(command)
|
||||
::Cask::Utils.gain_permissions_mkpath(target.dirname, command:)
|
||||
|
||||
command.run! "/bin/ln", args: ["--no-dereference", "--force", "--symbolic", source, target],
|
||||
sudo: !target.dirname.writable?
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Cask::Artifact::Symlinked.prepend(OS::Linux::Cask::Artifact::Symlinked)
|
@ -15,6 +15,9 @@ module OS
|
||||
def check_stanza_os_requirements
|
||||
return if artifacts.all?(::Cask::Artifact::Font)
|
||||
|
||||
install_artifacts = artifacts.reject { |artifact| artifact.instance_of?(::Cask::Artifact::Zap) }
|
||||
return if install_artifacts.all?(::Cask::Artifact::Binary)
|
||||
|
||||
raise ::Cask::CaskError, "macOS is required for this software."
|
||||
end
|
||||
end
|
||||
|
30
Library/Homebrew/extend/os/mac/cask/artifact/symlinked.rb
Normal file
30
Library/Homebrew/extend/os/mac/cask/artifact/symlinked.rb
Normal file
@ -0,0 +1,30 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cask/macos"
|
||||
|
||||
module OS
|
||||
module Mac
|
||||
module Cask
|
||||
module Artifact
|
||||
module Symlinked
|
||||
extend T::Helpers
|
||||
|
||||
requires_ancestor { ::Cask::Artifact::Symlinked }
|
||||
|
||||
sig { params(command: T.class_of(SystemCommand)).void }
|
||||
def create_filesystem_link(command)
|
||||
::Cask::Utils.gain_permissions_mkpath(target.dirname, command:)
|
||||
|
||||
command.run! "/bin/ln", args: ["-h", "-f", "-s", "--", source, target],
|
||||
sudo: !target.dirname.writable?
|
||||
|
||||
add_altname_metadata(source, target.basename, command:)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Cask::Artifact::Symlinked.prepend(OS::Mac::Cask::Artifact::Symlinked)
|
Loading…
x
Reference in New Issue
Block a user