From b90f91401f8e5b5c36ce42a0c7d31ab07fb7bea7 Mon Sep 17 00:00:00 2001 From: infactum Date: Sun, 24 Feb 2019 11:24:56 +0500 Subject: [PATCH 1/5] semicolon missed --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ab4a627..c15cc3d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,7 +37,7 @@ build_script: mkdir build; docker run --rm -v "$(pwd)":/src "$docker_image":"$docker_tag" /bin/bash -c " mkdir build && cd build; - export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release /src + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release /src; cmake --build .; chmod +x tg2sip; chmod +x gen_db; From 713914b3ad95e5079a34cf0f5d0fd87e514a4314 Mon Sep 17 00:00:00 2001 From: infactum Date: Sun, 24 Feb 2019 17:20:44 +0500 Subject: [PATCH 2/5] appimage support --- appveyor.yml | 34 +++- buildenv/Dockerfile.centos6 | 72 ++++++++ buildenv/app.desktop | 7 + buildenv/icon.svg | 320 ++++++++++++++++++++++++++++++++++++ libtgvoip/CMakeLists.txt | 1 + 5 files changed, 432 insertions(+), 2 deletions(-) create mode 100644 buildenv/Dockerfile.centos6 create mode 100644 buildenv/app.desktop create mode 100644 buildenv/icon.svg diff --git a/appveyor.yml b/appveyor.yml index c15cc3d..1da1d42 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,6 +24,9 @@ environment: - target_name: CentOS 7 docker_tag: centos7 + - target_name: AppImage + docker_tag: centos6 + init: - sh: | docker login -u "$docker_login" -p "$docker_password" @@ -34,6 +37,7 @@ install: build_script: - sh: >- + if [ "$target_name" = "AppImage" ] ; then exit 0; fi ; mkdir build; docker run --rm -v "$(pwd)":/src "$docker_image":"$docker_tag" /bin/bash -c " mkdir build && cd build; @@ -42,9 +46,35 @@ build_script: chmod +x tg2sip; chmod +x gen_db; cp tg2sip /src/build; - cp gen_db /src/build;" + cp gen_db /src/build;" 7z a tg2sip.zip ./build/tg2sip ./build/gen_db ./settings.ini; + - sh: >- + if [ "$target_name" != "AppImage" ] ; then exit 0; fi ; + mkdir build; + docker run --rm -v "$(pwd)":/src "$docker_image":"$docker_tag" /bin/bash -c " + mkdir build && cd build; + export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release /src; + cmake --build .; + chmod +x tg2sip; + chmod +x gen_db; + linuxdeploy --appdir /src/build/tg2sip -e tg2sip; + linuxdeploy --appdir /src/build/tg2sip -e gen_db;" + wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool.AppImage; + chmod +x appimagetool.AppImage; + wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -O chmod +x linuxdeploy.AppImage; + chmod +x linuxdeploy.AppImage; + ./linuxdeploy.AppImage --appdir ./build/tg2sip -d ./buildenv/app.desktop -i ./buildenv/icon.svg; + ./linuxdeploy.AppImage --appdir ./build/gen_db -d ./buildenv/app.desktop -i ./buildenv/icon.svg; + ./appimagetool.AppImage tg2sip; + ./appimagetool.AppImage gen_db; + 7z a tg2sip.zip ./build/tg2sip-x86_64.AppImage ./build/gen_db-x86_64.AppImage ./settings.ini; + after_build: - sh: docker push "$docker_image":"$docker_tag" - - sh: appveyor PushArtifact tg2sip.zip -FileName tg2sip_"$docker_tag".zip -DeploymentName "TG2SIP $target_name" \ No newline at end of file + - sh: >- + if [ "$target_name" != "AppImage" ] ; then + appveyor PushArtifact tg2sip.zip -FileName tg2sip_"$docker_tag".zip -DeploymentName "TG2SIP $target_name" + else + appveyor PushArtifact tg2sip.zip -FileName tg2sip.zip -DeploymentName "TG2SIP AppImage" + fi \ No newline at end of file diff --git a/buildenv/Dockerfile.centos6 b/buildenv/Dockerfile.centos6 new file mode 100644 index 0000000..8b3b14e --- /dev/null +++ b/buildenv/Dockerfile.centos6 @@ -0,0 +1,72 @@ +FROM centos:6 as builder + +# https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ +RUN yum -y install centos-release-scl yum-utils \ + && yum-config-manager --enable rhel-server-rhscl-7-rpms \ + && yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ + +RUN yum install -y \ + make \ + git wget \ + zlib-devel openssl-devel gperf \ + pkgconfig ccache gperf unzip \ + libpng-devel libjpeg-devel patchelf \ + epel-release \ + && yum install -y opus-devel + +RUN wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \ + && sh cmake-3.9.6-Linux-x86_64.sh --prefix=/usr --exclude-subdir + +COPY tdlib_header.patch / +COPY tdlib_threadname.patch / + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone https://github.com/tdlib/td.git \ + && cd td \ + && git reset --hard v1.2.0 \ + && git apply /tdlib_header.patch \ + && git apply /tdlib_threadname.patch \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release .. \ + && cmake --build . --target install \ + && cd / \ + && rm -rf td + +COPY config_site.h / + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone https://github.com/Infactum/pjproject.git \ + && cd pjproject \ + && cp /config_site.h pjlib/include/pj \ + && ./configure --disable-sound CFLAGS="-O3 -DNDEBUG" \ + && make dep && make && make install \ + && cd / \ + && rm -rf pjproject + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone -n https://github.com/gabime/spdlog.git \ + && cd spdlog \ + && git checkout tags/v0.17.0 \ + && mkdir build \ + && cd build \ + && cmake -DCMAKE_BUILD_TYPE=Release -DSPDLOG_BUILD_EXAMPLES=OFF -DSPDLOG_BUILD_TESTING=OFF .. \ + && cmake --build . --target install \ + && cd / \ + && rm -rf spdlog + +RUN source /opt/rh/devtoolset-7/enable \ + && git clone --recursive https://github.com/linuxdeploy/linuxdeploy.git \ + && cd linuxdeploy \ + && git checkout f9fc51a832185158d3e0e64858c83a941047871f \ + && mkdir build \ + && cd build \ + && export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig && cmake -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_CIMG=0 .. \ + && cmake --build . \ + && cp bin/linuxdeploy /usr/local/bin \ + && cd / \ + && rm -rf linuxdeploy + +COPY centos_entrypoint.sh / + +ENTRYPOINT ["/centos_entrypoint.sh"] diff --git a/buildenv/app.desktop b/buildenv/app.desktop new file mode 100644 index 0000000..252dfb2 --- /dev/null +++ b/buildenv/app.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Name= +Exec= +Terminal=true +Type=Application +Icon=icon +Categories=AudioVideo; \ No newline at end of file diff --git a/buildenv/icon.svg b/buildenv/icon.svg new file mode 100644 index 0000000..83ac565 --- /dev/null +++ b/buildenv/icon.svg @@ -0,0 +1,320 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/libtgvoip/CMakeLists.txt b/libtgvoip/CMakeLists.txt index 67ae01f..a9658fb 100644 --- a/libtgvoip/CMakeLists.txt +++ b/libtgvoip/CMakeLists.txt @@ -657,6 +657,7 @@ target_include_directories(libtgvoip PRIVATE ${PJSIP_INCLUDE_DIRS}) target_compile_definitions(libtgvoip PRIVATE + __STDC_FORMAT_MACROS WEBRTC_APM_DEBUG_DUMP=0 WEBRTC_POSIX WEBRTC_LINUX From b3d7b9859d8949aac191d25afbce83d1e75f1cad Mon Sep 17 00:00:00 2001 From: Infactum Date: Fri, 1 Mar 2019 23:29:38 +0500 Subject: [PATCH 3/5] CI update support for AppImage build --- appveyor.yml | 23 +++++++++++++---------- buildenv/Dockerfile.centos6 | 7 ++++--- buildenv/app.desktop | 7 ------- buildenv/gen_db.desktop | 8 ++++++++ buildenv/tg2sip.desktop | 8 ++++++++ 5 files changed, 33 insertions(+), 20 deletions(-) delete mode 100644 buildenv/app.desktop create mode 100644 buildenv/gen_db.desktop create mode 100644 buildenv/tg2sip.desktop diff --git a/appveyor.yml b/appveyor.yml index 1da1d42..72ce178 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,7 +37,7 @@ install: build_script: - sh: >- - if [ "$target_name" = "AppImage" ] ; then exit 0; fi ; + if [ "$target_name" != "AppImage" ] ; then mkdir build; docker run --rm -v "$(pwd)":/src "$docker_image":"$docker_tag" /bin/bash -c " mkdir build && cd build; @@ -48,9 +48,10 @@ build_script: cp tg2sip /src/build; cp gen_db /src/build;" 7z a tg2sip.zip ./build/tg2sip ./build/gen_db ./settings.ini; + fi; - - sh: >- - if [ "$target_name" != "AppImage" ] ; then exit 0; fi ; + - sh: >- + if [ "$target_name" = "AppImage" ] ; then mkdir build; docker run --rm -v "$(pwd)":/src "$docker_image":"$docker_tag" /bin/bash -c " mkdir build && cd build; @@ -59,16 +60,18 @@ build_script: chmod +x tg2sip; chmod +x gen_db; linuxdeploy --appdir /src/build/tg2sip -e tg2sip; - linuxdeploy --appdir /src/build/tg2sip -e gen_db;" + linuxdeploy --appdir /src/build/gen_db -e gen_db;" wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -O appimagetool.AppImage; chmod +x appimagetool.AppImage; - wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -O chmod +x linuxdeploy.AppImage; + wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage -O linuxdeploy.AppImage; chmod +x linuxdeploy.AppImage; - ./linuxdeploy.AppImage --appdir ./build/tg2sip -d ./buildenv/app.desktop -i ./buildenv/icon.svg; - ./linuxdeploy.AppImage --appdir ./build/gen_db -d ./buildenv/app.desktop -i ./buildenv/icon.svg; - ./appimagetool.AppImage tg2sip; - ./appimagetool.AppImage gen_db; - 7z a tg2sip.zip ./build/tg2sip-x86_64.AppImage ./build/gen_db-x86_64.AppImage ./settings.ini; + sudo chown -R "$(id -u)":"$(id -g)" ./build; + ./linuxdeploy.AppImage --appdir ./build/tg2sip -d ./buildenv/tg2sip.desktop -i ./buildenv/icon.svg; + ./linuxdeploy.AppImage --appdir ./build/gen_db -d ./buildenv/gen_db.desktop -i ./buildenv/icon.svg; + ./appimagetool.AppImage ./build/tg2sip; + ./appimagetool.AppImage ./build/gen_db; + 7z a tg2sip.zip ./tg2sip-x86_64.AppImage ./gen_db-x86_64.AppImage ./settings.ini; + fi; after_build: - sh: docker push "$docker_image":"$docker_tag" diff --git a/buildenv/Dockerfile.centos6 b/buildenv/Dockerfile.centos6 index 8b3b14e..7f29128 100644 --- a/buildenv/Dockerfile.centos6 +++ b/buildenv/Dockerfile.centos6 @@ -5,14 +5,15 @@ RUN yum -y install centos-release-scl yum-utils \ && yum-config-manager --enable rhel-server-rhscl-7-rpms \ && yum install -y devtoolset-7-gcc devtoolset-7-gcc-c++ -RUN yum install -y \ +RUN set -xe \ + && yum install -y \ make \ git wget \ zlib-devel openssl-devel gperf \ pkgconfig ccache gperf unzip \ - libpng-devel libjpeg-devel patchelf \ + libpng-devel libjpeg-devel \ epel-release \ - && yum install -y opus-devel + && yum install -y opus-devel patchelf RUN wget https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \ && sh cmake-3.9.6-Linux-x86_64.sh --prefix=/usr --exclude-subdir diff --git a/buildenv/app.desktop b/buildenv/app.desktop deleted file mode 100644 index 252dfb2..0000000 --- a/buildenv/app.desktop +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Name= -Exec= -Terminal=true -Type=Application -Icon=icon -Categories=AudioVideo; \ No newline at end of file diff --git a/buildenv/gen_db.desktop b/buildenv/gen_db.desktop new file mode 100644 index 0000000..8e5c3aa --- /dev/null +++ b/buildenv/gen_db.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=gen_db +Exec=gen_db +Comment=TG2SIP DB generator +Terminal=true +Type=Application +Icon=icon +Categories=AudioVideo; \ No newline at end of file diff --git a/buildenv/tg2sip.desktop b/buildenv/tg2sip.desktop new file mode 100644 index 0000000..f9ac64f --- /dev/null +++ b/buildenv/tg2sip.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Name=tg2sip +Exec=tg2sip +Comment=TG2SIP Voice Gateway +Terminal=true +Type=Application +Icon=icon +Categories=AudioVideo; \ No newline at end of file From e21fd4da62feb307c86ca0e8b1c0e20235e565e5 Mon Sep 17 00:00:00 2001 From: infactum Date: Fri, 1 Mar 2019 23:54:01 +0500 Subject: [PATCH 4/5] readme update --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a804d90..427c487 100644 --- a/README.md +++ b/README.md @@ -10,10 +10,16 @@ Your SIP PBX should be comaptible with `L16@48000` or `OPUS@48000` voice codec. ## Usage -1. Download prebuild versions for supported OS from CI or compile it yourself. -[Ubuntu 18.04 Bionic](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_bionic.zip?branch=master&job=Environment%3A%20target_name%3DUbuntu%20Bionic%2C%20docker_tag%3Dbionic) -[CentOS 7](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_centos7.zip?branch=master&job=Environment%3A%20target_name%3DCentOS%207%2C%20docker_tag%3Dcentos7) -Prebuild binaries requires OPUS libraries (`libopus0` for Ubuntu, `opus` for CentOS, etc). +1. Obtain binaries in one of convenient ways for you. + * Build them from source. + Requires C++17 supported comiler, which may be a trouble for old linux distros. + * Download prebuild native binaries for one of supported distros. + [Ubuntu 18.04 Bionic](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_bionic.zip?branch=master&job=Environment%3A%20target_name%3DUbuntu%20Bionic%2C%20docker_tag%3Dbionic) + [CentOS 7](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_centos7.zip?branch=master&job=Environment%3A%20target_name%3DCentOS%207%2C%20docker_tag%3Dcentos7) + Prebuild binaries requires OPUS libraries (`libopus0` for Ubuntu, `opus` for CentOS, etc). + * [Download](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip.zip?branch=master&job=Environment%3A%20target_name%3DAppImage2C%20docker_tag%3Dcentos6) universal AppImage package. + More information of what is AppImage can be found here https://appimage.org/ + 2. Obtain `api_id` and `api_hash` tokens from [this](https://my.telegram.org) page and put them in `settings.ini` file. 3. Login into telegram with `gen_db` app 4. Set SIP server settings in `settings.ini` @@ -25,6 +31,9 @@ SIP->Telegram calls can be done using 3 extension types: 2. `\+[\d]+` for calls by phone number 3. `[\d]+` for calls by telegram ID. Only known IDs allowed by telegram API. +All Telegram->SIP calls will be redirected to `callback_uri` SIP-URI that can be set in from `settings.ini` file. +Extra information about caller Telegram account will be added into `X-TG-*` SIP tags. + ## Donate [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=755FZWPRC9YGL&lc=US&item_name=TG2SIP¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted) From d394f11915f420562f6bc569c5f9653cbd4cf93c Mon Sep 17 00:00:00 2001 From: infactum Date: Fri, 1 Mar 2019 23:56:13 +0500 Subject: [PATCH 5/5] readme update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 427c487..0d78f25 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Your SIP PBX should be comaptible with `L16@48000` or `OPUS@48000` voice codec. [Ubuntu 18.04 Bionic](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_bionic.zip?branch=master&job=Environment%3A%20target_name%3DUbuntu%20Bionic%2C%20docker_tag%3Dbionic) [CentOS 7](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip_centos7.zip?branch=master&job=Environment%3A%20target_name%3DCentOS%207%2C%20docker_tag%3Dcentos7) Prebuild binaries requires OPUS libraries (`libopus0` for Ubuntu, `opus` for CentOS, etc). - * [Download](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip.zip?branch=master&job=Environment%3A%20target_name%3DAppImage2C%20docker_tag%3Dcentos6) universal AppImage package. + * [Download](https://ci.appveyor.com/api/projects/Infactum/tg2sip/artifacts/tg2sip.zip?branch=master&job=Environment%3A%20target_name%3DAppImage%2C%20docker_tag%3Dcentos6) universal AppImage package. More information of what is AppImage can be found here https://appimage.org/ 2. Obtain `api_id` and `api_hash` tokens from [this](https://my.telegram.org) page and put them in `settings.ini` file.