Bug 215064

Summary: net-im/telegram: update to upstream version 1.4.1
Product: Ports & Packages Reporter: Matthias Apitz <guru>
Component: Individual Port(s)Assignee: Carlos J. Puga Medina <cpm>
Status: Closed FIXED    
Severity: Affects Some People CC: amdmi3, feld, guru, junovitch
Priority: --- Keywords: patch, patch-ready
Version: LatestFlags: cpm: maintainer-feedback+
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch-telegram-1.4.1
cpm: maintainer-approval+
patch-telegram-1.4.1.g20161227 cpm: maintainer-approval+

Description Matthias Apitz 2016-12-05 06:33:36 UTC
the port should be updated to the version 1.4.1 available at:

https://github.com/vysheng/tg/archive/master.zip
https://github.com/vysheng/tg.git

I got it compiled and running on 11-CURRENT amd64 with the following changes in the sources:


*** tg/tgl/tl-parser/portable_endian.h.orig	2016-12-02 21:16:58.559277000 +0100
--- tg/tgl/tl-parser/portable_endian.h	2016-12-02 21:17:15.223912000 +0100
***************
*** 53,58 ****
--- 53,59 ----
  
  #	include <sys/endian.h>
  
+ /*
  #	define be16toh(x) betoh16(x)
  #	define le16toh(x) letoh16(x)
  
***************
*** 61,66 ****
--- 62,68 ----
  
  #	define be64toh(x) betoh64(x)
  #	define le64toh(x) letoh64(x)
+ */
  
  #elif defined(__WINDOWS__)
  
*** tg/tgl/mtproto-utils.c.orig	2016-11-30 10:05:22.000000000 +0100
--- tg/tgl/mtproto-utils.c	2016-11-30 10:58:57.000000000 +0100
***************
*** 98,104 ****
    if (sizeof (unsigned long) == 8) {
      return TGLC_bn_get_word (b);
    } else if (sizeof (unsigned long long) == 8) {
!     assert (0); // As long as nobody ever uses this code, assume it is broken.
      unsigned long long tmp;
      /* Here be dragons, but it should be okay due to be64toh */
      TGLC_bn_bn2bin (b, (unsigned char *) &tmp);
--- 98,104 ----
    if (sizeof (unsigned long) == 8) {
      return TGLC_bn_get_word (b);
    } else if (sizeof (unsigned long long) == 8) {
!     // assert (0); // As long as nobody ever uses this code, assume it is broken.
      unsigned long long tmp;
      /* Here be dragons, but it should be okay due to be64toh */
      TGLC_bn_bn2bin (b, (unsigned char *) &tmp);
***************
*** 112,118 ****
    if (sizeof (unsigned long) == 8 || val < (1ll << 32)) {
      TGLC_bn_set_word (b, val);
    } else if (sizeof (unsigned long long) == 8) {
!     assert (0); // As long as nobody ever uses this code, assume it is broken.
      htobe64(val);
      /* Here be dragons, but it should be okay due to htobe64 */
      TGLC_bn_bin2bn ((unsigned char *) &val, 8, b);
--- 112,118 ----
    if (sizeof (unsigned long) == 8 || val < (1ll << 32)) {
      TGLC_bn_set_word (b, val);
    } else if (sizeof (unsigned long long) == 8) {
!     // assert (0); // As long as nobody ever uses this code, assume it is broken.
      htobe64(val);
      /* Here be dragons, but it should be okay due to htobe64 */
      TGLC_bn_bin2bn ((unsigned char *) &val, 8, b);
*** tg/Makefile.in.orig	2016-11-30 10:05:04.000000000 +0100
--- tg/Makefile.in	2016-12-03 09:27:23.065984000 +0100
***************
*** 6,12 ****
  DEFS=@DEFS@
  COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC
  EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ @OPENSSL_LIBS@
! LOCAL_LDFLAGS=-rdynamic -ggdb -levent ${EXTRA_LIBS} -ldl -lpthread -lutil
  LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS}
  
  DEP=dep
--- 6,12 ----
  DEFS=@DEFS@
  COMPILE_FLAGS=${CFLAGS} ${CPFLAGS} ${CPPFLAGS} ${DEFS} -Wall -Werror -Wextra -Wno-missing-field-initializers -Wno-deprecated-declarations -fno-strict-aliasing -fno-omit-frame-pointer -ggdb -Wno-unused-parameter -fPIC
  EXTRA_LIBS=@LIBS@ @EXTRA_LIBS@ @OPENSSL_LIBS@
! LOCAL_LDFLAGS=-rdynamic -ggdb -levent ${EXTRA_LIBS} -lpthread -lutil
  LINK_FLAGS=${LDFLAGS} ${LOCAL_LDFLAGS}
  
  DEP=dep
Comment 1 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-06 11:26:38 UTC
I'll take a look.

Thanks, Matthias :)
Comment 2 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-08 12:43:03 UTC
I checked the telegram GH repository and a lot of pull requests are pending. The latest stable release is 1.3.1 that we already have it into the ports tree.

It's worth to ask to the telegram developer if he has some planning or roadmap to add telegram 1.4.1 as a new stable tag.

https://github.com/vysheng/tg/releases
Comment 3 Matthias Apitz 2016-12-22 06:21:54 UTC
I have not seen any message from the original author for months, not even in the ticket system. The version 1.4.1 I do run from git has much better support for so called 'channels':

> cha TAB
channel_get_admins    channel_kick          channel_set_photo     chat_set_photo
channel_get_members   channel_leave         channel_set_username  chat_upgrade
channel_info          channel_list          chat_add_user         chat_with_peer
channel_invite        channel_set_about     chat_del_user         
channel_join          channel_set_admin     chat_info             
> channel_info 
> channel_list
Channel SysAdmins de Cuba: 4714 unread
> channel_info SysAdmins_de_Cuba
Channel [megagroup] SysAdmins de Cuba @sysadmincuba (#1084453424):
	about: Consulta, Ayuda, Instalacion sobre cualquier tema referente a Administracion de Redes en Linux o Windows
	87 participants, 0 admins, 0 kicked
> channel_info @sysadmincuba
Channel [megagroup] SysAdmins de Cuba @sysadmincuba (#1084453424):
	about: Consulta, Ayuda, Instalacion sobre cualquier tema referente a Administracion de Redes en Linux o Windows
	87 participants, 0 admins, 0 kicked
...


we should move to this, I'd recommend.
Comment 4 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-25 19:30:43 UTC
Well, I'll try to contact with telegram-cli developer. While he responds or not, I'll check the changes you've submitted.
Comment 5 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-27 02:41:29 UTC
Created attachment 178309 [details]
patch-telegram-1.4.1

- Update telegram to 1.4.1
Comment 6 Mark Felder freebsd_committer freebsd_triage 2016-12-27 03:57:39 UTC
approved
Comment 7 Dmitry Marakasov freebsd_committer freebsd_triage 2016-12-27 09:00:14 UTC
Approved.

Though I don't like to use versions which do not have an official tag. Since 1.4.1 may not change for following updates, I recommend e.g PORTVERSION= 1.4.1.git20161227. The nice thing about it is that version comparison counts it as prerelease, e.g. when official 1.4.1 is released, it will be higher version (1.4.1 > 1.4.1.git20161227), so the update won't require PORTEPOCH bump.

Also, Matthias, please always use unified diffs (diff -u) when posting patches.
Comment 8 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-27 13:29:48 UTC
(In reply to Dmitry Marakasov from comment #7)

I like your approach, so I have modified PORTVERSION to 1.4.1.g20161227.

Thanks for the review.
Comment 9 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-27 13:31:18 UTC
Created attachment 178325 [details]
patch-telegram-1.4.1.g20161227

- Use PORTVERSION 1.4.1 -> 1.4.1.g20161227
Comment 10 commit-hook freebsd_committer freebsd_triage 2016-12-27 14:01:59 UTC
A commit references this bug:

Author: cpm
Date: Tue Dec 27 14:01:28 UTC 2016
New revision: 429615
URL: https://svnweb.freebsd.org/changeset/ports/429615

Log:
  net-im/telegram: Update to 1.4.1.g20161227

  - Update telegram 1.3.1 -> 1.4.1.g20161227

  PR:		215064
  Reported by:	Matthias Apitz <guru@unixarea.de>
  Reviewed by:	amdmi3
  Approved by:	amdmi3, feld (mentors)

Changes:
  head/net-im/telegram/Makefile
  head/net-im/telegram/distinfo
  head/net-im/telegram/files/
  head/net-im/telegram/files/patch-Makefile.in
  head/net-im/telegram/files/patch-lua-tg.c
  head/net-im/telegram/files/patch-tgl_mtproto-utils.c
  head/net-im/telegram/files/patch-tgl_tl-parser_portable__endian.h
Comment 11 Carlos J. Puga Medina freebsd_committer freebsd_triage 2016-12-27 14:03:27 UTC
Committed, thanks!