Merge branch 'master' into core-updates
[jackhill/guix/guix.git] / gnu / packages / compression.scm
index f977e63..2984e85 100644 (file)
@@ -1,7 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015, 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
-;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
 ;;; Copyright © 2015, 2016 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2015, 2016, 2017, 2018 Ricardo Wurmus <rekado@elephly.net>
@@ -13,7 +13,7 @@
 ;;; Copyright © 2016, 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2016 David Craven <david@craven.ch>
 ;;; Copyright © 2016 Kei Kebreau <kkebreau@posteo.net>
-;;; Copyright © 2016 Marius Bakke <mbakke@fastmail.com>
+;;; Copyright © 2016, 2018 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2017 Nils Gillmann <ng0@n0.is>
 ;;; Copyright © 2017 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
 ;;; Copyright © 2017 Theodoros Foradis <theodoros@foradis.org>
@@ -98,9 +98,8 @@
                ,@(if (%current-target-system)
                      `((setenv "CHOST" ,(%current-target-system)))
                      '())
-               (zero?
-                (system* "./configure"
-                         (string-append "--prefix=" out)))))))))
+               (invoke "./configure"
+                       (string-append "--prefix=" out))))))))
     (home-page "https://zlib.net/")
     (synopsis "Compression library")
     (description
@@ -128,7 +127,7 @@ in compression.")
            (lambda _ (chdir "contrib/minizip") #t))
          (add-after 'enter-source 'autoreconf
            (lambda _
-             (zero? (system* "autoreconf" "-vif")))))))
+             (invoke "autoreconf" "-vif"))))))
     (native-inputs
      `(("autoconf" ,autoconf)
        ("automake" ,automake)
@@ -185,7 +184,7 @@ utility.  Instead of being written in Java, FastJar is written in C.")
       #:phases
       (modify-phases %standard-phases
         (add-after 'unpack 'autoconf
-          (lambda _ (zero? (system* "sh" "autoreconf" "-vfi")))))))
+          (lambda _ (invoke "sh" "autoreconf" "-vfi"))))))
    (native-inputs
     `(("autoconf" ,autoconf)
       ("automake" ,automake)
@@ -202,14 +201,14 @@ adding and extracting files to/from a tar archive.")
 (define-public gzip
   (package
    (name "gzip")
-   (version "1.8")
+   (version "1.9")
    (source (origin
             (method url-fetch)
             (uri (string-append "mirror://gnu/gzip/gzip-"
                                 version ".tar.xz"))
             (sha256
              (base32
-              "1lxv3p4iyx7833mlihkn5wfwmz4cys5nybwpz3dfawag8kn6f5zz"))))
+              "16h8g4acy7fgfxcjacr3wijjsnixwsfd2jhz3zwdi2qrzi262l5f"))))
    (build-system gnu-build-system)
    (synopsis "General file (de)compression (using lzw)")
    (arguments
@@ -252,35 +251,48 @@ file; as a result, it is often used in conjunction with \"tar\", resulting in
        (modify-phases %standard-phases
          (replace 'configure
            (lambda* (#:key target #:allow-other-keys)
-             (if ,(%current-target-system)
-                 ;; Cross-compilation: use the cross tools.
-                 (substitute* (find-files "." "Makefile")
-                   (("CC=.*$")
-                    (string-append "CC = " target "-gcc\n"))
-                   (("AR=.*$")
-                    (string-append "AR = " target "-ar\n"))
-                   (("RANLIB=.*$")
-                    (string-append "RANLIB = " target "-ranlib\n"))
-                   (("^all:(.*)test" _ prerequisites)
-                    ;; Remove 'all' -> 'test' dependency.
-                    (string-append "all:" prerequisites "\n")))
-                 #t)))
+             (when ,(%current-target-system)
+               ;; Cross-compilation: use the cross tools.
+               (substitute* (find-files "." "Makefile")
+                 (("CC=.*$")
+                  (string-append "CC = " target "-gcc\n"))
+                 (("AR=.*$")
+                  (string-append "AR = " target "-ar\n"))
+                 (("RANLIB=.*$")
+                  (string-append "RANLIB = " target "-ranlib\n"))
+                 (("^all:(.*)test" _ prerequisites)
+                  ;; Remove 'all' -> 'test' dependency.
+                  (string-append "all:" prerequisites "\n"))))
+             #t))
          (add-before 'build 'build-shared-lib
            (lambda* (#:key inputs #:allow-other-keys)
              (patch-makefile-SHELL "Makefile-libbz2_so")
-             (zero? (system* "make" "-f" "Makefile-libbz2_so"))))
+             (invoke "make" "-f" "Makefile-libbz2_so")))
          (add-after 'install 'install-shared-lib
            (lambda* (#:key outputs #:allow-other-keys)
+             ;; The Makefile above does not have an 'install' target, nor does
+             ;; it create all the (un)versioned symlinks, so we handle it here.
              (let* ((out    (assoc-ref outputs "out"))
-                    (libdir (string-append out "/lib")))
-               (for-each (lambda (file)
-                           (let ((base (basename file)))
-                             (format #t "installing `~a' to `~a'~%"
-                                     base libdir)
-                             (copy-file file
-                                        (string-append libdir "/" base))))
-                         (find-files "." "^libbz2\\.so")))
-             #t))
+                    (libdir (string-append out "/lib"))
+                    ;; Find the actual library (e.g. "libbz2.so.1.0.6").
+                    (lib (string-drop
+                          (car (find-files
+                                "."
+                                (lambda (file stat)
+                                  (and (string-prefix? "./libbz2.so" file)
+                                       (eq? 'regular (stat:type stat))))))
+                          2))
+                    (soversion (string-drop lib (string-length "libbz2.so."))))
+               (install-file lib libdir)
+               (with-directory-excursion libdir
+                 ;; Create symlinks libbz2.so.1 -> libbz2.so.1.0, etc.
+                 (let loop ((base "libbz2.so")
+                            (numbers (string-split soversion #\.)))
+                   (unless (null? numbers)
+                     (let ((so-file (string-append base "." (car numbers))))
+                       (symlink so-file base)
+                       (loop so-file (cdr numbers))))))
+               #t)))
          (add-after 'install-shared-lib 'patch-scripts
            (lambda* (#:key outputs inputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out")))
@@ -477,14 +489,14 @@ some compression ratio).")
 (define-public lzip
   (package
     (name "lzip")
-    (version "1.19")
+    (version "1.20")
     (source (origin
              (method url-fetch)
              (uri (string-append "mirror://savannah/lzip/lzip-"
                                  version ".tar.gz"))
              (sha256
               (base32
-               "1abbch762gv8rjr579q3qyyk6c80plklbv2mw4x0vg71dgsw9bgz"))))
+               "0319q59kb8g324wnj7xzbr7vvlx5bcs13lr34j0zb3kqlyjq2fy9"))))
     (build-system gnu-build-system)
     (home-page "https://www.nongnu.org/lzip/lzip.html")
     (synopsis "Lossless data compressor based on the LZMA algorithm")
@@ -943,10 +955,11 @@ tarballs.")
                  (base32
                   "1qxxsasvwbbbh6dl3138y9h3fg0q2v7xdk5jjc690bdg7g1wrj6n"))
                 (modules '((guix build utils)))
-                (snippet
-                 ;; This is a recursive submodule that is unnecessary for this
-                 ;; package, so delete it.
-                 '(delete-file-recursively "brotli/terryfy"))))
+                (snippet '(begin
+                            ;; This is a recursive submodule that is
+                            ;; unnecessary for this package, so delete it.
+                            (delete-file-recursively "brotli/terryfy")
+                            #t))))
       (build-system gnu-build-system)
       (native-inputs
        `(("autoconf" ,autoconf)
@@ -957,7 +970,7 @@ tarballs.")
                     (add-after 'unpack 'autogen
                       (lambda _
                         (mkdir "m4")
-                        (zero? (system* "autoreconf" "-vfi")))))))
+                        (invoke "autoreconf" "-vfi"))))))
       (home-page "https://github.com/bagder/libbrotli/")
       (synopsis "Implementation of the Brotli compression algorithm")
       (description
@@ -1005,7 +1018,9 @@ respectively, based on the reference implementation from Google.")
        (file-name (string-append name "-" version ".tar.gz"))
        (snippet
         ;; This file isn't freely distributable and has no effect on building.
-        '(delete-file "xdelta3/draft-korn-vcdiff.txt"))))
+        '(begin
+           (delete-file "xdelta3/draft-korn-vcdiff.txt")
+           #t))))
     (build-system gnu-build-system)
     (native-inputs
      `(("autoconf" ,autoconf)
@@ -1014,9 +1029,9 @@ respectively, based on the reference implementation from Google.")
      `(#:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'enter-build-directory
-           (lambda _ (chdir "xdelta3")))
+           (lambda _ (chdir "xdelta3") #t))
          (add-after 'enter-build-directory 'autoconf
-           (lambda _ (zero? (system* "autoreconf" "-vfi")))))))
+           (lambda _ (invoke "autoreconf" "-vfi"))))))
     (home-page "http://xdelta.org")
     (synopsis "Delta encoder for binary files")
     (description "xdelta encodes only the differences between two binary files
@@ -1177,7 +1192,7 @@ install: libbitshuffle.so
          (add-before 'build 'build-jni
            (lambda _
              ;; Rebuild one of the binaries we removed earlier
-             (system* "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
+             (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
                       "-d" "lib")
              ;; Link to the dynamic bitshuffle and snappy, not the static ones
              (substitute* "Makefile.common"
@@ -1264,7 +1279,7 @@ compresser/decompresser.")
          (add-before 'build 'build-jni
            (lambda _
              ;; Rebuild one of the binaries we removed earlier
-             (system* "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
+             (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
                       "-d" "lib")
              ;; Link to the dynamic snappy, not the static ones
              (substitute* "Makefile.common"
@@ -1281,7 +1296,7 @@ compresser/decompresser.")
                (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
                 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
              ;; Finally we can run the Makefile to build the dynamic library.
-             (zero? (system* "make" "native"))))
+             (invoke "make" "native")))
          ;; Once we have built the shared library, we need to place it in the
          ;; "build" directory so it can be added to the jar file.
          (add-after 'build-jni 'copy-jni
@@ -1320,16 +1335,15 @@ compresser/decompresser.")
          (replace 'check
            (lambda _
              (define (test class)
-               (zero? (system* "java" "-cp" (string-append (getenv "CLASSPATH")
-                                                           ":build/classes"
-                                                           ":build/test-classes")
-                               "-Dtest.resources.dir=src/test/resources"
-                               "org.testng.TestNG" "-testclass"
-                               class)))
-             (system* "ant" "compile-tests")
-             (and
-               (test "org.iq80.snappy.SnappyFramedStreamTest")
-               (test "org.iq80.snappy.SnappyStreamTest"))))
+               (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
+                                                   ":build/classes"
+                                                   ":build/test-classes")
+                       "-Dtest.resources.dir=src/test/resources"
+                       "org.testng.TestNG" "-testclass"
+                       class))
+             (invoke "ant" "compile-tests")
+             (test "org.iq80.snappy.SnappyFramedStreamTest")
+             (test "org.iq80.snappy.SnappyStreamTest")))
          (add-before 'build 'remove-hadoop-dependency
            (lambda _
              ;; We don't have hadoop
@@ -1425,22 +1439,22 @@ It can be used as a replacement for the Apache @code{CBZip2InputStream} /
        (modify-phases %standard-phases
          (replace 'configure
            (lambda* (#:key system outputs #:allow-other-keys)
-             (zero? (system* "cp"
-                             (let ((system ,(or (%current-target-system)
-                                                (%current-system))))
-                               (cond
-                                ((string-prefix? "x86_64" system)
-                                 "makefile.linux_amd64_asm")
-                                ((string-prefix? "i686" system)
-                                 "makefile.linux_x86_asm_gcc_4.X")
-                                (else
-                                 "makefile.linux_any_cpu_gcc_4.X")))
-                             "makefile.machine"))))
+             (invoke "cp"
+                     (let ((system ,(or (%current-target-system)
+                                        (%current-system))))
+                       (cond
+                        ((string-prefix? "x86_64" system)
+                         "makefile.linux_amd64_asm")
+                        ((string-prefix? "i686" system)
+                         "makefile.linux_x86_asm_gcc_4.X")
+                        (else
+                         "makefile.linux_any_cpu_gcc_4.X")))
+                     "makefile.machine")))
          (replace 'check
            (lambda _
-             (and (zero? (system* "make" "test"))
-                  (zero? (system* "make" "test_7z"))
-                  (zero? (system* "make" "test_7zr"))))))))
+             (invoke "make" "test")
+             (invoke "make" "test_7z")
+             (invoke "make" "test_7zr"))))))
     (inputs
      (let ((system (or (%current-target-system)
                        (%current-system))))
@@ -1473,7 +1487,9 @@ handles the 7z format which features very high compression ratios.")
                 (modules '((guix build utils)))
                 (snippet
                  ;; Remove pre-compiled object.
-                 '(delete-file "gzstream.o"))))
+                 '(begin
+                    (delete-file "gzstream.o")
+                    #t))))
     (build-system gnu-build-system)
     (arguments
      `(#:test-target "test"
@@ -1510,7 +1526,9 @@ functionality in a C++ iostream.")
        (modules '((guix build utils)))
        (snippet
         ;; Delete irrelevant pre-compiled binaries.
-        '(for-each delete-file (find-files "." "\\.exe$")))))
+        '(begin
+           (for-each delete-file (find-files "." "\\.exe$"))
+           #t))))
     (build-system gnu-build-system)
     (arguments
      `(#:phases
@@ -1619,7 +1637,7 @@ or junctions, and always follows hard links.")
              #t))
          (replace 'check
            (lambda _
-            (zero? (system* "./run-tests.sh")))))))
+             (invoke "./run-tests.sh"))))))
     (home-page "https://github.com/twogood/unshield")
     (synopsis "Extract CAB files from InstallShield installers")
     (description
@@ -1685,7 +1703,7 @@ speed.")
          (delete 'configure)            ; no configure script
          (add-before 'check 'compile-tests
            (lambda* (#:key make-flags #:allow-other-keys)
-             (zero? (apply system* "make" "tests" make-flags))))
+             (apply invoke "make" "tests" make-flags)))
          (add-after 'install 'install-documentation
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
@@ -1729,14 +1747,11 @@ the actual decompression, the other input and output.")
                       (list "-f" "unix/Makefile"
                             (string-append "prefix=" out)
                             (string-append "MANDIR=" out "/share/man/man1")))
-       #:modules ((guix build gnu-build-system)
-                  (guix build utils)
-                  (srfi srfi-1))
        #:phases
        (modify-phases %standard-phases
          (replace 'build
            (lambda* (#:key (make-flags '()) #:allow-other-keys)
-             (zero? (apply system* "make" "generic_gcc" make-flags))))
+             (apply invoke "make" "generic_gcc" make-flags)))
          (delete 'configure))))
     (home-page "http://www.info-zip.org/Zip.html")
     (synopsis "Compression and file packing utility")
@@ -1758,7 +1773,6 @@ Compression ratios of 2:1 to 3:1 are common for text files.")
 (define-public unzip
   (package (inherit zip)
     (name "unzip")
-    (replacement unzip/fixed)
     (version "6.0")
     (source
      (origin
@@ -1786,13 +1800,20 @@ Compression ratios of 2:1 to 3:1 are common for text files.")
     (arguments
      `(#:phases (modify-phases %standard-phases
                   (delete 'configure)
+                  (add-after 'unpack 'fortify
+                    (lambda _
+                      ;; Mitigate CVE-2018-1000035, an exploitable buffer overflow.
+                      ;; This environment variable is recommended in 'unix/Makefile'
+                      ;; for passing flags to the C compiler.
+                      (setenv "LOCAL_UNZIP" "-D_FORTIFY_SOURCE=1")
+                      #t))
                   (replace 'build
                     (lambda* (#:key make-flags #:allow-other-keys)
-                      (zero? (apply system* "make"
-                                    `("-j" ,(number->string
-                                             (parallel-job-count))
-                                      ,@make-flags
-                                      "generic_gcc"))))))
+                      (apply invoke "make"
+                             `("-j" ,(number->string
+                                      (parallel-job-count))
+                               ,@make-flags
+                               "generic_gcc")))))
        #:make-flags (list "-f" "unix/Makefile"
                           (string-append "prefix=" %output)
                           (string-append "MANDIR=" %output "/share/man/man1"))))
@@ -1809,20 +1830,6 @@ recreates the stored directory structure by default.")
     (license (license:non-copyleft "file://LICENSE"
                                    "See LICENSE in the distribution."))))
 
-(define unzip/fixed
-  (package/inherit unzip
-    (arguments
-      (substitute-keyword-arguments (package-arguments unzip)
-        ((#:phases phases)
-          `(modify-phases ,phases
-             (add-after 'unpack 'fortify
-               (lambda _
-                 ;; Mitigate CVE-2018-1000035, an exploitable buffer overflow.
-                 ;; This environment variable is recommended in 'unix/Makefile'
-                 ;; for passing flags to the C compiler.
-                 (setenv "LOCAL_UNZIP" "-D_FORTIFY_SOURCE=1")
-                 #t))))))))
-
 (define-public zziplib
   (package
     (name "zziplib")