diff --git a/Makefile b/Makefile index 1c4c05c..014677c 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,13 @@ srcdir=. -CFLAGS=-g -O2 -I/usr/include/lua5.2 +CFLAGS=-g -O2 LDFLAGS= CPPFLAGS= DEFS=-DHAVE_CONFIG_H COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -EXTRA_LIBS= -lreadline -lrt -lconfig -llua5.2 -ldl -LOCAL_LDFLAGS=-lm -lcrypto -lz -lssl -rdynamic -ggdb ${EXTRA_LIBS} +EXTRA_LIBS=-lconfig -lcrypto -lz -lrt -lm -lreadline -llua +LOCAL_LDFLAGS=-rdynamic -ggdb ${EXTRA_LIBS} LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS} HEADERS= ${srcdir}/constants.h ${srcdir}/include.h ${srcdir}/interface.h ${srcdir}/LICENSE.h ${srcdir}/loop.h ${srcdir}/mtproto-client.h ${srcdir}/mtproto-common.h ${srcdir}/net.h ${srcdir}/no-preview.h ${srcdir}/queries.h ${srcdir}/structures.h ${srcdir}/telegram.h ${srcdir}/tree.h ${srcdir}/config.h ${srcdir}/binlog.h ${srcdir}/tools.h ${srcdir}/lua-tg.h diff --git a/Makefile.in b/Makefile.in index 5ee1b03..23a97dc 100644 --- a/Makefile.in +++ b/Makefile.in @@ -6,7 +6,7 @@ CPPFLAGS=@CPPFLAGS@ DEFS=@DEFS@ COMPILE_FLAGS=${CFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Wextra -Werror -Wno-deprecated -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -EXTRA_LIBS=-lssl @LIBS@ @EXTRA_LIBS@ +EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ LOCAL_LDFLAGS=-rdynamic -ggdb ${EXTRA_LIBS} LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS} diff --git a/README.md b/README.md index e65eac7..d6b6fff 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,10 @@ On gentoo: $ sudo emerge -av sys-libs/readline dev-libs/libconfig dev-libs/openssl dev-lang/lua +On Fedora: + + $ sudo yum install lua-devel, openssl-devel, libconfig-devel, readline-devel + Default Makefile uses liblua5.2 from ubuntu. If you use different version of liblua or linux you have to run ./configure script or you will get some strange compilation error. Then @@ -44,6 +48,7 @@ The client depends on [readline library](http://cnswww.cns.cwru.edu/php/chet/rea $ brew install libconfig $ brew install readline + $ brew install lua $ export CFLAGS="-I/usr/local/include -I/usr/local/Cellar/readline/6.2.4/include" $ export LDFLAGS="-L/usr/local/lib -L/usr/local/Cellar/readline/6.2.4/lib" $ ./configure && make diff --git a/config.h b/config.h index ee1ba04..5f54b0c 100644 --- a/config.h +++ b/config.h @@ -1,9 +1,6 @@ /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ -/* enable libconfig */ -#define ENABLE_LIBCONFIG 1 - /* Define to 1 if you have the `alarm' function. */ #define HAVE_ALARM 1 @@ -25,6 +22,9 @@ /* Define to 1 if you have the header file. */ #define HAVE_LAUXLIB_H 1 +/* Define to 1 if you have the `config' library (-lconfig). */ +#define HAVE_LIBCONFIG 1 + /* Define to 1 if you have the `crypto' library (-lcrypto). */ #define HAVE_LIBCRYPTO 1 @@ -141,6 +141,9 @@ /* Define to the version of this package. */ #define PACKAGE_VERSION "0.1" +/* Use custom prog name */ +/* #undef PROG_NAME */ + /* Use libedit */ /* #undef READLINE_EDIT */ diff --git a/config.h.in b/config.h.in index dfb83e9..1a20b5b 100644 --- a/config.h.in +++ b/config.h.in @@ -1,8 +1,5 @@ /* config.h.in. Generated from configure.ac by autoheader. */ -/* enable libconfig */ -#undef ENABLE_LIBCONFIG - /* Define to 1 if you have the `alarm' function. */ #undef HAVE_ALARM @@ -24,6 +21,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LAUXLIB_H +/* Define to 1 if you have the `config' library (-lconfig). */ +#undef HAVE_LIBCONFIG + /* Define to 1 if you have the `crypto' library (-lcrypto). */ #undef HAVE_LIBCRYPTO @@ -140,6 +140,9 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION +/* Use custom prog name */ +#undef PROG_NAME + /* Use libedit */ #undef READLINE_EDIT diff --git a/configure b/configure index 2361488..dd2e8ef 100755 --- a/configure +++ b/configure @@ -687,6 +687,7 @@ ac_user_opts=' enable_option_checking enable_libconfig enable_liblua +with_progname ' ac_precious_vars='build_alias host_alias @@ -1312,6 +1313,11 @@ Optional Features: --enable-libconfig/--disable-libconfig --enable-liblua/--disable-liblua +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) +--with-progname= + Some influential environment variables: CC C compiler command CFLAGS C compiler flags @@ -3562,14 +3568,16 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_config_config_init" >&5 $as_echo "$ac_cv_lib_config_config_init" >&6; } if test "x$ac_cv_lib_config_config_init" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCONFIG 1 +_ACEOF -$as_echo "#define ENABLE_LIBCONFIG 1" >>confdefs.h + LIBS="-lconfig $LIBS" else as_fn_error $? "No libconfig found. Try --disable-libconfig" "$LINENO" 5 fi - EXTRA_LIBS="${EXTRA_LIBS} -lconfig" ; fi else @@ -3613,14 +3621,16 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_config_config_init" >&5 $as_echo "$ac_cv_lib_config_config_init" >&6; } if test "x$ac_cv_lib_config_config_init" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBCONFIG 1 +_ACEOF -$as_echo "#define ENABLE_LIBCONFIG 1" >>confdefs.h + LIBS="-lconfig $LIBS" else as_fn_error $? "No libconfig found. Try --disable-libconfig" "$LINENO" 5 fi - EXTRA_LIBS="${EXTRA_LIBS} -lconfig" ; fi @@ -5359,6 +5369,35 @@ fi fi +#check for custom prog name + +# Check whether --with-progname was given. +if test "${with_progname+set}" = set; then : + withval=$with_progname; + if test "x$with_progname" = "xno" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 +$as_echo "default" >&6; } + elif test "x$with_progname" = "xyes" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 +$as_echo "default" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: \"$with_progname\"" >&5 +$as_echo "\"$with_progname\"" >&6; } + +cat >>confdefs.h <<_ACEOF +#define PROG_NAME "$with_progname" +_ACEOF + + fi + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: default" >&5 +$as_echo "default" >&6; } + +fi + + # Checks for header files. for ac_header in execinfo.h fcntl.h malloc.h netdb.h stdlib.h string.h unistd.h arpa/inet.h mach/mach.h netinet/in.h sys/file.h sys/socket.h termios.h do : diff --git a/configure.ac b/configure.ac index 357b911..f17039d 100644 --- a/configure.ac +++ b/configure.ac @@ -35,13 +35,11 @@ AC_ARG_ENABLE(libconfig,[--enable-libconfig/--disable-libconfig], AC_MSG_RESULT([disabled]) else AC_MSG_RESULT([enabled]) - AC_CHECK_LIB([config],[config_init],AC_DEFINE(ENABLE_LIBCONFIG,1,[enable libconfig]),AC_MSG_ERROR([No libconfig found. Try --disable-libconfig])) - [EXTRA_LIBS="${EXTRA_LIBS} -lconfig" ; ] + AC_CHECK_LIB([config],[config_init],[],AC_MSG_ERROR([No libconfig found. Try --disable-libconfig])) fi ],[ AC_MSG_RESULT([enabled]) - AC_CHECK_LIB([config],[config_init],AC_DEFINE(ENABLE_LIBCONFIG,1,[enable libconfig]),AC_MSG_ERROR([No libconfig found. Try --disable-libconfig])) - [EXTRA_LIBS="${EXTRA_LIBS} -lconfig" ; ] + AC_CHECK_LIB([config],[config_init],[],AC_MSG_ERROR([No libconfig found. Try --disable-libconfig])) ]) AC_MSG_CHECKING([for liblua]) @@ -77,6 +75,21 @@ AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua], AC_MSG_ERROR([No lua found. Try --disable-liblua]) ]) ]) + +#check for custom prog name +AC_ARG_WITH(progname,[--with-progname=], + [ + if test "x$with_progname" = "xno" ; then + AC_MSG_RESULT([default]) + elif test "x$with_progname" = "xyes" ; then + AC_MSG_RESULT([default]) + else + AC_MSG_RESULT(["$with_progname"]) + AC_DEFINE_UNQUOTED([PROG_NAME], ["$with_progname"], [Use custom prog name]) + fi + ],[ + AC_MSG_RESULT([default]) + ]) # Checks for header files. AC_CHECK_HEADERS([execinfo.h fcntl.h malloc.h netdb.h stdlib.h string.h unistd.h arpa/inet.h mach/mach.h netinet/in.h sys/file.h sys/socket.h termios.h]) diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..c83e5f7 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +telegram-cli (0.1-1) unstable; urgency=low + + * Initial release (Closes #737563) + + -- Cleto Martín Mon, 03 Feb 2014 20:00:03 +0000 diff --git a/debian/clean b/debian/clean new file mode 100644 index 0000000..33ceb8f --- /dev/null +++ b/debian/clean @@ -0,0 +1 @@ +Makefile \ No newline at end of file diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..5e7e1f0 --- /dev/null +++ b/debian/control @@ -0,0 +1,36 @@ +Source: telegram-cli +Section: net +Priority: optional +Maintainer: Cleto Martín +Build-Depends: debhelper (>= 8.0.0), + autotools-dev, + autoconf-archive, + libreadline-dev, + libconfig-dev, + libssl-dev, + lua5.2, + liblua5.2-dev +Standards-Version: 3.9.4 +Homepage: https://github.com/vysheng/tg +Vcs-Git: git://github.com/vysheng/tg.git +Vcs-Browser: https://github.com/vysheng/tg + +Package: telegram-cli +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Command-line interface for Telegram messenger + Telegram messenger is a cloud-based instant messaging designed for + smart phones and similar to Whatsapp but more flexible, and + powerful. You can send messages, photos, videos and documents to + people who are in your phone contacts (and have Telegram). Telegram + also supports secret chats whose provide a private (encrypted) way of + communication. + . + This package contains a command-line based client for Telegram with + the following features: + * Colored terminal messages. + * Message management: history, stats, etc. + * Group chat: create and manage groups. + * Secret chat: secured and encrypted conversations. + * Contact management: add/edit/remove contacts. + * Multimedia support: send/load photos and videos. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..2e46990 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,28 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: telegram-cli +Source: https://github.com/vysheng/tg + +Files: * +Copyright: 2013 Vitaly Valtman +License: GPL-2.0+ + +Files: debian/* +Copyright: 2014 Cleto Martín +License: GPL-2.0+ + +License: GPL-2.0+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..b43bf86 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +README.md diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..f0f94de --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +telegram usr/bin diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..0f41aca --- /dev/null +++ b/debian/rules @@ -0,0 +1,17 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +VERSION=$(shell dpkg-parsechangelog | sed -n 's/^Version: //p' | cut -f1 -d'-') +PACKAGE_NAME=$(shell dpkg-parsechangelog | sed -n 's/^Source: //p') + +%: + dh $@ --with autotools-dev + +build-orig: + mkdir -p $(PACKAGE_NAME)-$(VERSION) + tar --exclude=ax_lua.m4 --exclude=debian --exclude=\.pc \ + --exclude=$(PACKAGE_NAME)-$(VERSION) -cf - . \ + | ( cd $(PACKAGE_NAME)-$(VERSION) && tar xf - ) + tar -cf ../$(PACKAGE_NAME)_$(VERSION).orig.tar $(PACKAGE_NAME)-$(VERSION) + $(RM) -r $(PACKAGE_NAME)-$(VERSION) + xz ../$(PACKAGE_NAME)_$(VERSION).orig.tar diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..2148331 --- /dev/null +++ b/debian/watch @@ -0,0 +1,4 @@ +version=3 + +opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/tg-$1\.tar\.gz/ \ + https://github.com/vysheng/tg/tags .*/v?(\d\S*)\.tar\.gz diff --git a/gentoo/telegram-cli/Manifest b/gentoo/telegram-cli/Manifest new file mode 100644 index 0000000..f39008c --- /dev/null +++ b/gentoo/telegram-cli/Manifest @@ -0,0 +1 @@ +EBUILD telegram-cli-9999.ebuild 641 SHA256 4597e2f84c36b1ee02ecc415c399408bb8536b456e94370e996d57477db621be SHA512 287da263c9a4ba2058bf2f5844599432619053abc9249fd5725ed7b5e920c5c02e2493ad7b07f89177933b2c15394d939e7dc7dbf05d5873c32e55c9ec614d4c WHIRLPOOL 73dee37f91f1d4b747afc35c0a0cb2efb141d37702c71a7a9d188d2e1d727375c0ee3e7a1192e6c4c34f17ba1303f3a0be47b24272b5378ff255bce1a4a281be diff --git a/gentoo/telegram-cli/telegram-cli-9999.ebuild b/gentoo/telegram-cli/telegram-cli-9999.ebuild new file mode 100644 index 0000000..bf8ed3d --- /dev/null +++ b/gentoo/telegram-cli/telegram-cli-9999.ebuild @@ -0,0 +1,31 @@ +# Copyright 1999-2013 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +EAPI=5 + +EGIT_REPO_URI="https://github.com/vysheng/tg.git" +inherit git-2 +IUSE="lua" +DESCRIPTION="Command line interface client for Telegram" +HOMEPAGE="https://github.com/vysheng/tg" +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~amd64 ~x86" + +DEPEND="sys-libs/zlib + sys-libs/readline + dev-libs/libconfig + dev-libs/openssl + lua? ( dev-lang/lua )" + +src_configure() { + econf $(use_enable lua liblua ) --with-progname=telegram-cli +} + +src_install() { + newbin telegram telegram-cli + + insinto /etc/telegram-cli/ + newins tg.pub server.pub +} diff --git a/main.c b/main.c index e75e821..a8d23fe 100644 --- a/main.c +++ b/main.c @@ -43,7 +43,7 @@ #include #endif #include -#ifdef ENABLE_LIBCONFIG +#ifdef HAVE_LIBCONFIG #include #endif @@ -247,7 +247,7 @@ void running_for_first_time (void) { } } -#ifdef ENABLE_LIBCONFIG +#ifdef HAVE_LIBCONFIG void parse_config_val (config_t *conf, char **s, char *param_name, const char *default_name, const char *path) { static char buf[1000]; int l = 0; @@ -433,7 +433,9 @@ void print_backtrace (void) { } #else void print_backtrace (void) { - write (1, "No libexec. Backtrace disabled\n", 32); + if (write (1, "No libexec. Backtrace disabled\n", 32) < 0) { + // Sad thing + } } #endif diff --git a/rpm/telegram-cli-Beta-2.fc20.x86_64.rpm b/rpm/telegram-cli-Beta-2.fc20.x86_64.rpm new file mode 100644 index 0000000..0deaace Binary files /dev/null and b/rpm/telegram-cli-Beta-2.fc20.x86_64.rpm differ diff --git a/telegram-cli.spec b/telegram-cli.spec new file mode 100644 index 0000000..241e5b6 --- /dev/null +++ b/telegram-cli.spec @@ -0,0 +1,46 @@ +Name: telegram-cli +Version: Beta +Release: 2%{?dist} +Summary: Private fast and open platform for instant messaging + +Packager: Pablo Iranzo Gómez (Pablo.Iranzo@gmail.com) +Group: Internet/Messaging +License: GPL +URL: https://github.com/vysheng/tg +Source: master.zip + +BuildRequires: lua-devel, openssl-devel, libconfig-devel, readline-devel, wget +#Requires: wget + +%description +Telegram is an Open Source messaging platform for mobile, desktop focused on privacy. + + + + +%prep +[ -d %{name} ] && rm -Rfv %{name} +mkdir %{name} +cd %{name} +wget -O master.zip https://github.com/vysheng/tg/archive/master.zip +unzip master.zip +cd tg-master +./configure +make %{?_smp_mflags} + + +%install +cd %{name} +cd tg-master +%{__install} -D -m0755 telegram %{buildroot}/usr/bin/telegram +%{__install} -D -m0644 tg.pub %{buildroot}/etc/telegram/server.pub + +%files +/usr/bin/telegram +/etc/telegram/server.pub + +%changelog +* Tue Feb 4 2014 Pablo Iranzo Gómez (Pablo.Iranzo@gmail.com) +- Add server key to /etc/telegram/ +* Sat Feb 1 2014 Pablo Iranzo Gómez (Pablo.Iranzo@gmail.com) +- Initial SPEC file