-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
readline.rb
106 lines (92 loc) 路 4.51 KB
/
readline.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
class Readline < Formula
desc "Library for command-line editing"
homepage "https://tiswww.case.edu/php/chet/readline/rltop.html"
url "https://ftp.gnu.org/gnu/readline/readline-8.2.tar.gz"
mirror "https://ftpmirror.gnu.org/readline/readline-8.2.tar.gz"
version "8.2.10"
sha256 "3feb7171f16a84ee82ca18a36d7b9be109a52c04f492a053331d7d1095007c35"
license "GPL-3.0-or-later"
%w[
001 bbf97f1ec40a929edab5aa81998c1e2ef435436c597754916e6a5868f273aff7
002 e06503822c62f7bc0d9f387d4c78c09e0ce56e53872011363c74786c7cd4c053
003 24f587ba46b46ed2b1868ccaf9947504feba154bb8faabd4adaea63ef7e6acb0
004 79572eeaeb82afdc6869d7ad4cba9d4f519b1218070e17fa90bbecd49bd525ac
005 622ba387dae5c185afb4b9b20634804e5f6c1c6e5e87ebee7c35a8f065114c99
006 c7b45ff8c0d24d81482e6e0677e81563d13c74241f7b86c4de00d239bc81f5a1
007 5911a5b980d7900aabdbee483f86dab7056851e6400efb002776a0a4a1bab6f6
008 a177edc9d8c9f82e8c19d0630ab351f3fd1b201d655a1ddb5d51c4cee197b26a
009 3d9885e692e1998523fd5c61f558cecd2aafd67a07bd3bfe1d7ad5a31777a116
010 758e2ec65a0c214cfe6161f5cde3c5af4377c67d820ea01d13de3ca165f67b4c
].each_slice(2) do |p, checksum|
patch :p0 do
url "https://ftp.gnu.org/gnu/readline/readline-8.2-patches/readline82-#{p}"
mirror "https://ftpmirror.gnu.org/readline/readline-8.2-patches/readline82-#{p}"
sha256 checksum
end
end
# 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 :stable
regex(/href=.*?readline[._-]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=.*?(readline[._-]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(
"https://ftp.gnu.org/gnu/readline/#{patches_directory[1]}",
)
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=.*?readline[._-]?v?\d+(?:\.\d+)*[._-]0*(\d+)["' >]/i).each do |match|
versions << "#{newest_version.major_minor}.#{match[0]}"
end
versions
end
end
bottle do
sha256 cellar: :any, arm64_sonoma: "713fd1fa8544426b7e97eb21d13153195fea4c407db8a174bd183777b81c9192"
sha256 cellar: :any, arm64_ventura: "90351660d5ceca72a4c0a287555f2045db95f78aa5f65011b94213429f729cde"
sha256 cellar: :any, arm64_monterey: "e58bc8376c36602c3cedf94075bb1097b04b77438c5a946fdbd37bf0eb6579c2"
sha256 cellar: :any, sonoma: "9796e0ff1cc29ae7e75d8fc1a3e2c5e8ae2aeade8d9d59a16363306bf6c5b8f4"
sha256 cellar: :any, ventura: "952e2975dffc98bd35673c86474dbb91fadc8d993c0720e4f085597f7a484af9"
sha256 cellar: :any, monterey: "3633320dce51662036ea90acfc9adf5bb5e6f1dca7dbdb539839736129c474b0"
sha256 cellar: :any_skip_relocation, x86_64_linux: "65181d2c0a9bd1d91ded6f7ec4a69b1110f65e875b332947e86a30aed7eab20f"
end
keg_only :shadowed_by_macos, "macOS provides BSD libedit"
uses_from_macos "ncurses"
def install
system "./configure", "--prefix=#{prefix}", "--with-curses"
# FIXME: Setting `SHLIB_LIBS` should not be needed, but, on Linux,
# many dependents expect readline to link with ncurses and
# are broken without it. Readline should be agnostic about
# the terminfo library on Linux.
system "make", "install", "SHLIB_LIBS=-lcurses"
end
test do
(testpath/"test.c").write <<~EOS
#include <stdio.h>
#include <stdlib.h>
#include <readline/readline.h>
int main()
{
printf("%s\\n", readline("test> "));
return 0;
}
EOS
system ENV.cc, "-L", lib, "test.c", "-L#{lib}", "-lreadline", "-o", "test"
assert_equal "test> Hello, World!\nHello, World!", pipe_output("./test", "Hello, World!\n").strip
end
end