74 lines
3.1 KiB
Ruby
74 lines
3.1 KiB
Ruby
class Bash < Formula
|
|
desc "Bourne-Again SHell, a UNIX command interpreter"
|
|
homepage "https://www.gnu.org/software/bash/"
|
|
url "https://ftp.gnu.org/gnu/bash/bash-5.2.tar.gz"
|
|
mirror "https://ftpmirror.gnu.org/bash/bash-5.2.tar.gz"
|
|
mirror "https://mirrors.kernel.org/gnu/bash/bash-5.2.tar.gz"
|
|
mirror "https://mirrors.ocf.berkeley.edu/gnu/bash/bash-5.2.tar.gz"
|
|
sha256 "a139c166df7ff4471c5e0733051642ee5556c1cc8a4a78f145583c5c81ab32fb"
|
|
license "GPL-3.0-or-later"
|
|
head "https://git.savannah.gnu.org/git/bash.git", branch: "master"
|
|
|
|
# We're not using `url :stable` here because we need `url` to be a string
|
|
# when we use it in the `strategy` block.
|
|
livecheck do
|
|
url "https://ftp.gnu.org/gnu/bash/?C=M&O=D"
|
|
regex(/href=.*?bash[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
strategy :gnu do |page, regex|
|
|
# Match versions from files
|
|
versions = page.scan(regex)
|
|
.flatten
|
|
.uniq
|
|
.map { |v| Version.new(v) }
|
|
.sort
|
|
next versions if versions.blank?
|
|
|
|
# Assume the last-sorted version is newest
|
|
newest_version = versions.last
|
|
|
|
# Simply return the found versions if there isn't a patches directory
|
|
# for the "newest" version
|
|
patches_directory = page.match(%r{href=.*?(bash[._-]v?#{newest_version.major_minor}[._-]patches/?)["' >]}i)
|
|
next versions if patches_directory.blank?
|
|
|
|
# Fetch the page for the patches directory
|
|
patches_page = Homebrew::Livecheck::Strategy.page_content(URI.join(@url, patches_directory[1]).to_s)
|
|
next versions if patches_page[:content].blank?
|
|
|
|
# Generate additional major.minor.patch versions from the patch files in
|
|
# the directory and add those to the versions array
|
|
patches_page[:content].scan(/href=.*?bash[._-]?v?\d+(?:\.\d+)*[._-]0*(\d+)["' >]/i).each do |match|
|
|
versions << "#{newest_version.major_minor}.#{match[0]}"
|
|
end
|
|
|
|
versions
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
sha256 arm64_monterey: "824f87ed8e25d40bb7b1abbcb74e2a9cb7da1b6f4e484acecdb288f076201c85"
|
|
sha256 arm64_big_sur: "c978d7c40c84d2c11435a2d7e804f714d0afa62421bac61cf212be7a34503227"
|
|
sha256 monterey: "1ec2f5fd0b9635ff892e5ebc8def03ce55232abc3731bd6ae33528dccb3d9371"
|
|
sha256 big_sur: "b3d95c6bc517d73397cad77ce6184b43184fa856d3c1abce638916bba70801b0"
|
|
sha256 catalina: "55c6c14ff3b10f55069986ef6dc6dd43fffd8cb083b71a639e6ebd5378bc403f"
|
|
sha256 x86_64_linux: "b6a8ea41858e0c60f113865c96ed3f82eff69d077465874f5567da047d2f4e90"
|
|
end
|
|
|
|
def install
|
|
# When built with SSH_SOURCE_BASHRC, bash will source ~/.bashrc when
|
|
# it's non-interactively from sshd. This allows the user to set
|
|
# environment variables prior to running the command (e.g. PATH). The
|
|
# /bin/bash that ships with macOS defines this, and without it, some
|
|
# things (e.g. git+ssh) will break if the user sets their default shell to
|
|
# Homebrew's bash instead of /bin/bash.
|
|
ENV.append_to_cflags "-DSSH_SOURCE_BASHRC"
|
|
|
|
system "./configure", "--prefix=#{prefix}"
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
assert_equal "hello", shell_output("#{bin}/bash -c \"echo -n hello\"")
|
|
end
|
|
end
|