utils: Re-export 'delete'.
[jackhill/guix/guix.git] / gnu / packages / package-management.scm
CommitLineData
bbe8d8f0 1;;; GNU Guix --- Functional package management for GNU
a9174065 2;;; Copyright © 2013, 2014, 2015, 2016, 2017 Ludovic Courtès <ludo@gnu.org>
5dbeccf5 3;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
bbe8d8f0
LC
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)
480af4d6 23 #:use-module (guix git-download)
04eb0fab 24 #:use-module (guix gexp)
480af4d6 25 #:use-module (guix utils)
bbe8d8f0 26 #:use-module (guix build-system gnu)
e3e1ecf6
LC
27 #:use-module (guix build-system python)
28 #:use-module ((guix licenses) #:select (gpl2+ gpl3+ lgpl2.1+ asl2.0))
8a43ff10 29 #:use-module (gnu packages)
bbe8d8f0 30 #:use-module (gnu packages guile)
e3e1ecf6
LC
31 #:use-module (gnu packages file)
32 #:use-module (gnu packages backup)
38cf2ba0 33 #:use-module (gnu packages compression)
bbe8d8f0 34 #:use-module (gnu packages gnupg)
5f96f303 35 #:use-module (gnu packages databases)
480af4d6
LC
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)
fcb0109d 40 #:use-module (gnu packages texinfo)
e3e1ecf6 41 #:use-module (gnu packages nettle)
fcb0109d
LC
42 #:use-module (gnu packages perl)
43 #:use-module (gnu packages curl)
44 #:use-module (gnu packages web)
e21adc76 45 #:use-module (gnu packages man)
a7fd7b68 46 #:use-module (gnu packages bdw-gc)
5dbeccf5 47 #:use-module (gnu packages patchutils)
e3e1ecf6
LC
48 #:use-module (gnu packages python)
49 #:use-module (gnu packages popt)
50 #:use-module (gnu packages gnuzilla)
51 #:use-module (gnu packages cpio)
04eb0fab 52 #:use-module (gnu packages tls)
43ddcd72 53 #:use-module (gnu packages ssh)
5dbeccf5 54 #:use-module (gnu packages vim)
82ce81ba 55 #:use-module (srfi srfi-1)
04eb0fab 56 #:use-module (ice-9 match))
bbe8d8f0 57
39de700c
LC
58(define (boot-guile-uri arch)
59 "Return the URI for the bootstrap Guile tarball for ARCH."
aef81a81
LC
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)
b31b0155
LC
65 (string-append "http://alpha.gnu.org/gnu/guix/bootstrap/"
66 arch "-linux/20170217/guile-2.0.14.tar.xz"))
aef81a81
LC
67 (else
68 (string-append "http://alpha.gnu.org/gnu/guix/bootstrap/"
69 arch "-linux"
70 "/20131110/guile-2.0.9.tar.xz"))))
39de700c 71
994a1494
LC
72(define-public guix
73 ;; Latest version of Guix, which may or may not correspond to a release.
94fa8d76
LC
74 ;; Note: the 'update-guix-package.scm' script expects this definition to
75 ;; start precisely like this.
a6d728b7 76 (let ((version "0.13.0")
e9c53359
LC
77 (commit "a6d728b7aaee09892b0b420d07ed2dbb7de5e63f")
78 (revision 1))
994a1494
LC
79 (package
80 (name "guix")
ab2419e5 81
994a1494
LC
82 (version (if (zero? revision)
83 version
84 (string-append version "-"
85 (number->string revision)
4b7917f2 86 "." (string-take commit 7))))
994a1494
LC
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
e9c53359 94 "1nrskyk8z6w5i9cdfh5zxfgsrqf744sb30ssqi2g5xhijwagr1yq"))
994a1494
LC
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.)
4b7917f2
LC
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")
994a1494
LC
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$"))
ab2419e5 132
994a1494
LC
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")))
39de700c 141
994a1494
LC
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)))
bbe8d8f0 153
994a1494
LC
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)))
61cdad35 199
994a1494
LC
200 (wrap-program (string-append out "/bin/guix")
201 `("GUILE_LOAD_PATH" ":" prefix (,path))
202 `("GUILE_LOAD_COMPILED_PATH" ":" prefix (,path)))
61cdad35 203
994a1494
LC
204 #t))))))
205 (native-inputs `(("pkg-config" ,pkg-config)
a7db8540 206
994a1494
LC
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'
2d195e67 225
994a1494
LC
226 ("sqlite" ,sqlite)
227 ("libgcrypt" ,libgcrypt)
7561881f 228 ("guile" ,guile-2.2)
bbe8d8f0 229
994a1494
LC
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
7561881f 251 `(("gnutls" ,gnutls/guile-2.2) ;for 'guix download' & co.
2252f087 252 ("guile-json" ,guile-json)
4d8806c3 253 ("guile-ssh" ,guile-ssh)))
f1082ec1 254
994a1494
LC
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
c5779c93 259also a distribution thereof. It includes a virtual machine image. Besides
79c311b8 260the usual package management features, it also supports transactional
c5779c93
LC
261upgrades and roll-backs, per-user profiles, and much more. It is based on
262the Nix package manager.")
994a1494
LC
263 (license gpl3+)
264 (properties '((ftp-server . "alpha.gnu.org"))))))
3ad9a0b1 265
994a1494
LC
266;; Alias for backward compatibility.
267(define-public guix-devel guix)
fcb0109d 268
82ce81ba
LC
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
04eb0fab
LC
281(define (source-file? file stat)
282 "Return true if FILE is likely a source file, false if it is a typical
283generated 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
04eb0fab 297(define-public current-guix
6554be68 298 (let ((select? (delay (or (git-predicate
04eb0fab
LC
299 (string-append (current-source-directory)
300 "/../.."))
301 source-file?))))
302 (lambda ()
303 "Return a package representing Guix built from the current source tree.
304This works by adding the current source tree to the store (after filtering it
305out) 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
fcb0109d
LC
318(define-public nix
319 (package
320 (name "nix")
a041d56e 321 (version "1.11.9")
fcb0109d
LC
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
a041d56e 328 "1qg7qrfr60dysmyfg3ijgani71l23p1kqadhjs8kz11pgwkkx50f"))))
fcb0109d
LC
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.
9083788a
SB
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"))))))
fcb0109d
LC
346 (native-inputs `(("perl" ,perl)
347 ("pkg-config" ,pkg-config)))
348 (inputs `(("curl" ,curl)
349 ("openssl" ,openssl)
350 ("libgc" ,libgc)
351 ("sqlite" ,sqlite)
9083788a
SB
352 ("bzip2" ,bzip2)
353 ("perl-www-curl" ,perl-www-curl)
354 ("perl-dbi" ,perl-dbi)
355 ("perl-dbd-sqlite" ,perl-dbd-sqlite)))
fcb0109d
LC
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
360packages like values in purely functional programming languages such as
361Haskell—they are built by functions that don't have side-effects, and they
362never change after they have been built. Nix stores packages in the Nix
363store, usually the directory /nix/store, where each package has its own unique
364sub-directory.")
365 (license lgpl2.1+)))
8d422e25
RW
366
367(define-public stow
368 (package
369 (name "stow")
ddfd70da 370 (version "2.2.2")
8d422e25
RW
371 (source (origin
372 (method url-fetch)
373 (uri (string-append "mirror://gnu/stow/stow-"
374 version ".tar.gz"))
375 (sha256
376 (base32
ddfd70da 377 "1pvky9fayms4r6fhns8jd0vavszd7d979w62vfd5n88v614pdxz2"))))
8d422e25
RW
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)
ddfd70da
LC
384 ("perl-capture-tiny" ,perl-capture-tiny)
385 ("perl-io-stringy" ,perl-io-stringy)))
8d422e25
RW
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
390of data and makes them appear to be merged into the same directory. It is
391typically used for managing software packages installed from source, by
392letting you install them apart in distinct directories and then create
393symlinks to the files in a common directory such as /usr/local.")
394 (license gpl2+)))
e3e1ecf6
LC
395
396(define-public rpm
397 (package
398 (name "rpm")
41019e9f 399 (version "4.12.0.1")
e3e1ecf6
LC
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
65da8dd0
LF
406 "0a82ym8phx7g0f3k6smvxnvzh7yv857l42xafk49689kzhld5pbp"))
407 (patches (search-patches "rpm-CVE-2014-8118.patch"))))
e3e1ecf6
LC
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"
e8e2e18b 423 (string-append (getenv "C_INCLUDE_PATH") ":"
e3e1ecf6
LC
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
460management system capable of installing, uninstalling, verifying, querying,
461and updating computer software packages. Each software package consists of an
462archive of files along with information about the package like its version, a
463description. There is also a library permitting developers to manage such
464transactions from C or Python.")
465
466 ;; The whole is GPLv2+; librpm itself is dual-licensed LGPLv2+ | GPLv2+.
467 (license gpl2+)))
468
08dcff47
LC
469(define-public diffoscope
470 (package
471 (name "diffoscope")
a7ccfefd 472 (version "81")
08dcff47 473 (source (origin
7dd21101
LF
474 (method url-fetch)
475 (uri (pypi-uri name version))
08dcff47
LC
476 (sha256
477 (base32
a7ccfefd 478 "093lxy6zj69i19fxdkj3jnai3b1ajqbksyqcvy8wqj3plaaxjna5"))))
08dcff47
LC
479 (build-system python-build-system)
480 (arguments
7dd21101 481 `(#:phases (modify-phases %standard-phases
a7ccfefd 482 (add-before 'unpack 'n (lambda _ #t))
7dd21101
LF
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"
5dbeccf5
RW
489 (("'python-magic',") ""))))
490 (add-after 'unpack 'embed-tool-references
491 (lambda* (#:key inputs #:allow-other-keys)
025519fa 492 (substitute* "diffoscope/comparators/utils/compare.py"
5dbeccf5
RW
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)))))
08dcff47 500 (inputs `(("rpm" ,rpm) ;for rpm-python
7dd21101
LF
501 ("python-file" ,python-file)
502 ("python-debian" ,python-debian)
503 ("python-libarchive-c" ,python-libarchive-c)
504 ("python-tlsh" ,python-tlsh)
5dbeccf5
RW
505 ("colordiff" ,colordiff)
506 ("xxd" ,vim)
08dcff47
LC
507
508 ;; Below are modules used for tests.
7dd21101
LF
509 ("python-pytest" ,python-pytest)
510 ("python-chardet" ,python-chardet)))
08dcff47
LC
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
515different. It recursively unpacks archives of many kinds and transforms
516various binary formats into more human readable forms to compare them. It can
517compare two tarballs, ISO images, or PDFs just as easily.")
518 (license gpl3+)))