diff --git a/Library/Homebrew/cask/artifact/uninstall.rb b/Library/Homebrew/cask/artifact/uninstall.rb index e136b05b8fbbc..c9801b09618ec 100644 --- a/Library/Homebrew/cask/artifact/uninstall.rb +++ b/Library/Homebrew/cask/artifact/uninstall.rb @@ -3,12 +3,12 @@ require "cask/artifact/abstract_uninstall" -UPGRADE_REINSTALL_SKIP_DIRECTIVES = [:quit, :signal].freeze - module Cask module Artifact # Artifact corresponding to the `uninstall` stanza. class Uninstall < AbstractUninstall + UPGRADE_REINSTALL_SKIP_DIRECTIVES = [:quit, :signal].freeze + def uninstall_phase(upgrade: false, reinstall: false, **options) filtered_directives = ORDERED_DIRECTIVES.filter do |directive_sym| next false if directive_sym == :rmdir diff --git a/Library/Homebrew/cask/utils.rb b/Library/Homebrew/cask/utils.rb index b90dbfdad6635..c7019a1c50591 100644 --- a/Library/Homebrew/cask/utils.rb +++ b/Library/Homebrew/cask/utils.rb @@ -4,11 +4,11 @@ require "utils/user" require "open3" -BUG_REPORTS_URL = "https://github.com/Homebrew/homebrew-cask#reporting-bugs" - module Cask # Helper functions for various cask operations. module Utils + BUG_REPORTS_URL = "https://github.com/Homebrew/homebrew-cask#reporting-bugs" + def self.gain_permissions_mkpath(path, command: SystemCommand) dir = path.ascend.find(&:directory?) return if path == dir diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index a3cde6b1ec6db..60869fd858127 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -2,6 +2,7 @@ # frozen_string_literal: true require "utils/curl" +require "utils/gzip" require "json" require "zlib" require "extend/hash/keys" @@ -26,9 +27,6 @@ class GitHubPackages VALID_OCI_TAG_REGEX = /^[a-zA-Z0-9_][a-zA-Z0-9._-]{0,127}$/ INVALID_OCI_TAG_CHARS_REGEX = /[^a-zA-Z0-9._-]/ - GZIP_BUFFER_SIZE = 64 * 1024 - private_constant :GZIP_BUFFER_SIZE - # Translate Homebrew tab.arch to OCI platform.architecture TAB_ARCH_TO_PLATFORM_ARCHITECTURE = { "arm64" => "arm64", @@ -382,7 +380,7 @@ def upload_bottle(user, token, skopeo, formula_full_name, bottle_hash, keep_old: tar_sha256 = Digest::SHA256.new Zlib::GzipReader.open(local_file) do |gz| - while (data = gz.read(GZIP_BUFFER_SIZE)) + while (data = gz.read(Utils::Gzip::GZIP_BUFFER_SIZE)) tar_sha256 << data end end diff --git a/Library/Homebrew/manpages.rb b/Library/Homebrew/manpages.rb index 3b3048017faff..e2d79bf1f8aa0 100644 --- a/Library/Homebrew/manpages.rb +++ b/Library/Homebrew/manpages.rb @@ -4,9 +4,6 @@ require "cli/parser" require "erb" -SOURCE_PATH = (HOMEBREW_LIBRARY_PATH/"manpages").freeze -TARGET_MAN_PATH = (HOMEBREW_REPOSITORY/"manpages").freeze -TARGET_DOC_PATH = (HOMEBREW_REPOSITORY/"docs").freeze module Homebrew # Helper functions for generating homebrew manual. module Manpages @@ -25,6 +22,10 @@ module Manpages keyword_init: true, ) + SOURCE_PATH = (HOMEBREW_LIBRARY_PATH/"manpages").freeze + TARGET_MAN_PATH = (HOMEBREW_REPOSITORY/"manpages").freeze + TARGET_DOC_PATH = (HOMEBREW_REPOSITORY/"docs").freeze + def self.regenerate_man_pages(quiet:) require "kramdown" require "manpages/parser/ronn" diff --git a/Library/Homebrew/utils/gzip.rb b/Library/Homebrew/utils/gzip.rb index acb70088ecef0..d4e927309d3f6 100644 --- a/Library/Homebrew/utils/gzip.rb +++ b/Library/Homebrew/utils/gzip.rb @@ -1,13 +1,13 @@ # typed: strict # frozen_string_literal: true -# Apple's gzip also uses zlib so use the same buffer size here. -# https://github.com/apple-oss-distributions/file_cmds/blob/file_cmds-400/gzip/gzip.c#L147 -GZIP_BUFFER_SIZE = T.let(64 * 1024, Integer) - module Utils # Helper functions for creating gzip files. module Gzip + # Apple's gzip also uses zlib so use the same buffer size here. + # https://github.com/apple-oss-distributions/file_cmds/blob/file_cmds-400/gzip/gzip.c#L147 + GZIP_BUFFER_SIZE = T.let(64 * 1024, Integer) + sig { params( path: T.any(String, Pathname),