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