Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions Formula/telegram-cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class TelegramCli < Formula
sha256 high_sierra: "410b56cc04620c7a1f495b500b41fa61339cc68444c1c65939bb4fb0c4cc96ef"
end

# "This project is deprecated and is no longer being maintained.
# Last commit was in 2016
deprecate! date: "2021-06-30", because: :unmaintained

depends_on "pkg-config" => :build
depends_on "jansson"
depends_on "libconfig"
Expand All @@ -38,13 +42,23 @@ class TelegramCli < Formula
sha256 "eb6243e1861c0b1595e8bdee705d1acdd2678e854f0919699d4b26c159e30b5e"
end

# Patch to make telegram-cli use sysconfdir for Apple Silicon support
# This patch does not apply cleanly to 1.3.1, but applies cleanly to head.
# using inline patch for the tag this is checking out.
# patch do
# url "https://github.com/vysheng/tg/commit/63b85c3ca1b335daf783d6e9ae80c076e7406e39.patch?full_index=1"
# sha256 "cbc37bd03b7456a43dbedeb5c8dd17294e016d8e8bb36f236f42f74bde4d7a71"
# end
patch :DATA

def install
args = %W[
--prefix=#{prefix}
CFLAGS=-I#{Formula["readline"].include}
CPPFLAGS=-I#{Formula["readline"].include}
LDFLAGS=-L#{Formula["readline"].lib}
--disable-liblua
--sysconfdir=#{etc}
]

system "./configure", *args
Expand All @@ -58,3 +72,40 @@ def install
assert_match "messages_allocated", shell_output("echo stats | #{bin}/telegram")
end
end
__END__
diff --git a/Makefile.in b/Makefile.in
index e1989ab..78d84d0 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2,7 +2,7 @@ srcdir=@srcdir@

CFLAGS=@CFLAGS@
LDFLAGS=@LDFLAGS@ @OPENSSL_LDFLAGS@
-CPPFLAGS=@CPPFLAGS@ @OPENSSL_INCLUDES@
+CPPFLAGS=@CPPFLAGS@ @OPENSSL_INCLUDES@ -DSYSCONFDIR='"@sysconfdir@"'
DEFS=@DEFS@
COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC

diff --git a/main.c b/main.c
index 9498b0b..ba97e36 100644
--- a/main.c
+++ b/main.c
@@ -927,8 +927,16 @@ int main (int argc, char **argv) {
running_for_first_time ();
parse_config ();

- #if defined(__FreeBSD__) || (defined(__APPLE__) && defined(__MACH__))
- tgl_set_rsa_key (TLS, "/usr/local/etc/" PROG_NAME "/server.pub");
+ #if defined(__FreeBSD__)
+ /* at the time of adding --sysconfdir to configure I do not know if FreeBSD has it set to /usr/local/etc */
+ #undef SYSCONFDIR
+ #define SYSCONFDIR "/usr/local/etc"
+ #endif
+
+ #if defined(SYSCONFDIR)
+ /* if --sysconfdir was provided to configure use it, not touching FreeBSD as I'm not sure if
+ the default is correct there */
+ tgl_set_rsa_key (TLS, SYSCONFDIR "/" PROG_NAME "/server.pub");
#else
tgl_set_rsa_key (TLS, "/etc/" PROG_NAME "/server.pub");
#endif