1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 Evgenii Lepikhin <johnlepikhin@gmail.com>
;;;
;;; This file is not part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (johnlepikhin packages vkteams)
#:use-module (gnu packages base)
#:use-module (gnu packages bootstrap)
#:use-module (gnu packages compression)
#:use-module (gnu packages elf)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages gcc)
#:use-module (gnu packages gl)
#:use-module (gnu packages glib)
#:use-module (gnu packages gnupg)
#:use-module (gnu packages linux)
#:use-module (gnu packages ncurses)
#:use-module (gnu packages nss)
#:use-module (gnu packages pulseaudio)
#:use-module (gnu packages xorg)
#:use-module (guix build-system copy)
#:use-module (guix download)
#:use-module (guix gexp)
#:use-module (guix licenses)
#:use-module (guix monads)
#:use-module (guix packages)
#:use-module (guix store)
#:use-module (guix utils)
#:use-module (ice-9 match)
#:export (make-vkteams))
;; Patched version, added support of xz
(define* (url-fetch/tarbomb url hash-algo hash
#:optional name
#:key (system (%current-system))
(guile (default-guile)))
"Similar to 'url-fetch' but unpack the file from URL in a directory of its
own. This helper makes it easier to deal with \"tar bombs\"."
(define file-name
(match url
((head k v)
(basename head))
(z
(basename url))))
(define gzip
(module-ref (resolve-interface '(gnu packages compression)) 'gzip))
(define tar
(module-ref (resolve-interface '(gnu packages base)) 'tar))
(define xz
(module-ref (resolve-interface '(gnu packages compression)) 'xz))
(mlet %store-monad ((drv (url-fetch url hash-algo hash
(string-append "tarbomb-"
(or name file-name))
#:system system
#:guile guile))
(guile (package->derivation guile system)))
;; Take the tar bomb, and simply unpack it as a directory.
;; Use ungrafted tar/gzip so that the resulting tarball doesn't depend on
;; whether grafts are enabled.
(gexp->derivation (or name file-name)
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(mkdir #$output)
(setenv "PATH" (string-append #+gzip "/bin:" #+xz "/bin"))
(chdir #$output)
(invoke (string-append #+tar "/bin/tar")
"xf" #$drv)))
#:system system
#:guile-for-build guile
#:graft? #f
#:local-build? #t)))
(define (make-vkteams version uri checksum)
(package
(name "vkteams")
(version version)
(source (origin
(method url-fetch/tarbomb)
(uri uri)
(sha256 (base32 checksum))))
(build-system copy-build-system)
(arguments
`(#:install-plan
`(("vkteams" "dist/.vkteams-real")
("lib" "dist/lib")
("libexec" "dist/libexec")
("resources" "dist/resources")
("plugins" "dist/plugins"))
#:phases
(modify-phases
%standard-phases
(add-after
'strip 'fix-binary
(lambda*
(#:key outputs inputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(ncurses-lib
(string-append (assoc-ref inputs "ncurses") "/lib"))
(patchelf (string-append (assoc-ref inputs "patchelf") "/bin/patchelf"))
(binaries (string-append out "/dist/.vkteams-real"
" " out "/dist/libexec/*"))
(libs (string-append out "/dist/lib/lib*.so*"))
(plugins (string-append out "/dist/plugins/*/lib*.so*"))
(dynamic-linker (string-append (assoc-ref inputs "libc") ,(glibc-dynamic-linker)))
(nss (string-append (assoc-ref inputs "nss") "/lib/nss")))
(system
(string-append
patchelf
" --set-rpath \"" out "/dist/lib:" nss ":$LIBRARY_PATH\""
" --set-interpreter " dynamic-linker
" " binaries))
(system
(string-append
patchelf " --set-rpath \"" out "/dist/lib:" nss ":$LIBRARY_PATH\" " libs " " plugins))
(mkdir (string-append out "/bin"))
(let ((wrapper (string-append out "/bin/vkteams")))
(with-output-to-file wrapper
(lambda _
(display (string-append "#! /bin/sh\n\nSOFTWARE_RENDER=1 " out "/dist/.vkteams-real $*\n"))))
(chmod wrapper #o755))
(let ((qt.conf (string-append
"[Paths]\n"
"Plugins = " out "/dist/plugins\n"
"Libraries = " out "/dist/lib\n"
"LibraryExecutables = " out "/dist/libexec\n")))
(with-output-to-file (string-append out "/dist/qt.conf")
(lambda _
(display qt.conf))))
(symlink
(string-append ncurses-lib "/libncursesw.so."
;; Extract "6.0" from "6.0-20170930" if a
;; dash-separated version tag exists.
,(let* ((v (package-version ncurses))
(d (or (string-index v #\-)
(string-length v))))
(version-major+minor (string-take v d))))
(string-append out "/dist/lib/libtinfo.so.5"))
#t)))
(add-after
'install 'finalize-install
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(let ((apps (string-append out "/share/applications")))
(mkdir-p apps)
(make-desktop-entry-file
(string-append apps "/vkteams.desktop")
#:name "VK Teams"
#:exec (string-append out "/bin/vkteams -urlcommand %U")
#:mime-type (list
"x-scheme-handler/myteam-messenger"
"x-scheme-handler/vkteams-messenger"
"x-scheme-handler/vkteams"
"x-scheme-handler/callto"
"x-scheme-handler/zoomphonecall")
#:categories '("Network" "Application")
#:comment
'(("en" "VK Teams messenger")
(#f "VK Teams messenger")))
#t)))))))
(synopsis "VK Teams")
(description "VK Teams")
(home-page "https://dl.internal.myteam.mail.ru/")
(native-inputs `(("patchelf" ,patchelf)))
(inputs `(("libxrandr" ,libxrandr)
("libxcomposite" ,libxcomposite)
("libxcursor" ,libxcursor)
("libxdamage" ,libxdamage)
("gcc:lib" ,gcc-5 "lib")
("gcc" ,gcc)
("libgpg-error" ,libgpg-error)
("glibc" ,glibc)
("libfontconfig" ,fontconfig)
("libxau" ,libxau)
("pulseaudio" ,pulseaudio)
("dbus" ,dbus)
("mesa" ,mesa)
("glib" ,glib)
("libxi" ,libxi)
("eudev" ,eudev)
("ncurses" ,ncurses)
("libxtst" ,libxtst)
("alsa-lib" ,alsa-lib)
("nss" ,nss)
("libxinerama" ,libxinerama)))
(license gpl3+)))
(define-public vkteams-23.02
(make-vkteams "23.02.2" "https://t.bk.ru/lQ8MG7Buvx1ugDI/vkteams.tar.xz" "0kjng9rm89b8iz574p6ykvjvdhs8w5dn85da66mdsxkp9gkcka0x"))
(define-public vkteams vkteams-23.02)
|