Merge branch 'version-0.13.0'
[jackhill/guix/guix.git] / gnu / packages / package-management.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;;
5 ;;; This file is part of GNU Guix.
6 ;;;
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
11 ;;;
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
16 ;;;
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19
20 (define-module (gnu packages package-management)
21 #:use-module (guix packages)
22 #:use-module (guix download)
23 #:use-module (guix git-download)
24 #:use-module (guix gexp)
25 #:use-module (guix utils)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix build-system python)
28 #:use-module ((guix licenses) #:select (gpl2+ gpl3+ lgpl2.1+ asl2.0))
29 #:use-module (gnu packages)
30 #:use-module (gnu packages guile)
31 #:use-module (gnu packages file)
32 #:use-module (gnu packages backup)
33 #:use-module (gnu packages compression)
34 #:use-module (gnu packages gnupg)
35 #:use-module (gnu packages databases)
36 #:use-module (gnu packages graphviz)
37 #:use-module (gnu packages pkg-config)
38 #:use-module (gnu packages autotools)
39 #:use-module (gnu packages gettext)
40 #:use-module (gnu packages texinfo)
41 #:use-module (gnu packages nettle)
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages curl)
44 #:use-module (gnu packages web)
45 #:use-module (gnu packages man)
46 #:use-module (gnu packages bdw-gc)
47 #:use-module (gnu packages patchutils)
48 #:use-module (gnu packages python)
49 #:use-module (gnu packages popt)
50 #:use-module (gnu packages gnuzilla)
51 #:use-module (gnu packages cpio)
52 #:use-module (gnu packages tls)
53 #:use-module (gnu packages ssh)
54 #:use-module (gnu packages vim)
55 #:use-module (srfi srfi-1)
56 #:use-module (ice-9 match))
57
58 (define (boot-guile-uri arch)
59 "Return the URI for the bootstrap Guile tarball for ARCH."
60 (cond ((string=? "armhf" arch)
61 (string-append "http://alpha.gnu.org/gnu/guix/bootstrap/"
62 arch "-linux"
63 "/20150101/guile-2.0.11.tar.xz"))
64 ((string=? "aarch64" arch)
65 (string-append "http://alpha.gnu.org/gnu/guix/bootstrap/"
66 arch "-linux/20170217/guile-2.0.14.tar.xz"))
67 (else
68 (string-append "http://alpha.gnu.org/gnu/guix/bootstrap/"
69 arch "-linux"
70 "/20131110/guile-2.0.9.tar.xz"))))
71
72 (define-public guix
73 ;; Latest version of Guix, which may or may not correspond to a release.
74 ;; Note: the 'update-guix-package.scm' script expects this definition to
75 ;; start precisely like this.
76 (let ((version "0.13.0")
77 (commit "a6d728b7aaee09892b0b420d07ed2dbb7de5e63f")
78 (revision 1))
79 (package
80 (name "guix")
81
82 (version (if (zero? revision)
83 version
84 (string-append version "-"
85 (number->string revision)
86 "." (string-take commit 7))))
87 (source (origin
88 (method git-fetch)
89 (uri (git-reference
90 (url "https://git.savannah.gnu.org/r/guix.git")
91 (commit commit)))
92 (sha256
93 (base32
94 "1nrskyk8z6w5i9cdfh5zxfgsrqf744sb30ssqi2g5xhijwagr1yq"))
95 (file-name (string-append "guix-" version "-checkout"))))
96 (build-system gnu-build-system)
97 (arguments
98 `(#:configure-flags (list
99 "--localstatedir=/var"
100 "--sysconfdir=/etc"
101 (string-append "--with-bash-completion-dir="
102 (assoc-ref %outputs "out")
103 "/etc/bash_completion.d")
104 (string-append "--with-libgcrypt-prefix="
105 (assoc-ref %build-inputs
106 "libgcrypt"))
107
108 ;; Set 'DOT_USER_PROGRAM' to the empty string so
109 ;; we don't keep a reference to Graphviz, whose
110 ;; closure is pretty big (too big for the GuixSD
111 ;; installation image.)
112 "ac_cv_path_DOT_USER_PROGRAM=dot"
113
114 ;; To avoid problems with the length of shebangs,
115 ;; choose a fixed-width and short directory name
116 ;; for tests.
117 "ac_cv_guix_test_root=/tmp/guix-tests")
118 #:parallel-tests? #f ;work around <http://bugs.gnu.org/21097>
119
120 #:modules ((guix build gnu-build-system)
121 (guix build utils)
122 (ice-9 popen)
123 (ice-9 rdelim))
124
125 #:phases (modify-phases %standard-phases
126 (add-after 'unpack 'bootstrap
127 (lambda _
128 ;; Make sure 'msgmerge' can modify the PO files.
129 (for-each (lambda (po)
130 (chmod po #o666))
131 (find-files "." "\\.po$"))
132
133 (zero? (system* "sh" "bootstrap"))))
134 (add-before
135 'configure 'copy-bootstrap-guile
136 (lambda* (#:key system inputs #:allow-other-keys)
137 (define (boot-guile-version arch)
138 (cond ((string=? "armhf" arch) "2.0.11")
139 ((string=? "aarch64" arch) "2.0.14")
140 (else "2.0.9")))
141
142 (define (copy arch)
143 (let ((guile (assoc-ref inputs
144 (string-append "boot-guile/"
145 arch)))
146 (target (string-append "gnu/packages/bootstrap/"
147 arch "-linux/"
148 "/guile-"
149 (boot-guile-version arch)
150 ".tar.xz")))
151 (mkdir-p (dirname target)) ;XXX: eventually unneeded
152 (copy-file guile target)))
153
154 (copy "i686")
155 (copy "x86_64")
156 (copy "mips64el")
157 (copy "armhf")
158 (copy "aarch64")
159 #t))
160 (add-after
161 'unpack 'disable-container-tests
162 ;; XXX FIXME: These tests fail within the build container.
163 (lambda _
164 (substitute* "tests/syscalls.scm"
165 (("^\\(test-(assert|equal) \"(clone|setns|pivot-root)\"" all)
166 (string-append "(test-skip 1)\n" all)))
167 (substitute* "tests/containers.scm"
168 (("^\\(test-(assert|equal)" all)
169 (string-append "(test-skip 1)\n" all)))
170 (when (file-exists? "tests/guix-environment-container.sh")
171 (substitute* "tests/guix-environment-container.sh"
172 (("guix environment --version")
173 "exit 77\n")))
174 #t))
175 (add-before 'check 'set-SHELL
176 (lambda _
177 ;; 'guix environment' tests rely on 'SHELL' having a
178 ;; correct value, so set it.
179 (setenv "SHELL" (which "sh"))
180 #t))
181 (add-after 'install 'wrap-program
182 (lambda* (#:key inputs outputs #:allow-other-keys)
183 ;; Make sure the 'guix' command finds GnuTLS and
184 ;; Guile-JSON automatically.
185 (let* ((out (assoc-ref outputs "out"))
186 (guile (assoc-ref inputs "guile"))
187 (json (assoc-ref inputs "guile-json"))
188 (ssh (assoc-ref inputs "guile-ssh"))
189 (gnutls (assoc-ref inputs "gnutls"))
190 (effective
191 (read-line
192 (open-pipe* OPEN_READ
193 (string-append guile "/bin/guile")
194 "-c" "(display (effective-version))")))
195 (path (string-append
196 json "/share/guile/site/" effective ":"
197 ssh "/share/guile/site/" effective ":"
198 gnutls "/share/guile/site/" effective)))
199
200 (wrap-program (string-append out "/bin/guix")
201 `("GUILE_LOAD_PATH" ":" prefix (,path))
202 `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,path)))
203
204 #t))))))
205 (native-inputs `(("pkg-config" ,pkg-config)
206
207 ;; XXX: Keep the development inputs here even though
208 ;; they're unnecessary, just so that 'guix environment
209 ;; guix' always contains them.
210 ("autoconf" ,(autoconf-wrapper))
211 ("automake" ,automake)
212 ("gettext" ,gettext-minimal)
213 ("texinfo" ,texinfo)
214 ("graphviz" ,graphviz)
215 ("help2man" ,help2man)))
216 (inputs
217 (let ((boot-guile (lambda (arch hash)
218 (origin
219 (method url-fetch)
220 (uri (boot-guile-uri arch))
221 (sha256 hash)))))
222 `(("bzip2" ,bzip2)
223 ("gzip" ,gzip)
224 ("zlib" ,zlib) ;for 'guix publish'
225
226 ("sqlite" ,sqlite)
227 ("libgcrypt" ,libgcrypt)
228 ("guile" ,guile-2.2)
229
230 ("boot-guile/i686"
231 ,(boot-guile "i686"
232 (base32
233 "0im800m30abgh7msh331pcbjvb4n02smz5cfzf1srv0kpx3csmxp")))
234 ("boot-guile/x86_64"
235 ,(boot-guile "x86_64"
236 (base32
237 "1w2p5zyrglzzniqgvyn1b55vprfzhgk8vzbzkkbdgl5248si0yq3")))
238 ("boot-guile/mips64el"
239 ,(boot-guile "mips64el"
240 (base32
241 "0fzp93lvi0hn54acc0fpvhc7bvl0yc853k62l958cihk03q80ilr")))
242 ("boot-guile/armhf"
243 ,(boot-guile "armhf"
244 (base32
245 "1mi3brl7l58aww34rawhvja84xc7l1b4hmwdmc36fp9q9mfx0lg5")))
246 ("boot-guile/aarch64"
247 ,(boot-guile "aarch64"
248 (base32
249 "1giy2aprjmn5fp9c4s9r125fljw4wv6ixy5739i5bffw4jgr0f9r"))))))
250 (propagated-inputs
251 `(("gnutls" ,gnutls/guile-2.2) ;for 'guix download' & co.
252 ("guile-json" ,guile-json)
253 ("guile-ssh" ,guile-ssh)))
254
255 (home-page "https://www.gnu.org/software/guix/")
256 (synopsis "Functional package manager for installed software packages and versions")
257 (description
258 "GNU Guix is a functional package manager for the GNU system, and is
259 also a distribution thereof. It includes a virtual machine image. Besides
260 the usual package management features, it also supports transactional
261 upgrades and roll-backs, per-user profiles, and much more. It is based on
262 the Nix package manager.")
263 (license gpl3+)
264 (properties '((ftp-server . "alpha.gnu.org"))))))
265
266 ;; Alias for backward compatibility.
267 (define-public guix-devel guix)
268
269 (define-public guile2.0-guix
270 (package
271 (inherit guix)
272 (name "guile2.0-guix")
273 (inputs
274 `(("guile" ,guile-2.0)
275 ,@(alist-delete "guile" (package-inputs guix))))
276 (propagated-inputs
277 `(("gnutls" ,gnutls)
278 ("guile-json" ,guile2.0-json)
279 ("guile-ssh" ,guile2.0-ssh)))))
280
281 (define (source-file? file stat)
282 "Return true if FILE is likely a source file, false if it is a typical
283 generated file."
284 (define (wrong-extension? file)
285 (or (string-suffix? "~" file)
286 (member (file-extension file)
287 '("o" "a" "lo" "so" "go"))))
288
289 (match (basename file)
290 ((or ".git" "autom4te.cache" "configure" "Makefile" "Makefile.in" ".libs")
291 #f)
292 ((? wrong-extension?)
293 #f)
294 (_
295 #t)))
296
297 (define-public current-guix
298 (let ((select? (delay (or (git-predicate
299 (string-append (current-source-directory)
300 "/../.."))
301 source-file?))))
302 (lambda ()
303 "Return a package representing Guix built from the current source tree.
304 This works by adding the current source tree to the store (after filtering it
305 out) and returning a package that uses that as its 'source'."
306 (package
307 (inherit guix)
308 (version (string-append (package-version guix) "+"))
309 (source (local-file "../.." "guix-current"
310 #:recursive? #t
311 #:select? (force select?)))))))
312
313 \f
314 ;;;
315 ;;; Other tools.
316 ;;;
317
318 (define-public nix
319 (package
320 (name "nix")
321 (version "1.11.9")
322 (source (origin
323 (method url-fetch)
324 (uri (string-append "http://nixos.org/releases/nix/nix-"
325 version "/nix-" version ".tar.xz"))
326 (sha256
327 (base32
328 "1qg7qrfr60dysmyfg3ijgani71l23p1kqadhjs8kz11pgwkkx50f"))))
329 (build-system gnu-build-system)
330 ;; XXX: Should we pass '--with-store-dir=/gnu/store'? But then we'd also
331 ;; need '--localstatedir=/var'. But then! The thing would use /var/nix
332 ;; instead of /var/guix. So in the end, we do nothing special.
333 (arguments
334 '(#:configure-flags
335 ;; Set the prefixes of Perl libraries to avoid propagation.
336 (let ((perl-libdir (lambda (p)
337 (string-append
338 (assoc-ref %build-inputs p)
339 "/lib/perl5/site_perl"))))
340 (list (string-append "--with-dbi="
341 (perl-libdir "perl-dbi"))
342 (string-append "--with-dbd-sqlite="
343 (perl-libdir "perl-dbd-sqlite"))
344 (string-append "--with-www-curl="
345 (perl-libdir "perl-www-curl"))))))
346 (native-inputs `(("perl" ,perl)
347 ("pkg-config" ,pkg-config)))
348 (inputs `(("curl" ,curl)
349 ("openssl" ,openssl)
350 ("libgc" ,libgc)
351 ("sqlite" ,sqlite)
352 ("bzip2" ,bzip2)
353 ("perl-www-curl" ,perl-www-curl)
354 ("perl-dbi" ,perl-dbi)
355 ("perl-dbd-sqlite" ,perl-dbd-sqlite)))
356 (home-page "http://nixos.org/nix/")
357 (synopsis "The Nix package manager")
358 (description
359 "Nix is a purely functional package manager. This means that it treats
360 packages like values in purely functional programming languages such as
361 Haskell—they are built by functions that don't have side-effects, and they
362 never change after they have been built. Nix stores packages in the Nix
363 store, usually the directory /nix/store, where each package has its own unique
364 sub-directory.")
365 (license lgpl2.1+)))
366
367 (define-public stow
368 (package
369 (name "stow")
370 (version "2.2.2")
371 (source (origin
372 (method url-fetch)
373 (uri (string-append "mirror://gnu/stow/stow-"
374 version ".tar.gz"))
375 (sha256
376 (base32
377 "1pvky9fayms4r6fhns8jd0vavszd7d979w62vfd5n88v614pdxz2"))))
378 (build-system gnu-build-system)
379 (inputs
380 `(("perl" ,perl)))
381 (native-inputs
382 `(("perl-test-simple" ,perl-test-simple)
383 ("perl-test-output" ,perl-test-output)
384 ("perl-capture-tiny" ,perl-capture-tiny)
385 ("perl-io-stringy" ,perl-io-stringy)))
386 (home-page "https://www.gnu.org/software/stow/")
387 (synopsis "Managing installed software packages")
388 (description
389 "GNU Stow is a symlink manager. It generates symlinks to directories
390 of data and makes them appear to be merged into the same directory. It is
391 typically used for managing software packages installed from source, by
392 letting you install them apart in distinct directories and then create
393 symlinks to the files in a common directory such as /usr/local.")
394 (license gpl2+)))
395
396 (define-public rpm
397 (package
398 (name "rpm")
399 (version "4.12.0.1")
400 (source (origin
401 (method url-fetch)
402 (uri (string-append "http://rpm.org/releases/rpm-4.12.x/rpm-"
403 version ".tar.bz2"))
404 (sha256
405 (base32
406 "0a82ym8phx7g0f3k6smvxnvzh7yv857l42xafk49689kzhld5pbp"))
407 (patches (search-patches "rpm-CVE-2014-8118.patch"))))
408 (build-system gnu-build-system)
409 (arguments
410 '(#:configure-flags '("--with-external-db" ;use the system's bdb
411 "--enable-python"
412 "--without-lua")
413 #:phases (modify-phases %standard-phases
414 (add-before 'configure 'set-nspr-search-path
415 (lambda* (#:key inputs #:allow-other-keys)
416 ;; nspr.pc contains the right -I flag pointing to
417 ;; 'include/nspr', but unfortunately 'configure' doesn't
418 ;; use 'pkg-config'. Thus, augment CPATH.
419 ;; Likewise for NSS.
420 (let ((nspr (assoc-ref inputs "nspr"))
421 (nss (assoc-ref inputs "nss")))
422 (setenv "CPATH"
423 (string-append (getenv "C_INCLUDE_PATH") ":"
424 nspr "/include/nspr:"
425 nss "/include/nss"))
426 (setenv "LIBRARY_PATH"
427 (string-append (getenv "LIBRARY_PATH") ":"
428 nss "/lib/nss"))
429 #t)))
430 (add-after 'install 'fix-rpm-symlinks
431 (lambda* (#:key outputs #:allow-other-keys)
432 ;; 'make install' gets these symlinks wrong. Fix them.
433 (let* ((out (assoc-ref outputs "out"))
434 (bin (string-append out "/bin")))
435 (with-directory-excursion bin
436 (for-each (lambda (file)
437 (delete-file file)
438 (symlink "rpm" file))
439 '("rpmquery" "rpmverify"))
440 #t)))))))
441 (native-inputs
442 `(("pkg-config" ,pkg-config)))
443 (inputs
444 `(("python" ,python-2)
445 ("xz" ,xz)
446 ("bdb" ,bdb)
447 ("popt" ,popt)
448 ("nss" ,nss)
449 ("nspr" ,nspr)
450 ("libarchive" ,libarchive)
451 ("nettle" ,nettle) ;XXX: actually a dependency of libarchive
452 ("file" ,file)
453 ("bzip2" ,bzip2)
454 ("zlib" ,zlib)
455 ("cpio" ,cpio)))
456 (home-page "http://www.rpm.org/")
457 (synopsis "The RPM Package Manager")
458 (description
459 "The RPM Package Manager (RPM) is a command-line driven package
460 management system capable of installing, uninstalling, verifying, querying,
461 and updating computer software packages. Each software package consists of an
462 archive of files along with information about the package like its version, a
463 description. There is also a library permitting developers to manage such
464 transactions from C or Python.")
465
466 ;; The whole is GPLv2+; librpm itself is dual-licensed LGPLv2+ | GPLv2+.
467 (license gpl2+)))
468
469 (define-public diffoscope
470 (package
471 (name "diffoscope")
472 (version "81")
473 (source (origin
474 (method url-fetch)
475 (uri (pypi-uri name version))
476 (sha256
477 (base32
478 "093lxy6zj69i19fxdkj3jnai3b1ajqbksyqcvy8wqj3plaaxjna5"))))
479 (build-system python-build-system)
480 (arguments
481 `(#:phases (modify-phases %standard-phases
482 (add-before 'unpack 'n (lambda _ #t))
483 ;; setup.py mistakenly requires python-magic from PyPi, even
484 ;; though the Python bindings of `file` are sufficient.
485 ;; https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815844
486 (add-after 'unpack 'dependency-on-python-magic
487 (lambda _
488 (substitute* "setup.py"
489 (("'python-magic',") ""))))
490 (add-after 'unpack 'embed-tool-references
491 (lambda* (#:key inputs #:allow-other-keys)
492 (substitute* "diffoscope/comparators/utils/compare.py"
493 (("\\['xxd',")
494 (string-append "['" (which "xxd") "',")))
495 (substitute* "diffoscope/comparators/elf.py"
496 (("@tool_required\\('readelf'\\)") "")
497 (("\\['readelf',")
498 (string-append "['" (which "readelf") "',")))
499 #t)))))
500 (inputs `(("rpm" ,rpm) ;for rpm-python
501 ("python-file" ,python-file)
502 ("python-debian" ,python-debian)
503 ("python-libarchive-c" ,python-libarchive-c)
504 ("python-tlsh" ,python-tlsh)
505 ("colordiff" ,colordiff)
506 ("xxd" ,vim)
507
508 ;; Below are modules used for tests.
509 ("python-pytest" ,python-pytest)
510 ("python-chardet" ,python-chardet)))
511 (home-page "http://diffoscope.org/")
512 (synopsis "Compare files, archives, and directories in depth")
513 (description
514 "Diffoscope tries to get to the bottom of what makes files or directories
515 different. It recursively unpacks archives of many kinds and transforms
516 various binary formats into more human readable forms to compare them. It can
517 compare two tarballs, ISO images, or PDFs just as easily.")
518 (license gpl3+)))