Skip to content

Commit 7d7dd3d

Browse files
author
Allen Reese
committed
telegram-cli: Add Apple Silicon support by supporting the --sysconfdir option of configure
1 parent c5796b9 commit 7d7dd3d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

Formula/telegram-cli.rb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ class TelegramCli < Formula
1616
sha256 high_sierra: "410b56cc04620c7a1f495b500b41fa61339cc68444c1c65939bb4fb0c4cc96ef"
1717
end
1818

19+
# "This project is deprecated and is no longer being maintained.
20+
# Last commit was in 2016
21+
deprecate! date: "2021-06-30", because: :unmaintained
22+
1923
depends_on "pkg-config" => :build
2024
depends_on "jansson"
2125
depends_on "libconfig"
@@ -38,13 +42,23 @@ class TelegramCli < Formula
3842
sha256 "eb6243e1861c0b1595e8bdee705d1acdd2678e854f0919699d4b26c159e30b5e"
3943
end
4044

45+
# Patch to make telegram-cli use sysconfdir for Apple Silicon support
46+
# This patch does not apply cleanly to 1.3.1, but applies cleanly to head.
47+
# using inline patch for the tag this is checking out.
48+
# patch do
49+
# url "https://github.com/vysheng/tg/commit/63b85c3ca1b335daf783d6e9ae80c076e7406e39.patch?full_index=1"
50+
# sha256 "cbc37bd03b7456a43dbedeb5c8dd17294e016d8e8bb36f236f42f74bde4d7a71"
51+
# end
52+
patch :DATA
53+
4154
def install
4255
args = %W[
4356
--prefix=#{prefix}
4457
CFLAGS=-I#{Formula["readline"].include}
4558
CPPFLAGS=-I#{Formula["readline"].include}
4659
LDFLAGS=-L#{Formula["readline"].lib}
4760
--disable-liblua
61+
--sysconfdir=#{etc}
4862
]
4963

5064
system "./configure", *args
@@ -58,3 +72,40 @@ def install
5872
assert_match "messages_allocated", shell_output("echo stats | #{bin}/telegram")
5973
end
6074
end
75+
__END__
76+
diff --git a/Makefile.in b/Makefile.in
77+
index e1989ab..78d84d0 100644
78+
--- a/Makefile.in
79+
+++ b/Makefile.in
80+
@@ -2,7 +2,7 @@ srcdir=@srcdir@
81+
82+
CFLAGS=@CFLAGS@
83+
LDFLAGS=@LDFLAGS@ @OPENSSL_LDFLAGS@
84+
-CPPFLAGS=@CPPFLAGS@ @OPENSSL_INCLUDES@
85+
+CPPFLAGS=@CPPFLAGS@ @OPENSSL_INCLUDES@ -DSYSCONFDIR='"@sysconfdir@"'
86+
DEFS=@DEFS@
87+
COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC
88+
89+
diff --git a/main.c b/main.c
90+
index 9498b0b..ba97e36 100644
91+
--- a/main.c
92+
+++ b/main.c
93+
@@ -927,8 +927,16 @@ int main (int argc, char **argv) {
94+
running_for_first_time ();
95+
parse_config ();
96+
97+
- #if defined(__FreeBSD__) || (defined(__APPLE__) && defined(__MACH__))
98+
- tgl_set_rsa_key (TLS, "/usr/local/etc/" PROG_NAME "/server.pub");
99+
+ #if defined(__FreeBSD__)
100+
+ /* at the time of adding --sysconfdir to configure I do not know if FreeBSD has it set to /usr/local/etc */
101+
+ #undef SYSCONFDIR
102+
+ #define SYSCONFDIR "/usr/local/etc"
103+
+ #endif
104+
+
105+
+ #if defined(SYSCONFDIR)
106+
+ /* if --sysconfdir was provided to configure use it, not touching FreeBSD as I'm not sure if
107+
+ the default is correct there */
108+
+ tgl_set_rsa_key (TLS, SYSCONFDIR "/" PROG_NAME "/server.pub");
109+
#else
110+
tgl_set_rsa_key (TLS, "/etc/" PROG_NAME "/server.pub");
111+
#endif

0 commit comments

Comments
 (0)