diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-02-10 11:03:19 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-02-10 11:03:19 +0100 |
commit | e01535ee6ea3d756528aab1b4ca454a2002daf9c (patch) | |
tree | 07ce467efbf0441b9eaaae49653091700657389d | |
parent | f80772dc1f1ffb3e6d36ea0b96f71c875bb9b2cd (diff) | |
download | Nix-e01535ee6ea3d756528aab1b4ca454a2002daf9c.tar.gz Nix-e01535ee6ea3d756528aab1b4ca454a2002daf9c.tar.zst Nix-e01535ee6ea3d756528aab1b4ca454a2002daf9c.zip |
Add mutt-ics telegram-cli
-rw-r--r-- | default.nix | 29 | ||||
-rw-r--r-- | fetched/mutt-ics.json | 15 | ||||
-rw-r--r-- | fetched/telegram-cli.json | 15 | ||||
-rw-r--r-- | fetched/telegram-history-dump.json | 15 | ||||
-rw-r--r-- | patches/telegram-cli.patch | 90 |
5 files changed, 164 insertions, 0 deletions
diff --git a/default.nix b/default.nix index 75e1e0a..40cac81 100644 --- a/default.nix +++ b/default.nix | |||
@@ -252,6 +252,35 @@ let | |||
252 | buildInputs = old.buildInputs ++ [ tokyocabinet bzip2 ]; | 252 | buildInputs = old.buildInputs ++ [ tokyocabinet bzip2 ]; |
253 | }); | 253 | }); |
254 | 254 | ||
255 | mypkgs.mutt-ics = with python3Packages; buildPythonApplication (fetchedGithub ./fetched/mutt-ics.json // rec { | ||
256 | propagatedBuildInputs = [ icalendar ]; | ||
257 | }); | ||
258 | |||
259 | mypkgs.telegram-cli = stdenv.mkDerivation (fetchedGithub ./fetched/telegram-cli.json // rec { | ||
260 | patches = [ | ||
261 | ./patches/telegram-cli.patch | ||
262 | ]; | ||
263 | buildInputs = [ pkgconfig libevent lua jansson openssl readline zlib libconfig ]; | ||
264 | preBuild = '' | ||
265 | sed -i -e 's@"/etc/" PROG_NAME "/server.pub"@"'$out'/etc/server.pub"@' main.c | ||
266 | ''; | ||
267 | installPhase = '' | ||
268 | mkdir -p $out | ||
269 | install -Dm755 bin/telegram-cli $out/bin/telegram-cli | ||
270 | install -Dm644 tg-server.pub $out/etc/server.pub | ||
271 | install -Dm644 debian/telegram-cli.8 $out/man/man8/telegram-cli.8 | ||
272 | ''; | ||
273 | }); | ||
274 | |||
275 | mypkgs.telegram-history-dump = stdenv.mkDerivation (fetchedGithub ./fetched/telegram-history-dump.json // rec { | ||
276 | installPhase = '' | ||
277 | mkdir -p $out/lib $out/bin | ||
278 | cp -a $src $out/lib/telegram-history-dump | ||
279 | ln -s $out/lib/telegram-history-dump/telegram-history-dump.rb $out/bin/telegram-history-dump | ||
280 | ''; | ||
281 | buildInputs = [ ruby ]; | ||
282 | }); | ||
283 | |||
255 | # https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh | 284 | # https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh |
256 | # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks | 285 | # https://github.com/NixOS/nixpkgs/blob/master/doc/languages-frameworks |
257 | in | 286 | 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 @@ | |||
1 | { | ||
2 | "tag": "d291187-master", | ||
3 | "meta": { | ||
4 | "name": "mutt-ics", | ||
5 | "url": "https://github.com/dmedvinsky/mutt-ics", | ||
6 | "branch": "master" | ||
7 | }, | ||
8 | "github": { | ||
9 | "owner": "dmedvinsky", | ||
10 | "repo": "mutt-ics", | ||
11 | "rev": "d29118788f291f67d34fefa6eda9f95846a2fe34", | ||
12 | "sha256": "0kqzngsvzjq5gpf60jhfmb2xzjznvk172khf4dlcb72n3ak4rb92", | ||
13 | "fetchSubmodules": true | ||
14 | } | ||
15 | } | ||
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 @@ | |||
1 | { | ||
2 | "tag": "6547c0b-master", | ||
3 | "meta": { | ||
4 | "name": "telegram-cli", | ||
5 | "url": "https://github.com/vysheng/tg", | ||
6 | "branch": "master" | ||
7 | }, | ||
8 | "github": { | ||
9 | "owner": "vysheng", | ||
10 | "repo": "tg", | ||
11 | "rev": "6547c0b21b977b327b3c5e8142963f4bc246187a", | ||
12 | "sha256": "07sss5cnw2ygd7mp8f5532lmj7qm6ywqf4cjaq5g13i8igzqzwzj", | ||
13 | "fetchSubmodules": true | ||
14 | } | ||
15 | } | ||
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 @@ | |||
1 | { | ||
2 | "tag": "468ea91-master", | ||
3 | "meta": { | ||
4 | "name": "telegram-history-dump", | ||
5 | "url": "https://github.com/tvdstaaij/telegram-history-dump", | ||
6 | "branch": "master" | ||
7 | }, | ||
8 | "github": { | ||
9 | "owner": "tvdstaaij", | ||
10 | "repo": "telegram-history-dump", | ||
11 | "rev": "468ea91e543529b54bc2c5ea28b1ea17f362fd3e", | ||
12 | "sha256": "1wmwiqacfa56bmwx50njnb15cg0fy6rbdrmrjd4xfbh8bs6yp0gh", | ||
13 | "fetchSubmodules": true | ||
14 | } | ||
15 | } | ||
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 @@ | |||
1 | diff --git a/tgl/crypto/rsa_pem_openssl.c b/tgl/crypto/rsa_pem_openssl.c | ||
2 | index db653f2..5e6a697 100644 | ||
3 | --- a/tgl/crypto/rsa_pem_openssl.c | ||
4 | +++ b/tgl/crypto/rsa_pem_openssl.c | ||
5 | @@ -36,6 +36,12 @@ TGLC_WRAPPER_ASSOC(rsa,RSA) | ||
6 | // TODO: Refactor crucial struct-identity into its own header. | ||
7 | TGLC_WRAPPER_ASSOC(bn,BIGNUM) | ||
8 | |||
9 | +/* | ||
10 | + * Since OpenSSL version 1.1.0 the RSA struct (rsa_st) is opaque, | ||
11 | + * see also https://wiki.openssl.org/index.php/OpenSSL_1.1.0_Changes | ||
12 | + */ | ||
13 | +#if (OPENSSL_VERSION_NUMBER < 0x10100000L) | ||
14 | + | ||
15 | TGLC_rsa *TGLC_rsa_new (unsigned long e, int n_bytes, const unsigned char *n) { | ||
16 | RSA *ret = RSA_new (); | ||
17 | ret->e = unwrap_bn (TGLC_bn_new ()); | ||
18 | @@ -47,7 +53,30 @@ TGLC_rsa *TGLC_rsa_new (unsigned long e, int n_bytes, const unsigned char *n) { | ||
19 | #define RSA_GETTER(M) \ | ||
20 | TGLC_bn *TGLC_rsa_ ## M (TGLC_rsa *key) { \ | ||
21 | return wrap_bn (unwrap_rsa (key)->M); \ | ||
22 | - } \ | ||
23 | + } | ||
24 | + | ||
25 | +#else // OPENSSL_VERSION_NUMBER | ||
26 | + | ||
27 | +TGLC_rsa *TGLC_rsa_new (unsigned long e, int n_bytes, const unsigned char *n) { | ||
28 | + RSA *ret = RSA_new (); | ||
29 | + BIGNUM *ret_e = unwrap_bn (TGLC_bn_new ()); | ||
30 | + BIGNUM *ret_n = unwrap_bn (TGLC_bn_bin2bn (n, n_bytes, NULL)); | ||
31 | + RSA_set0_key (ret, ret_n, ret_e, NULL); | ||
32 | + TGLC_bn_set_word (wrap_bn (ret_e), e); | ||
33 | + return wrap_rsa (ret); | ||
34 | +} | ||
35 | + | ||
36 | +#define RSA_GETTER(M) \ | ||
37 | +TGLC_bn *TGLC_rsa_ ## M (TGLC_rsa *key) { \ | ||
38 | + BIGNUM *rsa_n, *rsa_e, *rsa_d; \ | ||
39 | + RSA_get0_key(unwrap_rsa (key), \ | ||
40 | + (const BIGNUM **) &rsa_n, \ | ||
41 | + (const BIGNUM **) &rsa_e, \ | ||
42 | + (const BIGNUM **) &rsa_d); \ | ||
43 | + return wrap_bn (rsa_ ## M); \ | ||
44 | +} | ||
45 | + | ||
46 | +#endif // OPENSSL_VERSION_NUMBER | ||
47 | |||
48 | RSA_GETTER(n); | ||
49 | RSA_GETTER(e); | ||
50 | @@ -60,4 +89,4 @@ TGLC_rsa *TGLC_pem_read_RSAPublicKey (FILE *fp) { | ||
51 | return wrap_rsa (PEM_read_RSAPublicKey (fp, NULL, NULL, NULL)); | ||
52 | } | ||
53 | |||
54 | -#endif | ||
55 | +#endif // TGL_AVOID_OPENSSL | ||
56 | diff --git a/tgl/mtproto-utils.c b/tgl/mtproto-utils.c | ||
57 | index 0948bc8..cfdb216 100644 | ||
58 | --- a/tgl/mtproto-utils.c | ||
59 | +++ b/tgl/mtproto-utils.c | ||
60 | @@ -98,7 +98,7 @@ static unsigned long long BN2ull (TGLC_bn *b) { | ||
61 | if (sizeof (unsigned long) == 8) { | ||
62 | return TGLC_bn_get_word (b); | ||
63 | } else if (sizeof (unsigned long long) == 8) { | ||
64 | - assert (0); // As long as nobody ever uses this code, assume it is broken. | ||
65 | +// assert (0); // As long as nobody ever uses this code, assume it is broken. | ||
66 | unsigned long long tmp; | ||
67 | /* Here be dragons, but it should be okay due to be64toh */ | ||
68 | TGLC_bn_bn2bin (b, (unsigned char *) &tmp); | ||
69 | @@ -112,7 +112,7 @@ static void ull2BN (TGLC_bn *b, unsigned long long val) { | ||
70 | if (sizeof (unsigned long) == 8 || val < (1ll << 32)) { | ||
71 | TGLC_bn_set_word (b, val); | ||
72 | } else if (sizeof (unsigned long long) == 8) { | ||
73 | - assert (0); // As long as nobody ever uses this code, assume it is broken. | ||
74 | +// assert (0); // As long as nobody ever uses this code, assume it is broken. | ||
75 | htobe64(val); | ||
76 | /* Here be dragons, but it should be okay due to htobe64 */ | ||
77 | TGLC_bn_bin2bn ((unsigned char *) &val, 8, b); | ||
78 | diff --git a/tgl/tl-parser/tl-parser.c b/tgl/tl-parser/tl-parser.c | ||
79 | index 524b196..aeadbd2 100644 | ||
80 | --- a/tgl/tl-parser/tl-parser.c | ||
81 | +++ b/tgl/tl-parser/tl-parser.c | ||
82 | @@ -1903,7 +1903,7 @@ struct tl_combinator_tree *tl_parse_args134 (struct tree *T) { | ||
83 | //assert (S->data); | ||
84 | char *name = S->data; | ||
85 | if (!name) { | ||
86 | - static char s[20]; | ||
87 | + static char s[21]; | ||
88 | sprintf (s, "%lld", lrand48 () * (1ll << 32) + lrand48 ()); | ||
89 | name = s; | ||
90 | } | ||