Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telegram on OpenWrt #213

Open
Noltari opened this issue Jun 29, 2014 · 19 comments
Open

Telegram on OpenWrt #213

Noltari opened this issue Jun 29, 2014 · 19 comments

Comments

@Noltari
Copy link

Noltari commented Jun 29, 2014

Hello guys,

I'm trying to port telegram to OpenWrt and I have some weird issues.

First here's what I have so far:
http://www.mediafire.com/download/51ar189inrp2w92/telegram.zip

It was impossible to use configure due to some tests being incompatible with cross-compiling (lua version), so I decided to switch to cmake.
After that, telegram was built succesfully, but there were some runtime issues with "my_clock_gettime". To solve this and fix the timers, I replaced all "my_clock_gettime" to the standard "clock_gettime".

But after fixing the timers there's another network issue which I cannot identify. Maybe someone who knows telegram better than me can help me with this :D.
Log: http://pastebin.com/LQxytw28

Regards,
Álvaro.

@vk496
Copy link

vk496 commented Apr 22, 2015

Hi

Some progress?

@petit-miner
Copy link

That would be very interesting for me as well

@ryzhovau
Copy link

ryzhovau commented Aug 7, 2015

I've made OpenWrt package and it's works as expected on Asus RT-N66U (256MB RAM). GCC 4.6.4, uClibc 0.9.32, MIPSEL.

@vysheng, is there any way to reduce RAM consumption? Even for RT-N66U 211MB is too much.

admin@RT-N66U:/tmp/home/root# ldd /opt/bin/telegram-cli
        libevent-2.0.so.5 => /opt/lib/libevent-2.0.so.5 (0x2aac0000)
        libjansson.so.4 => /opt/lib/libjansson.so.4 (0x2ab01000)
        libconfig.so.9 => /opt/lib/libconfig.so.9 (0x2ab1d000)
        libz.so.1 => /opt/lib/libz.so.1 (0x2ab37000)
        libm.so.0 => /opt/lib/libm.so.0 (0x2ab5b000)
        libncursesw.so.5 => /opt/lib/libncursesw.so.5 (0x2ab77000)
        libreadline.so.6 => /opt/lib/libreadline.so.6 (0x2abd8000)
        libssl.so.1.0.0 => /opt/lib/libssl.so.1.0.0 (0x2ac24000)
        libcrypto.so.1.0.0 => /opt/lib/libcrypto.so.1.0.0 (0x2ac87000)
        libdl.so.0 => /opt/lib/libdl.so.0 (0x2ae03000)
        libpthread.so.0 => /opt/lib/libpthread.so.0 (0x2ae16000)
        libutil.so.0 => /opt/lib/libutil.so.0 (0x2ae3b000)
        libc.so.0 => /opt/lib/libc.so.0 (0x2ae4c000)
        ld-uClibc.so.0 => /opt/lib/ld-uClibc.so.0 (0x2aaa8000)
admin@RT-N66U:/tmp/home/root# pmap -d `pidof telegram-cli`
8371:   telegram-cli -k /opt/etc/telegram-cli/tg-server.pub
Address   Kbytes Mode  Offset           Device    Mapping
00400000    3368 r-x-- 0000000000000000 008:00002 telegram-cli
00759000     144 rw--- 0000000000349000 008:00002 telegram-cli
0077d000  205688 rwx-- 000000000077d000 000:00000   [ anon ]
2aaa8000      28 r-x-- 0000000000000000 008:00002 ld-uClibc-0.9.32.so
2aaaf000       8 rw--- 000000002aaaf000 000:00000   [ anon ]
2aab2000       4 rw--- 000000002aab2000 000:00000   [ anon ]
2aabe000       4 r---- 0000000000006000 008:00002 ld-uClibc-0.9.32.so
2aabf000       4 rw--- 0000000000007000 008:00002 ld-uClibc-0.9.32.so
2aac0000     256 r-x-- 0000000000000000 008:00002 libevent-2.0.so.5.1.10
2ab00000       4 rw--- 0000000000040000 008:00002 libevent-2.0.so.5.1.10
2ab01000      44 r-x-- 0000000000000000 008:00002 libjansson.so.4.7.0
2ab0c000      64 ----- 000000002ab0c000 000:00000   [ anon ]
2ab1c000       4 rw--- 000000000000b000 008:00002 libjansson.so.4.7.0
2ab1d000      40 r-x-- 0000000000000000 008:00002 libconfig.so.9.1.3
2ab27000      60 ----- 000000002ab27000 000:00000   [ anon ]
2ab36000       4 rw--- 0000000000009000 008:00002 libconfig.so.9.1.3
2ab37000      80 r-x-- 0000000000000000 008:00002 libz.so.1.2.8
2ab4b000      60 ----- 000000002ab4b000 000:00000   [ anon ]
2ab5a000       4 rw--- 0000000000013000 008:00002 libz.so.1.2.8
2ab5b000      44 r-x-- 0000000000000000 008:00002 libm-0.9.32.so
2ab66000      64 ----- 000000002ab66000 000:00000   [ anon ]
2ab76000       4 rw--- 000000000000b000 008:00002 libm-0.9.32.so
2ab77000     312 r-x-- 0000000000000000 008:00002 libncursesw.so.5.9
2abc5000      64 ----- 000000002abc5000 000:00000   [ anon ]
2abd5000      12 rw--- 000000000004e000 008:00002 libncursesw.so.5.9
2abd8000     220 r-x-- 0000000000000000 008:00002 libreadline.so.6.3
2ac0f000      64 ----- 000000002ac0f000 000:00000   [ anon ]
2ac1f000      16 rw--- 0000000000037000 008:00002 libreadline.so.6.3
2ac23000       4 rw--- 000000002ac23000 000:00000   [ anon ]
2ac24000     312 r-x-- 0000000000000000 008:00002 libssl.so.1.0.0
2ac72000      64 ----- 000000002ac72000 000:00000   [ anon ]
2ac82000      20 rw--- 000000000004e000 008:00002 libssl.so.1.0.0
2ac87000    1384 r-x-- 0000000000000000 008:00002 libcrypto.so.1.0.0
2ade1000      60 ----- 000000002ade1000 000:00000   [ anon ]
2adf0000      72 rw--- 0000000000159000 008:00002 libcrypto.so.1.0.0
2ae02000       4 rw--- 000000002ae02000 000:00000   [ anon ]
2ae03000       8 r-x-- 0000000000000000 008:00002 libdl-0.9.32.so
2ae05000      60 ----- 000000002ae05000 000:00000   [ anon ]
2ae14000       4 r---- 0000000000001000 008:00002 libdl-0.9.32.so
2ae15000       4 rw--- 0000000000002000 008:00002 libdl-0.9.32.so
2ae16000      72 r-x-- 0000000000000000 008:00002 libpthread-0.9.32.so
2ae28000      60 ----- 000000002ae28000 000:00000   [ anon ]
2ae37000       4 r---- 0000000000011000 008:00002 libpthread-0.9.32.so
2ae38000       4 rw--- 0000000000012000 008:00002 libpthread-0.9.32.so
2ae39000       8 rw--- 000000002ae39000 000:00000   [ anon ]
2ae3b000       4 r-x-- 0000000000000000 008:00002 libutil-0.9.32.so
2ae3c000      60 ----- 000000002ae3c000 000:00000   [ anon ]
2ae4b000       4 rw--- 0000000000000000 008:00002 libutil-0.9.32.so
2ae4c000     616 r-x-- 0000000000000000 008:00002 libuClibc-0.9.32.so
2aee6000      60 ----- 000000002aee6000 000:00000   [ anon ]
2aef5000       4 r---- 0000000000099000 008:00002 libuClibc-0.9.32.so
2aef6000       4 rw--- 000000000009a000 008:00002 libuClibc-0.9.32.so
2aef7000    5164 rw--- 000000002aef7000 000:00000   [ anon ]
7fc9d000      84 rwx-- 000000007fc9d000 000:00000   [ stack ]
7fff7000       4 r-x-- 000000007fff7000 000:00000   [ anon ]
mapped: 218816K    writeable/private: 211268K    shared: 0K
admin@RT-N66U:/tmp/home/root# uname -a
Linux RT-N66U 2.6.22.19 #1 Thu Jul 16 23:16:01 EDT 2015 mips GNU/Linux

@vk496
Copy link

vk496 commented Aug 7, 2015

Can you post the source please?

Thnks

@ryzhovau
Copy link

ryzhovau commented Aug 7, 2015

@vk496, please, look at my previous post again.

@petit-miner
Copy link

Have you linked and stripped the telegram-cli ?
Telegram claim ~45mb of RAM on my Raspberry PI.
My AVM Router has only 32mb RAM so I plugged in a USB Stick with a Swap partition and it works just fine :)
I had problems with Lua and Python to compile with telegram, do you fixed this?

@ryzhovau
Copy link

Have you linked and stripped the telegram-cli ?
Telegram claim ~45mb of RAM on my Raspberry PI.

Yep. linked (see above) and stripped down to 3,7MB

I had problems with Lua and Python to compile with telegram, do you fixed this?

Yes, fixed just yesterday, now it supports LUA script, I've checked it with this ping-pong example.

@vk496
Copy link

vk496 commented Aug 23, 2015

Ok, sorry @ryzhovau

I've tried to compile on AR7XXX/AR9XXX but have issues with zlib

hecking event2/event.h presence... yes
checking for event2/event.h... yes
checking for pkg-config... /home/vk496/openwrt/trunk/staging_dir/host/bin/pkg-config
checking whether compiling and linking against OpenSSL works... yes
checking if zlib is wanted... yes
configure: WARNING: Sorry, /home/vk496/openwrt/trunk/staging_dir/target-mips_34kc_musl-1.1.10/opt does not exist, checking usual places
checking for inflateEnd in -lz... yes
checking zlib.h usability... no
checking zlib.h presence... no
checking for zlib.h... no
configure: error: No zlib found
make[2]: *** [/home/vk496/openwrt/trunk/build_dir/target-mips_34kc_musl-1.1.10/telegram-cli-1.3.1-20150730/.configured_yyyyyyyy] Error 1

zlib1g-dev is installed in my system

@ryzhovau
Copy link

@vk496, change some prefixes in Makefile:

  • /opt/lib > /usr/lib
  • /opt/include > /usr/include

and so on.

@vk496
Copy link

vk496 commented Aug 23, 2015

@ryzhovau yes, works. Now get this

mips-openwrt-linux-musl-gcc -I. -I. -I./tgl -Os -pipe -mno-branch-likely -mips32r2 -mtune=34kc -fno-caller-saves -fhonour-copts -Wno-error=unused-but-set-variable -msoft-float -mips16 -minterlink-mips16 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro   -I/home/vk496/openwrt/trunk/staging_dir/target-mips_34kc_musl-1.1.10/usr/include -I/home/vk496/openwrt/trunk/staging_dir/target-mips_34kc_musl-1.1.10/include -I/home/vk496/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_musl-1.1.10/usr/include -I/home/vk496/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_musl-1.1.10/include/fortify -I/home/vk496/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_musl-1.1.10/include  -I/home/vk496/openwrt/trunk/staging_dir/target-mips_34kc_musl-1.1.10/usr/include -I/home/vk496/openwrt/trunk/staging_dir/target-mips_34kc_musl-1.1.10/usr/include -I/home/vk496/openwrt/trunk/staging_dir/target-mips_34kc_musl-1.1.10/usr/include -I/home/vk496/openwrt/trunk/staging_dir/target-mips_34kc_musl-1.1.10/usr/include  -DHAVE_CONFIG_H -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC -iquote ./tgl -c -MP -MD -MF dep/tgl-net.d -MQ objs/tgl-net.o -o objs/tgl-net.o tgl/tgl-net.c
In file included from tgl/tgl-net.c:33:0:
/home/vk496/openwrt/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_musl-1.1.10/include/sys/fcntl.h:1:2: error: #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h> [-Werror=cpp]
 #warning redirecting incorrect #include <sys/fcntl.h> to <fcntl.h>
  ^
cc1: all warnings being treated as errors
make[3]: *** [objs/tgl-net.o] Error 1
make[3]: Leaving directory `/home/vk496/openwrt/trunk/build_dir/target-mips_34kc_musl-1.1.10/telegram-cli-1.3.1-20150730'
make[2]: *** [/home/vk496/openwrt/trunk/build_dir/target-mips_34kc_musl-1.1.10/telegram-cli-1.3.1-20150730/.built] Error 2
make[2]: Leaving directory `/home/vk496/openwrt/trunk/feeds/packages/net/telegram-cli'
make[1]: *** [package/feeds/packages/telegram-cli/compile] Error 2
make[1]: Leaving directory `/home/vk496/openwrt/trunk'
make: *** [package/telegram-cli/compile] Error 2

@ryzhovau
Copy link

Quite self-explained. Fix sources or disable warnings being treated as errors.

@vk496
Copy link

vk496 commented Aug 23, 2015

Sorry for noob questions...

I have tried to disable warnings as errors with Makefile arguments

CONFIGURE_ARGS += \
    --disable-Werror \
    --disable-python \
    --disable-valgrind \
    --with-zlib=$(STAGING_DIR)/usr

But still have the same problem. Some help please?

@ryzhovau
Copy link

There is no --disable-Werror defined. You have to find out where -Werror C flag came from. Take a look at .config from OpenWrt buildroot first.

@vk496
Copy link

vk496 commented Aug 24, 2015

My problem was using musl library. Recompiled with uClibc and compilation work. Now have problems again

root@OpenWrt:~# telegram-cli -k /etc/telegram-cli/tg-server.pub -vvvvv
change_user_group: can't find the user telegramd to switch to
Telegram-cli version 1.3.3, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 2.0.3
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/root/.telegram-cli]
 *** public key '/etc/telegram-cli/tg-server.pub' loaded successfully
 *** Couldn't open public key file: /etc/telegram-cli/server.pub
 *** Can not load key /etc/telegram-cli/server.pub
 *** public key 'tg-server.pub' loaded successfully
 *** Can not replay at 0 (magic = 0x7c0d22d8)
telegram-cli: tgl/binlog.c: 934: replay_log_event: Assertion `0' failed.
SIGNAL received
No libexec. Backtrace disabled

@raphikBIS
Copy link

Hello.
I got the same error than vk496

root@OpenWrt:~# telegram-cli -U root -k /usr/etc/telegram-cli/tg-server.pub -vvvvv
Telegram-cli version 1.3.3, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type show_license'. This is free software, and you are welcome to redistribute it under certain conditions; typeshow_license' for details.
Telegram-cli uses libtgl version 2.0.3
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/root/.telegram-cli]
*** public key '/usr/etc/telegram-cli/tg-server.pub' loaded successfully
*** Couldn't open public key file: /etc/telegram-cli/server.pub
*** Can not load key /etc/telegram-cli/server.pub
*** Couldn't open public key file: tg-server.pub
*** Can not load key tg-server.pub
*** Can not replay at 0 (magic = 0x7c0d22d8)
telegram-cli: tgl/binlog.c: 934: replay_log_event: Assertion `0' failed.
SIGNAL received
No libexec. Backtrace disabled

This is the Makefile I've used:

Copyright (C) 2011-2015 Entware

This is free software, licensed under the GNU General Public License v2.

See /LICENSE for more information.

include $(TOPDIR)/rules.mk

PKG_NAME:=telegram-cli
PKG_VERSION:=1.3.1
PKG_REV:=2052f4b381337d75e783facdbfad56b04dec1a9c
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE_URL:=https://github.com/vysheng/tg
PKG_SOURCE_PROTO:=git
PKG_SOURCE_VERSION:=$(PKG_REV)

PKG_REMOVE_FILES:=ax_lua.m4
PKG_FIXUP:=autoreconf

PKG_BUILD_DEPENDS:=telegram-cli/host

include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk

define Package/telegram-cli
SUBMENU:=Instant Messaging
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libconfig +libopenssl +libreadline +libevent2 +jansson
+libpthread +libncursesw +liblua
TITLE:=CLI for Telegram
URL:=$(PKG_SOURCE_URL)
MAINTAINER:=Entware team, entware.wl500g.info
endef

define Package/telegram-cli/description
Telegram messenger command-line interface
endef

CONFIGURE_ARGS +=
--disable-python
--disable-valgrind
--with-zlib=$(STAGING_DIR)/usr

CONFIGURE_VARS +=
LIBS=-lncursesw
LUA_INCLUDE="-I$(STAGING_DIR)/usr/include"
LUA_LIB="-L$(STAGING_DIR)/usr/lib -llua"

define Host/Configure
(cd $(HOST_BUILD_DIR)/tgl;
./configure;
)
endef

define Host/Compile
$(MAKE) $(HOST_JOBS) -C $(HOST_BUILD_DIR)/tgl $(HOST_MAKE_FLAGS)
endef

define Host/Install
endef

define Build/Compile
mkdir $(PKG_BUILD_DIR)/bin
$(CP) $(HOST_BUILD_DIR)/tgl/bin/* $(PKG_BUILD_DIR)/bin
$(call Build/Compile/Default)
endef

define Package/telegram-cli/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/telegram-cli $(1)/usr/bin
$(INSTALL_DIR) $(1)/usr/etc/telegram-cli
$(INSTALL_CONF) $(PKG_BUILD_DIR)/tg-server.pub $(1)/usr/etc/telegram-cli
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,telegram-cli))

Regards.

@ryzhovau
Copy link

ryzhovau commented Sep 3, 2015

@vk496, @raphikBIS, are you expecting me or @vysheng will debug your builds? strace, gdb are present in OpenWrt not only as decorations, please use it.

@raphikBIS
Copy link

@ryzhovau, thank you. I do really appreciate your suggestion.

@raphikBIS
Copy link

Despite the kind help received, I cannot compile anything able to work on Comtrend AR5387-un. Tests are over.
Best regards.

@canozip
Copy link

canozip commented Apr 11, 2016

How to install telegram on Open WRT or Arduino Yun step by step ? i am newbie at it

sorry for my bad english

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants