From e01535ee6ea3d756528aab1b4ca454a2002daf9c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Sun, 10 Feb 2019 11:03:19 +0100 Subject: [PATCH] Add mutt-ics telegram-cli --- default.nix | 29 ++++++++++ fetched/mutt-ics.json | 15 +++++ fetched/telegram-cli.json | 15 +++++ fetched/telegram-history-dump.json | 15 +++++ patches/telegram-cli.patch | 90 ++++++++++++++++++++++++++++++ 5 files changed, 164 insertions(+) create mode 100644 fetched/mutt-ics.json create mode 100644 fetched/telegram-cli.json create mode 100644 fetched/telegram-history-dump.json create mode 100644 patches/telegram-cli.patch diff --git a/default.nix b/default.nix index 75e1e0a..40cac81 100644 --- a/default.nix +++ b/default.nix @@ -252,6 +252,35 @@ let buildInputs = old.buildInputs ++ [ tokyocabinet bzip2 ]; }); + mypkgs.mutt-ics = with python3Packages; buildPythonApplication (fetchedGithub ./fetched/mutt-ics.json // rec { + propagatedBuildInputs = [ icalendar ]; + }); + + mypkgs.telegram-cli = stdenv.mkDerivation (fetchedGithub ./fetched/telegram-cli.json // rec { + patches = [ + ./patches/telegram-cli.patch + ]; + buildInputs = [ pkgconfig libevent lua jansson openssl readline zlib libconfig ]; + preBuild = '' + sed -i -e 's@"/etc/" PROG_NAME "/server.pub"@"'$out'/etc/server.pub"@' main.c + ''; + installPhase = '' + mkdir -p $out + install -Dm755 bin/telegram-cli $out/bin/telegram-cli + install -Dm644 tg-server.pub $out/etc/server.pub + install -Dm644 debian/telegram-cli.8 $out/man/man8/telegram-cli.8 + ''; + }); + + mypkgs.telegram-history-dump = stdenv.mkDerivation (fetchedGithub ./fetched/telegram-history-dump.json // rec { + installPhase = '' + mkdir -p $out/lib $out/bin + cp -a $src $out/lib/telegram-history-dump + ln -s $out/lib/telegram-history-dump/telegram-history-dump.rb $out/bin/telegram-history-dump + ''; + buildInputs = [ ruby ]; + }); + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks in diff --git a/fetched/mutt-ics.json b/fetched/mutt-ics.json new file mode 100644 index 0000000..ae8ed37 --- /dev/null +++ b/fetched/mutt-ics.json @@ -0,0 +1,15 @@ +{ + "tag": "d291187-master", + "meta": { + "name": "mutt-ics", + "url": "https://github.com/dmedvinsky/mutt-ics", + "branch": "master" + }, + "github": { + "owner": "dmedvinsky", + "repo": "mutt-ics", + "rev": "d29118788f291f67d34fefa6eda9f95846a2fe34", + "sha256": "0kqzngsvzjq5gpf60jhfmb2xzjznvk172khf4dlcb72n3ak4rb92", + "fetchSubmodules": true + } +} diff --git a/fetched/telegram-cli.json b/fetched/telegram-cli.json new file mode 100644 index 0000000..53e0a7b --- /dev/null +++ b/fetched/telegram-cli.json @@ -0,0 +1,15 @@ +{ + "tag": "6547c0b-master", + "meta": { + "name": "telegram-cli", + "url": "https://github.com/vysheng/tg", + "branch": "master" + }, + "github": { + "owner": "vysheng", + "repo": "tg", + "rev": "6547c0b21b977b327b3c5e8142963f4bc246187a", + "sha256": "07sss5cnw2ygd7mp8f5532lmj7qm6ywqf4cjaq5g13i8igzqzwzj", + "fetchSubmodules": true + } +} diff --git a/fetched/telegram-history-dump.json b/fetched/telegram-history-dump.json new file mode 100644 index 0000000..487df73 --- /dev/null +++ b/fetched/telegram-history-dump.json @@ -0,0 +1,15 @@ +{ + "tag": "468ea91-master", + "meta": { + "name": "telegram-history-dump", + "url": "https://github.com/tvdstaaij/telegram-history-dump", + "branch": "master" + }, + "github": { + "owner": "tvdstaaij", + "repo": "telegram-history-dump", + "rev": "468ea91e543529b54bc2c5ea28b1ea17f362fd3e", + "sha256": "1wmwiqacfa56bmwx50njnb15cg0fy6rbdrmrjd4xfbh8bs6yp0gh", + "fetchSubmodules": true + } +} diff --git a/patches/telegram-cli.patch b/patches/telegram-cli.patch new file mode 100644 index 0000000..2d2b7b0 --- /dev/null +++ b/patches/telegram-cli.patch @@ -0,0 +1,90 @@ +diff --git a/tgl/crypto/rsa_pem_openssl.c b/tgl/crypto/rsa_pem_openssl.c +index db653f2..5e6a697 100644 +--- a/tgl/crypto/rsa_pem_openssl.c ++++ b/tgl/crypto/rsa_pem_openssl.c +@@ -36,6 +36,12 @@ TGLC_WRAPPER_ASSOC(rsa,RSA) + // TODO: Refactor crucial struct-identity into its own header. + TGLC_WRAPPER_ASSOC(bn,BIGNUM) + ++/* ++ * Since OpenSSL version 1.1.0 the RSA struct (rsa_st) is opaque, ++ * see also https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes ++ */ ++#if (OPENSSL_VERSION_NUMBER < 0x10100000L) ++ + TGLC_rsa *TGLC_rsa_new (unsigned long e, int n_bytes, const unsigned char *n) { + RSA *ret = RSA_new (); + ret->e = unwrap_bn (TGLC_bn_new ()); +@@ -47,7 +53,30 @@ TGLC_rsa *TGLC_rsa_new (unsigned long e, int n_bytes, const unsigned char *n) { + #define RSA_GETTER(M) \ + TGLC_bn *TGLC_rsa_ ## M (TGLC_rsa *key) { \ + return wrap_bn (unwrap_rsa (key)->M); \ +- } \ ++ } ++ ++#else // OPENSSL_VERSION_NUMBER ++ ++TGLC_rsa *TGLC_rsa_new (unsigned long e, int n_bytes, const unsigned char *n) { ++ RSA *ret = RSA_new (); ++ BIGNUM *ret_e = unwrap_bn (TGLC_bn_new ()); ++ BIGNUM *ret_n = unwrap_bn (TGLC_bn_bin2bn (n, n_bytes, NULL)); ++ RSA_set0_key (ret, ret_n, ret_e, NULL); ++ TGLC_bn_set_word (wrap_bn (ret_e), e); ++ return wrap_rsa (ret); ++} ++ ++#define RSA_GETTER(M) \ ++TGLC_bn *TGLC_rsa_ ## M (TGLC_rsa *key) { \ ++ BIGNUM *rsa_n, *rsa_e, *rsa_d; \ ++ RSA_get0_key(unwrap_rsa (key), \ ++ (const BIGNUM **) &rsa_n, \ ++ (const BIGNUM **) &rsa_e, \ ++ (const BIGNUM **) &rsa_d); \ ++ return wrap_bn (rsa_ ## M); \ ++} ++ ++#endif // OPENSSL_VERSION_NUMBER + + RSA_GETTER(n); + RSA_GETTER(e); +@@ -60,4 +89,4 @@ TGLC_rsa *TGLC_pem_read_RSAPublicKey (FILE *fp) { + return wrap_rsa (PEM_read_RSAPublicKey (fp, NULL, NULL, NULL)); + } + +-#endif ++#endif // TGL_AVOID_OPENSSL +diff --git a/tgl/mtproto-utils.c b/tgl/mtproto-utils.c +index 0948bc8..cfdb216 100644 +--- a/tgl/mtproto-utils.c ++++ b/tgl/mtproto-utils.c +@@ -98,7 +98,7 @@ static unsigned long long BN2ull (TGLC_bn *b) { + 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. ++// 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,7 +112,7 @@ static void ull2BN (TGLC_bn *b, unsigned long long val) { + 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. ++// 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); +diff --git a/tgl/tl-parser/tl-parser.c b/tgl/tl-parser/tl-parser.c +index 524b196..aeadbd2 100644 +--- a/tgl/tl-parser/tl-parser.c ++++ b/tgl/tl-parser/tl-parser.c +@@ -1903,7 +1903,7 @@ struct tl_combinator_tree *tl_parse_args134 (struct tree *T) { + //assert (S->data); + char *name = S->data; + if (!name) { +- static char s[20]; ++ static char s[21]; + sprintf (s, "%lld", lrand48 () * (1ll << 32) + lrand48 ()); + name = s; + } -- 2.41.0