Merge pull request #19121 from Homebrew/feat/cask/bin_install
feat: allow linux binaries in casks
This commit is contained in:
commit
634768e724
@ -411,7 +411,7 @@ module Cask
|
|||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
if MacOS.undeletable?(resolved_path)
|
if undeletable?(resolved_path)
|
||||||
opoo "Skipping #{Formatter.identifier(action)} for undeletable path '#{path}'."
|
opoo "Skipping #{Formatter.identifier(action)} for undeletable path '#{path}'."
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@ -538,6 +538,10 @@ module Cask
|
|||||||
recursive_rmdir(*resolved_paths, **kwargs)
|
recursive_rmdir(*resolved_paths, **kwargs)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def undeletable?(target); end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "extend/os/cask/artifact/abstract_uninstall"
|
||||||
|
|||||||
@ -62,7 +62,7 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'"
|
ohai "Linking #{self.class.english_name} '#{source.basename}' to '#{target}'"
|
||||||
create_filesystem_link(command:)
|
create_filesystem_link(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
def unlink(command: nil, **)
|
def unlink(command: nil, **)
|
||||||
@ -72,14 +72,10 @@ module Cask
|
|||||||
Utils.gain_permissions_remove(target, command:)
|
Utils.gain_permissions_remove(target, command:)
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_filesystem_link(command: nil)
|
sig { params(command: T.class_of(SystemCommand)).void }
|
||||||
Utils.gain_permissions_mkpath(target.dirname, command:)
|
def create_filesystem_link(command); 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
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require "extend/os/cask/artifact/symlinked"
|
||||||
|
|||||||
@ -114,6 +114,7 @@ module Cask
|
|||||||
return unless @block
|
return unless @block
|
||||||
|
|
||||||
@dsl.instance_eval(&@block)
|
@dsl.instance_eval(&@block)
|
||||||
|
@dsl.add_implicit_macos_dependency
|
||||||
@dsl.language_eval
|
@dsl.language_eval
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -106,7 +106,7 @@ module Cask
|
|||||||
]).freeze
|
]).freeze
|
||||||
|
|
||||||
extend Attrable
|
extend Attrable
|
||||||
include OnSystem::MacOSOnly
|
include OnSystem::MacOSAndLinux
|
||||||
|
|
||||||
attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :deprecation_replacement, :disable_date,
|
attr_reader :cask, :token, :deprecation_date, :deprecation_reason, :deprecation_replacement, :disable_date,
|
||||||
:disable_reason, :disable_replacement, :on_system_block_min_os
|
:disable_reason, :disable_replacement, :on_system_block_min_os
|
||||||
@ -310,18 +310,36 @@ module Cask
|
|||||||
# For architecture-dependent downloads:
|
# For architecture-dependent downloads:
|
||||||
#
|
#
|
||||||
# ```ruby
|
# ```ruby
|
||||||
# sha256 arm: "7bdb497080ffafdfd8cc94d8c62b004af1be9599e865e5555e456e2681e150ca",
|
# sha256 arm: "7bdb497080ffafdfd8cc94d8c62b004af1be9599e865e5555e456e2681e150ca",
|
||||||
# intel: "b3c1c2442480a0219b9e05cf91d03385858c20f04b764ec08a3fa83d1b27e7b2"
|
# x86_64: "b3c1c2442480a0219b9e05cf91d03385858c20f04b764ec08a3fa83d1b27e7b2"
|
||||||
|
# x86_64_linux: "1a2aee7f1ddc999993d4d7d42a150c5e602bc17281678050b8ed79a0500cc90f"
|
||||||
|
# arm64_linux: "bd766af7e692afceb727a6f88e24e6e68d9882aeb3e8348412f6c03d96537c75"
|
||||||
# ```
|
# ```
|
||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
def sha256(arg = nil, arm: nil, intel: nil)
|
sig {
|
||||||
should_return = arg.nil? && arm.nil? && intel.nil?
|
params(
|
||||||
|
arg: T.nilable(T.any(String, Symbol)),
|
||||||
|
arm: T.nilable(String),
|
||||||
|
intel: T.nilable(String),
|
||||||
|
x86_64: T.nilable(String),
|
||||||
|
x86_64_linux: T.nilable(String),
|
||||||
|
arm64_linux: T.nilable(String),
|
||||||
|
).returns(T.nilable(T.any(Symbol, Checksum)))
|
||||||
|
}
|
||||||
|
def sha256(arg = nil, arm: nil, intel: nil, x86_64: nil, x86_64_linux: nil, arm64_linux: nil)
|
||||||
|
should_return = arg.nil? && arm.nil? && (intel.nil? || x86_64.nil?) && x86_64_linux.nil? && arm64_linux.nil?
|
||||||
|
|
||||||
|
x86_64 ||= intel if intel.present? && x86_64.nil?
|
||||||
set_unique_stanza(:sha256, should_return) do
|
set_unique_stanza(:sha256, should_return) do
|
||||||
@on_system_blocks_exist = true if arm.present? || intel.present?
|
if arm.present? || x86_64.present? || x86_64_linux.present? || arm64_linux.present?
|
||||||
|
@on_system_blocks_exist = true
|
||||||
|
end
|
||||||
|
|
||||||
val = arg || on_arch_conditional(arm:, intel:)
|
val = arg || on_system_conditional(
|
||||||
|
macos: on_arch_conditional(arm:, intel: x86_64),
|
||||||
|
linux: on_arch_conditional(arm: arm64_linux, intel: x86_64_linux),
|
||||||
|
)
|
||||||
case val
|
case val
|
||||||
when :no_check
|
when :no_check
|
||||||
val
|
val
|
||||||
@ -352,6 +370,31 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sets the cask's os strings.
|
||||||
|
#
|
||||||
|
# ### Example
|
||||||
|
#
|
||||||
|
# ```ruby
|
||||||
|
# os macos: "darwin", linux: "tux"
|
||||||
|
# ```
|
||||||
|
#
|
||||||
|
# @api public
|
||||||
|
sig {
|
||||||
|
params(
|
||||||
|
macos: T.nilable(String),
|
||||||
|
linux: T.nilable(String),
|
||||||
|
).returns(T.nilable(String))
|
||||||
|
}
|
||||||
|
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.
|
# Declare dependencies and requirements for a cask.
|
||||||
#
|
#
|
||||||
# NOTE: Multiple dependencies can be specified.
|
# NOTE: Multiple dependencies can be specified.
|
||||||
@ -370,6 +413,13 @@ module Cask
|
|||||||
@depends_on
|
@depends_on
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @api private
|
||||||
|
def add_implicit_macos_dependency
|
||||||
|
return if @depends_on.present? && @depends_on.macos.present?
|
||||||
|
|
||||||
|
depends_on macos: ">= :#{MacOSVersion::SYMBOLS.key MacOSVersion::SYMBOLS.values.min}"
|
||||||
|
end
|
||||||
|
|
||||||
# Declare conflicts that keep a cask from installing or working correctly.
|
# Declare conflicts that keep a cask from installing or working correctly.
|
||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
|
|||||||
@ -20,4 +20,7 @@ module OnSystem::MacOSAndLinux
|
|||||||
.returns(T.type_parameter(:U))
|
.returns(T.type_parameter(:U))
|
||||||
}
|
}
|
||||||
def on_macos(&block); end
|
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
|
end
|
||||||
|
|||||||
@ -0,0 +1,5 @@
|
|||||||
|
# typed: strict
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "extend/os/mac/cask/artifact/abstract_uninstall" if OS.mac?
|
||||||
|
require "extend/os/linux/cask/artifact/abstract_uninstall" if OS.linux?
|
||||||
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?
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
# typed: strict
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
module OS
|
||||||
|
module Linux
|
||||||
|
module Cask
|
||||||
|
module Artifact
|
||||||
|
module AbstractUninstall
|
||||||
|
extend T::Helpers
|
||||||
|
|
||||||
|
requires_ancestor { ::Cask::Artifact::AbstractUninstall }
|
||||||
|
|
||||||
|
sig { params(target: Pathname).returns(T::Boolean) }
|
||||||
|
def undeletable?(target)
|
||||||
|
!target.parent.writable?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Cask::Artifact::AbstractUninstall.prepend(OS::Linux::Cask::Artifact::AbstractUninstall)
|
||||||
@ -20,4 +20,4 @@ module OS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Cask::Artifact::Moved.prepend(OS::Linux::Cask::Config)
|
Cask::Artifact::Moved.prepend(OS::Linux::Cask::Artifact::Moved)
|
||||||
|
|||||||
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
|
def check_stanza_os_requirements
|
||||||
return if artifacts.all?(::Cask::Artifact::Font)
|
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."
|
raise ::Cask::CaskError, "macOS is required for this software."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -0,0 +1,25 @@
|
|||||||
|
# typed: strict
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cask/macos"
|
||||||
|
|
||||||
|
module OS
|
||||||
|
module Mac
|
||||||
|
module Cask
|
||||||
|
module Artifact
|
||||||
|
module AbstractUninstall
|
||||||
|
extend T::Helpers
|
||||||
|
|
||||||
|
requires_ancestor { ::Cask::Artifact::AbstractUninstall }
|
||||||
|
|
||||||
|
sig { params(target: Pathname).returns(T::Boolean) }
|
||||||
|
def undeletable?(target)
|
||||||
|
MacOS.undeletable?(target)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Cask::Artifact::AbstractUninstall.prepend(OS::Mac::Cask::Artifact::AbstractUninstall)
|
||||||
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)
|
||||||
@ -76,7 +76,12 @@
|
|||||||
"depends_on": {
|
"depends_on": {
|
||||||
"cask": [
|
"cask": [
|
||||||
"something"
|
"something"
|
||||||
]
|
],
|
||||||
|
"macos": {
|
||||||
|
">=": [
|
||||||
|
"10.11"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"conflicts_with": {
|
"conflicts_with": {
|
||||||
"formula": [
|
"formula": [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user