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