Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / kodi.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
3 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
4 ;;; Copyright © 2017 Oleg Pykhalov <go.wigust@gmail.com>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages kodi)
22 #:use-module ((guix licenses) #:prefix license:)
23 #:use-module (guix utils)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix git-download)
27 #:use-module (guix build-system cmake)
28 #:use-module (guix build-system gnu)
29 #:use-module (guix build-system trivial)
30 #:use-module (gnu packages algebra)
31 #:use-module (gnu packages audio)
32 #:use-module (gnu packages autotools)
33 #:use-module (gnu packages avahi)
34 #:use-module (gnu packages base)
35 #:use-module (gnu packages bash)
36 #:use-module (gnu packages cdrom)
37 #:use-module (gnu packages cmake)
38 #:use-module (gnu packages compression)
39 #:use-module (gnu packages curl)
40 #:use-module (gnu packages databases)
41 #:use-module (gnu packages documentation)
42 #:use-module (gnu packages fontutils)
43 #:use-module (gnu packages fribidi)
44 #:use-module (gnu packages gettext)
45 #:use-module (gnu packages ghostscript)
46 #:use-module (gnu packages gawk)
47 #:use-module (gnu packages gl)
48 #:use-module (gnu packages glib)
49 #:use-module (gnu packages gperf)
50 #:use-module (gnu packages gnunet)
51 #:use-module (gnu packages gnupg)
52 #:use-module (gnu packages image)
53 #:use-module (gnu packages java)
54 #:use-module (gnu packages libusb)
55 #:use-module (gnu packages linux)
56 #:use-module (gnu packages mp3)
57 #:use-module (gnu packages pcre)
58 #:use-module (gnu packages pkg-config)
59 #:use-module (gnu packages pretty-print)
60 #:use-module (gnu packages pulseaudio)
61 #:use-module (gnu packages python)
62 #:use-module (gnu packages samba)
63 #:use-module (gnu packages sdl)
64 #:use-module (gnu packages ssh)
65 #:use-module (gnu packages swig)
66 #:use-module (gnu packages textutils)
67 #:use-module (gnu packages tls)
68 #:use-module (gnu packages video)
69 #:use-module (gnu packages web)
70 #:use-module (gnu packages xdisorg)
71 #:use-module (gnu packages xiph)
72 #:use-module (gnu packages xml)
73 #:use-module (gnu packages xorg)
74 #:use-module (gnu packages assembly))
75
76 (define-public crossguid
77 (let ((commit "8f399e8bd4252be9952f3dfa8199924cc8487ca4"))
78 (package
79 (name "crossguid")
80 (version (string-append "0.0-1." (string-take commit 7)))
81 ;; There's no official release. Just a Git repository.
82 (source (origin
83 (method git-fetch)
84 (uri (git-reference
85 (url "https://github.com/graeme-hill/crossguid.git")
86 (commit commit)))
87 (file-name (string-append name "-" version "-checkout"))
88 (sha256
89 (base32
90 "1i29y207qqddvaxbn39pk2fbh3gx8zvdprfp35wasj9rw2wjk3s9"))))
91 (build-system gnu-build-system)
92 (arguments
93 '(#:phases
94 (modify-phases %standard-phases
95 (delete 'configure) ; no configure script
96 ;; There's no build system here, so we have to do it ourselves.
97 (replace 'build
98 (lambda _
99 (and (zero? (system* "g++" "-c" "guid.cpp" "-o" "guid.o"
100 "-std=c++11" "-DGUID_LIBUUID"))
101 (zero? (system* "ar" "rvs" "libcrossguid.a" "guid.o")))))
102 (replace 'check
103 (lambda _
104 (and (zero? (system* "g++" "-c" "test.cpp" "-o" "test.o"
105 "-std=c++11"))
106 (zero? (system* "g++" "-c" "testmain.cpp" "-o" "testmain.o"
107 "-std=c++11"))
108 (zero? (system* "g++" "test.o" "guid.o" "testmain.o"
109 "-o" "test" "-luuid"))
110 (zero? (system* (string-append (getcwd) "/test"))))))
111 (replace 'install
112 (lambda* (#:key outputs #:allow-other-keys)
113 (let ((out (assoc-ref outputs "out")))
114 (install-file "guid.h" (string-append out "/include"))
115 (install-file "libcrossguid.a"
116 (string-append out "/lib"))
117 #t))))))
118 (inputs
119 `(("util-linux" ,util-linux)))
120 (synopsis "Lightweight universal identifier library")
121 (description "CrossGuid is a minimal GUID/UUID
122 generator library for C++.")
123 (home-page "https://github.com/graeme-hill/crossguid")
124 (license license:expat))))
125
126 ;; Kodi requires using their own special forks of these libraries.
127 ;; In addition, it insists on downloading and building these as part
128 ;; of the standard build process. To make things easier, we bootstrap
129 ;; and patch shebangs here, so we don't have to worry about it later.
130 (define libdvdnav/kodi
131 (let ((commit "6.0.0-Leia-Alpha-1"))
132 (package
133 (name "libdvdnav-bootstrapped")
134 (version commit)
135 (source (origin
136 (method git-fetch)
137 (uri (git-reference
138 (url "https://github.com/xbmc/libdvdnav.git")
139 (commit commit)))
140 (file-name (string-append name "-" version "-checkout"))
141 (sha256
142 (base32
143 "1xiyfgf8v8aknlxlzsvk6pbzkhclz0hbh3s1b0w6ivkng2k310j9"))))
144 (build-system gnu-build-system)
145 (arguments
146 '(#:tests? #f
147 #:phases
148 (modify-phases %standard-phases
149 (delete 'configure)
150 (delete 'build)
151 (replace 'install
152 (lambda* (#:key outputs #:allow-other-keys)
153 (copy-recursively "." (assoc-ref outputs "out"))
154 #t)))))
155 (native-inputs
156 `(("autoconf" ,autoconf)
157 ("automake" ,automake)
158 ("libtool" ,libtool)
159 ("pkg-config" ,pkg-config)))
160 (home-page "https://github.com/xbmc/libdvdnav")
161 (synopsis (package-synopsis libdvdnav))
162 (description (package-description libdvdnav))
163 (license license:gpl2+))))
164
165 (define libdvdread/kodi
166 (let ((commit "6.0.0-Leia-Alpha-1"))
167 (package
168 (name "libdvdread-bootstrapped")
169 (version commit)
170 (source (origin
171 (method git-fetch)
172 (uri (git-reference
173 (url "https://github.com/xbmc/libdvdread.git")
174 (commit commit)))
175 (file-name (string-append name "-" version "-checkout"))
176 (sha256
177 (base32
178 "1c3g18n2vwhgcfz3dka1pmw58bnv2ram7xjvizfiykb3sgi9zfwp"))))
179 (build-system gnu-build-system)
180 (arguments
181 '(#:tests? #f
182 #:phases
183 (modify-phases %standard-phases
184 (delete 'configure)
185 (delete 'build)
186 (replace 'install
187 (lambda* (#:key outputs #:allow-other-keys)
188 (copy-recursively "." (assoc-ref outputs "out"))
189 #t)))))
190 (native-inputs
191 `(("autoconf" ,autoconf)
192 ("automake" ,automake)
193 ("libtool" ,libtool)
194 ("pkg-config" ,pkg-config)))
195 (home-page "https://github.com/xbmc/libdvdread")
196 (synopsis (package-synopsis libdvdread))
197 (description (package-description libdvdread))
198 (license (list license:gpl2+ license:lgpl2.1+)))))
199
200 (define libdvdcss/kodi
201 (let ((commit "1.4.1-Leia-Alpha-1"))
202 (package
203 (name "libdvdcss-bootstrapped")
204 (version commit)
205 (source (origin
206 (method git-fetch)
207 (uri (git-reference
208 (url "https://github.com/xbmc/libdvdcss.git")
209 (commit commit)))
210 (file-name (string-append name "-" version "-checkout"))
211 (sha256
212 (base32
213 "0adafwsawxssj3nilkql447v0l4a2584rdpmy5rfjmznh91lykgh"))))
214 (build-system gnu-build-system)
215 (arguments
216 '(#:tests? #f
217 #:phases
218 (modify-phases %standard-phases
219 (delete 'configure)
220 (delete 'build)
221 (replace 'install
222 (lambda* (#:key outputs #:allow-other-keys)
223 (copy-recursively "." (assoc-ref outputs "out"))
224 #t)))))
225 (native-inputs
226 `(("autoconf" ,autoconf)
227 ("automake" ,automake)
228 ("libtool" ,libtool)
229 ("pkg-config" ,pkg-config)))
230 (home-page "https://github.com/xbmc/libdvdcss")
231 (synopsis (package-synopsis libdvdcss))
232 (description (package-description libdvdcss))
233 (license license:gpl2+))))
234
235 (define-public kodi
236 ;; We package the git version because the current released
237 ;; version was cut while the cmake transition was in turmoil.
238 (let ((commit "ec16dbca4dcf2923f53f819695a6d47c52e68d74")
239 (revision "8"))
240 (package
241 (name "kodi")
242 (version (git-version "18.0_alpha" revision commit))
243 (source (origin
244 (method git-fetch)
245 (uri (git-reference
246 (url "https://github.com/xbmc/xbmc.git")
247 (commit commit)))
248 (file-name (git-file-name name version))
249 (sha256
250 (base32
251 "1rxg752cl59124cfpfwmyjldn6qpq5jginxddpzvgagfadf10i4d"))
252 (snippet
253 '(begin
254 (use-modules (guix build utils))
255 (for-each delete-file-recursively
256 '("project/BuildDependencies/bin/"
257 ;; TODO: Purge these jars.
258 ;;"tools/codegenerator/groovy"
259 ;; And these sources:
260 ;; "tools/depend/native/JsonSchemaBuilder"
261 ;; "tools/depend/native/TexturePacker"
262 ;; "lib/gtest"
263 ;; "lib/cpluff"
264 ;; "lib/libUPnP"
265 "lib/libUPnP/Neptune/ThirdParty"
266 "project/Win32BuildSetup/tools/7z"))
267 #t))
268 (modules '((guix build utils)))))
269 (build-system cmake-build-system)
270 (arguments
271 '(#:modules ((srfi srfi-1)
272 (guix build cmake-build-system)
273 (guix build utils))
274 #:configure-flags
275 (list "-DENABLE_INTERNAL_FFMPEG=OFF"
276 "-DENABLE_INTERNAL_CROSSGUID=OFF"
277 (string-append "-Dlibdvdread_URL="
278 (assoc-ref %build-inputs "libdvdread-bootstrapped"))
279 (string-append "-Dlibdvdnav_URL="
280 (assoc-ref %build-inputs "libdvdnav-bootstrapped"))
281 (string-append "-Dlibdvdcss_URL="
282 (assoc-ref %build-inputs "libdvdcss-bootstrapped"))
283 (string-append "-DSYSTEM_LDFLAGS=-Wl,-rpath="
284 (assoc-ref %build-inputs "curl") "/lib"))
285 #:phases
286 (modify-phases %standard-phases
287 ;; The build system tries to bootstrap these bundled components
288 ;; during the regular build phase, which causes serious issues
289 ;; because there's no time for shebangs to be patched. So, we
290 ;; bootstrap it on our own instead.
291 (add-after 'unpack 'bootstrap-bundled-software
292 (lambda _
293 (let ((dirs '("tools/depends/native/JsonSchemaBuilder/src"
294 "lib/cpluff")))
295 (every (lambda (third-party)
296 (with-directory-excursion third-party
297 (zero? (system* "autoreconf" "-vif"))))
298 dirs))))
299 (add-after 'bootstrap-bundled-software 'patch-stuff
300 (lambda* (#:key inputs #:allow-other-keys)
301 ;; Prevent the build scripts from calling autoreconf in the
302 ;; build stage. Otherwise, it would undo the bootstrapping
303 ;; and shebang patching that we worked so hard for.
304 (substitute* "cmake/modules/FindCpluff.cmake"
305 (("autoreconf -vif") "true"))
306 (substitute* "lib/cpluff/po/Makefile.in.in"
307 (("/bin/sh") (which "sh")))
308 (substitute* "cmake/modules/FindLibDvd.cmake"
309 ;; The libdvd* sources that we bootstrapped separately are
310 ;; unpacked in the build phase. This is our best opportunity
311 ;; to make them writable before the build process starts.
312 (("autoreconf -vif") "chmod -R u+w ."))
313
314 (substitute* "xbmc/platform/linux/LinuxTimezone.cpp"
315 (("/usr/share/zoneinfo")
316 (string-append (assoc-ref inputs "tzdata")
317 "/share/zoneinfo")))
318
319 ;; Let's disable some tests that are known not to work here.
320 ;; Doing this later while in the cmake "../build" directory
321 ;; is trickier.
322 (substitute* '("xbmc/utils/test/TestSystemInfo.cpp")
323 (("TEST_F\\(TestSystemInfo, GetOsPrettyNameWithVersion\\)")
324 "TEST_F(TestSystemInfo, DISABLED_GetOsPrettyNameWithVersion)")
325 (("TEST_F\\(TestSystemInfo, GetOsName\\)")
326 "TEST_F(TestSystemInfo, DISABLED_GetOsName)")
327 (("TEST_F\\(TestSystemInfo, GetOsVersion\\)")
328 "TEST_F(TestSystemInfo, DISABLED_GetOsVersion)"))
329 #t))
330 (add-before 'build 'set-build-environment
331 (lambda _
332 ;; Some bundled build scripts fall back to /bin/sh
333 ;; if this is not set.
334 (setenv "CONFIG_SHELL" (which "sh"))
335 #t))
336 (add-before 'check 'build-kodi-test
337 (lambda _
338 (zero? (system* "make" "kodi-test")))))))
339 ;; TODO: Add dependencies for:
340 ;; - nfs
341 ;; - cec
342 ;; - plist
343 ;; - shairplay
344 (native-inputs
345 `(("autoconf" ,autoconf)
346 ("automake" ,automake)
347 ("gettext" ,gettext-minimal)
348 ("icedtea" ,icedtea) ; needed at build-time only, mandatory
349 ("libdvdcss-bootstrapped" ,libdvdcss/kodi)
350 ("libdvdnav-bootstrapped" ,libdvdnav/kodi)
351 ("libdvdread-bootstrapped" ,libdvdread/kodi)
352 ("libtool" ,libtool)
353 ("pkg-config" ,pkg-config)
354 ("swig" ,swig)
355 ("yasm" ,yasm)))
356 (inputs
357 `(("alsa-lib" ,alsa-lib)
358 ("avahi" ,avahi)
359 ("bluez" ,bluez)
360 ("crossguid" ,crossguid)
361 ("curl" ,curl)
362 ("dcadec" ,dcadec)
363 ("dbus" ,dbus)
364 ("eudev" ,eudev)
365 ("ffmpeg" ,ffmpeg)
366 ("flac" ,flac)
367 ("fmt" ,fmt)
368 ("fontconfig" ,fontconfig)
369 ("freetype" ,freetype)
370 ("fribidi" ,fribidi)
371 ("giflib" ,giflib)
372 ("glew" ,glew)
373 ("gnutls" ,gnutls)
374 ("lame" ,lame)
375 ("lcms" ,lcms)
376 ("libass" ,libass)
377 ("libbluray" ,libbluray)
378 ("libcap" ,libcap)
379 ("libcdio" ,libcdio)
380 ("libdrm" ,libdrm)
381 ("libgcrypt" ,libgcrypt)
382 ("libjpeg" ,libjpeg)
383 ("libltdl" ,libltdl)
384 ("libmad" ,libmad)
385 ("libmicrohttpd" ,libmicrohttpd)
386 ("libmpeg2" ,libmpeg2)
387 ("libogg" ,libogg)
388 ("libpng" ,libpng)
389 ("libssh" ,libssh)
390 ("libtiff" ,libtiff)
391 ("libva" ,libva)
392 ("libvorbis" ,libvorbis)
393 ("libxml2" ,libxml2)
394 ("libxrandr" ,libxrandr)
395 ("libxrender" ,libxrender)
396 ("libxslt" ,libxslt)
397 ("lzo" ,lzo)
398 ("mysql" ,mysql)
399 ("openssl" ,openssl)
400 ("pcre" ,pcre)
401 ("pulseaudio" ,pulseaudio)
402 ("python" ,python-2)
403 ("rapidjson" ,rapidjson)
404 ("samba" ,samba)
405 ("sqlite" ,sqlite)
406 ("taglib" ,taglib)
407 ("tinyxml" ,tinyxml)
408 ("tzdata" ,tzdata)
409 ("util-linux" ,util-linux)
410 ("zip" ,zip)
411 ("zlib" ,zlib)))
412 (synopsis "Media center for home theater computers")
413 (description "Kodi is a media center application for playing videos,
414 music, games, etc. Kodi is highly customizable and features a theme and
415 plug-in system.")
416 (home-page "https://kodi.tv")
417 ;; XBMC is largely GPL2+, with some library components as LGPL2.1+, but
418 ;; there are some other licenses spread throughout.
419 (license (list license:gpl2+ license:lgpl2.1+
420 license:gpl3+ ;WiiRemote client
421 license:expat ;cpluff, dbwrappers
422 license:public-domain ;cpluff/examples
423 license:bsd-3 ;misc, gtest
424 license:bsd-2))))) ;xbmc/freebsd
425
426 (define-public kodi-cli
427 (let ((commit "104dc23b2a993c8e6db8c46f4f8bec24b146549b") ; Add support for
428 (revision "1")) ; `$HOME/.kodirc'.
429 (package
430 (name "kodi-cli")
431 (version (string-append "1.1-" revision "." (string-take commit 7)))
432 (source (origin
433 (method git-fetch)
434 (uri (git-reference (url "https://github.com/nawar/kodi-cli")
435 (commit commit)))
436 (sha256
437 (base32
438 "1xjhasc5gngfxpr1dlzy6q24w0wpdfjx12p43fanjppxw4i49n5p"))
439 (file-name (string-append name "-" version "-checkout"))))
440 (build-system trivial-build-system)
441 (inputs
442 `(("bash" ,bash)
443 ("curl" ,curl)
444 ("mps-youtube" ,mps-youtube)))
445 (arguments
446 `(#:modules ((guix build utils))
447 #:builder
448 (begin
449 (use-modules (guix build utils))
450 (copy-recursively (assoc-ref %build-inputs "source") ".")
451 (substitute* "kodi-cli"
452 (("/bin/bash") (string-append (assoc-ref %build-inputs "bash")
453 "/bin/bash"))
454 (("output=\\$\\((curl)" all curl)
455 (string-append "output=$("
456 (assoc-ref %build-inputs "curl")
457 "/bin/" curl))
458 (("play_youtube `(mpsyt)" all mpsyt)
459 (string-append "play_youtube `"
460 (assoc-ref %build-inputs "mps-youtube")
461 "/bin/" mpsyt)))
462 (install-file "kodi-cli" (string-append %output "/bin"))
463 #t)))
464 (home-page "https://github.com/nawar/kodi-cli")
465 (synopsis "Control Kodi from the command line")
466 (description "@code{kodi-cli} is a tool for sending commands to a Kodi
467 server using JSON RPC.
468
469 Features:
470
471 @itemize
472 @item Play, pause, stop the currently playing item.
473 @item Skip forward or backward in the currently playing item.
474 @item Play or queue to the currently list of YouTube videos.
475 @item Interactive and noninteractive volume control.
476 @item Interactive navigation.
477 @item Send text to the Kodi keyboard.
478 @item Toggle fullscreen.
479 @item Update or clean Kodi libraries.
480 @end itemize\n")
481 (license license:gpl2+))))