gnu: Python: use /nix/.../sh instead of /bin/sh in the subprocess module
[jackhill/guix/guix.git] / gnu / packages / compression.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
4 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
5 ;;;
6 ;;; This file is part of GNU Guix.
7 ;;;
8 ;;; GNU Guix is free software; you can redistribute it and/or modify it
9 ;;; under the terms of the GNU General Public License as published by
10 ;;; the Free Software Foundation; either version 3 of the License, or (at
11 ;;; your option) any later version.
12 ;;;
13 ;;; GNU Guix is distributed in the hope that it will be useful, but
14 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;;; GNU General Public License for more details.
17 ;;;
18 ;;; You should have received a copy of the GNU General Public License
19 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21 (define-module (gnu packages compression)
22 #:use-module ((guix licenses)
23 #:renamer (symbol-prefix-proc 'license:))
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix build-system gnu)
27 #:use-module (gnu packages which))
28
29 (define-public zlib
30 (package
31 (name "zlib")
32 (version "1.2.7")
33 (source
34 (origin
35 (method url-fetch)
36 (uri (list (string-append "http://zlib.net/zlib-"
37 version ".tar.gz")
38 (string-append "mirror://sourceforge/libpng/zlib-"
39 version ".tar.gz")))
40 (sha256
41 (base32
42 "1i96gsdvxqb6skp9a58bacf1wxamwi9m9pg4yn7cpf7g7239r77s"))))
43 (build-system gnu-build-system)
44 (arguments
45 `(#:phases (alist-replace
46 'configure
47 (lambda* (#:key outputs #:allow-other-keys)
48 ;; Zlib's home-made `configure' fails when passed
49 ;; extra flags like `--enable-fast-install', so we need to
50 ;; invoke it with just what it understand.
51 (let ((out (assoc-ref outputs "out")))
52 ;; 'configure' doesn't understand '--host'.
53 ,@(if (%current-target-system)
54 `((setenv "CHOST" ,(%current-target-system)))
55 '())
56 (zero?
57 (system* "./configure"
58 (string-append "--prefix=" out)))))
59 %standard-phases)))
60 (home-page "http://zlib.net/")
61 (synopsis "The zlib compression library")
62 (description
63 "zlib is designed to be a free, general-purpose, legally unencumbered --
64 that is, not covered by any patents -- lossless data-compression library for
65 use on virtually any computer hardware and operating system. The zlib data
66 format is itself portable across platforms. Unlike the LZW compression method
67 used in Unix compress(1) and in the GIF image format, the compression method
68 currently used in zlib essentially never expands the data. (LZW can double or
69 triple the file size in extreme cases.) zlib's memory footprint is also
70 independent of the input data and can be reduced, if necessary, at some cost
71 in compression.")
72 (license license:zlib)))
73
74 (define-public gzip
75 (package
76 (name "gzip")
77 (version "1.6")
78 (source (origin
79 (method url-fetch)
80 (uri (string-append "mirror://gnu/gzip/gzip-"
81 version ".tar.gz"))
82 (sha256
83 (base32
84 "0zlgdm4v3dndrbiz7b67mbbj25dpwqbmbzjiycssvrfrcfvq7swp"))))
85 (build-system gnu-build-system)
86 (synopsis "General file (de)compression (using lzw)")
87 (arguments
88 ;; FIXME: The test suite wants `less', and optionally Perl.
89 '(#:tests? #f))
90 (description
91 "GNU Gzip provides data compression and decompression utilities; the
92 typical extension is \".gz\". Unlike the \"zip\" format, it compresses a single
93 file; as a result, it is often used in conjunction with \"tar\", resulting in
94 \".tar.gz\" or \".tgz\", etc.")
95 (license license:gpl3+)
96 (home-page "http://www.gnu.org/software/gzip/")))
97
98 (define-public bzip2
99 (let ((fix-man-dir
100 ;; Move man pages to $out/share/.
101 '(lambda* (#:key outputs #:allow-other-keys)
102 (with-directory-excursion (assoc-ref outputs "out")
103 (mkdir "share")
104 (rename-file "man" "share/man"))))
105 (build-shared-lib
106 ;; Build a shared library.
107 '(lambda* (#:key inputs #:allow-other-keys)
108 (patch-makefile-SHELL "Makefile-libbz2_so")
109 (zero? (system* "make" "-f" "Makefile-libbz2_so"))))
110 (install-shared-lib
111 '(lambda* (#:key outputs #:allow-other-keys)
112 (let* ((out (assoc-ref outputs "out"))
113 (libdir (string-append out "/lib")))
114 (for-each (lambda (file)
115 (let ((base (basename file)))
116 (format #t "installing `~a' to `~a'~%"
117 base libdir)
118 (copy-file file
119 (string-append libdir "/" base))))
120 (find-files "." "^libbz2\\.so")))))
121 (set-cross-environment
122 '(lambda* (#:key target #:allow-other-keys)
123 (substitute* (find-files "." "Makefile")
124 (("CC=.*$")
125 (string-append "CC = " target "-gcc\n"))
126 (("AR=.*$")
127 (string-append "AR = " target "-ar\n"))
128 (("RANLIB=.*$")
129 (string-append "RANLIB = " target "-ranlib\n"))
130 (("^all:(.*)test" _ prerequisites)
131 ;; Remove 'all' -> 'test' dependency.
132 (string-append "all:" prerequisites "\n"))))))
133 (package
134 (name "bzip2")
135 (version "1.0.6")
136 (source (origin
137 (method url-fetch)
138 (uri (string-append "http://www.bzip.org/" version "/bzip2-"
139 version ".tar.gz"))
140 (sha256
141 (base32
142 "1kfrc7f0ja9fdn6j1y6yir6li818npy6217hvr3wzmnmzhs8z152"))))
143 (build-system gnu-build-system)
144 (arguments
145 `(#:modules ((guix build gnu-build-system)
146 (guix build utils)
147 (srfi srfi-1))
148 #:phases
149 ,(if (%current-target-system)
150
151 ;; Cross-compilation: use the cross tools.
152 `(alist-cons-before
153 'build 'build-shared-lib ,build-shared-lib
154 (alist-cons-after
155 'install 'fix-man-dir ,fix-man-dir
156 (alist-cons-after
157 'install 'install-shared-lib ,install-shared-lib
158 (alist-replace 'configure ,set-cross-environment
159 %standard-phases))))
160
161 ;; Native compilation: build the shared library.
162 `(alist-cons-before
163 'build 'build-shared-lib ,build-shared-lib
164 (alist-cons-after
165 'install 'fix-man-dir ,fix-man-dir
166 (alist-cons-after
167 'install 'install-shared-lib ,install-shared-lib
168 (alist-delete 'configure %standard-phases)))))
169
170 #:make-flags (list (string-append "PREFIX="
171 (assoc-ref %outputs "out")))
172
173 ;; Don't attempt to run the tests when cross-compiling.
174 ,@(if (%current-target-system)
175 '(#:tests? #f)
176 '())))
177 (synopsis "high-quality data compression program")
178 (description
179 "bzip2 is a freely available, patent free (see below), high-quality data
180 compressor. It typically compresses files to within 10% to 15% of the best
181 available techniques (the PPM family of statistical compressors), whilst
182 being around twice as fast at compression and six times faster at
183 decompression.")
184 (license (license:bsd-style "file://LICENSE"
185 "See LICENSE in the distribution."))
186 (home-page "http://www.bzip.org/"))))
187
188 (define-public xz
189 (package
190 (name "xz")
191 (version "5.0.4")
192 (source (origin
193 (method url-fetch)
194 (uri (string-append "http://tukaani.org/xz/xz-" version
195 ".tar.gz"))
196 (sha256
197 (base32
198 "1dl35ca8fdss9z2d6y234gxh24ixq904xksizrjmjr5dimwhax6n"))))
199 (build-system gnu-build-system)
200 (synopsis
201 "XZ, general-purpose data compression software, successor of LZMA")
202 (description
203 "XZ Utils is free general-purpose data compression software with high
204 compression ratio. XZ Utils were written for POSIX-like systems, but also
205 work on some not-so-POSIX systems. XZ Utils are the successor to LZMA Utils.
206
207 The core of the XZ Utils compression code is based on LZMA SDK, but it has
208 been modified quite a lot to be suitable for XZ Utils. The primary
209 compression algorithm is currently LZMA2, which is used inside the .xz
210 container format. With typical files, XZ Utils create 30 % smaller output
211 than gzip and 15 % smaller output than bzip2.")
212 (license (list license:gpl2+ license:lgpl2.1+)) ; bits of both
213 (home-page "http://tukaani.org/xz/")))
214
215 (define-public lzo
216 (package
217 (name "lzo")
218 (version "2.06")
219 (source
220 (origin
221 (method url-fetch)
222 (uri (string-append "http://www.oberhumer.com/opensource/lzo/download/lzo-"
223 version ".tar.gz"))
224 (sha256
225 (base32
226 "0wryshs446s7cclrbjykyj766znhcpnr7s3cxy33ybfn6vwfcygz"))))
227 (build-system gnu-build-system)
228 (arguments '(#:configure-flags '("--enable-shared")))
229 (home-page "http://www.oberhumer.com/opensource/lzo")
230 (synopsis
231 "A data compresion library suitable for real-time data de-/compression")
232 (description
233 "LZO is a data compression library which is suitable for data
234 de-/compression in real-time. This means it favours speed over
235 compression ratio.
236
237 LZO is written in ANSI C. Both the source code and the compressed data
238 format are designed to be portable across platforms.")
239 (license license:gpl2+)))
240
241 (define-public lzip
242 (package
243 (name "lzip")
244 (version "1.15")
245 (source (origin
246 (method url-fetch)
247 (uri (string-append "mirror://savannah/lzip/lzip-"
248 version ".tar.gz"))
249 (sha256
250 (base32
251 "1dh5vmj5apizfawnsm50y7z064yx7cz3313przph16gwd3dgrlvw"))))
252 (build-system gnu-build-system)
253 (home-page "http://www.nongnu.org/lzip/lzip.html")
254 (synopsis "Lossless data compressor based on the LZMA algorithm")
255 (description
256 "Lzip is a lossless data compressor with a user interface similar to the
257 one of gzip or bzip2. Lzip decompresses almost as fast as gzip and compresses
258 more than bzip2, which makes it well suited for software distribution and data
259 archiving. Lzip is a clean implementation of the LZMA algorithm.")
260 (license license:gpl3+)))
261
262 (define-public sharutils
263 (package
264 (name "sharutils")
265 (version "4.14")
266 (source
267 (origin
268 (method url-fetch)
269 (uri (string-append "mirror://gnu/sharutils/sharutils-"
270 version ".tar.xz"))
271 (sha256
272 (base32
273 "033sq1v0cp0bi1mp320xaqwd4fhakqc5747hh6qa1asjrzpqiqza"))))
274 (build-system gnu-build-system)
275 (inputs
276 `(("which" ,which)))
277 (arguments
278 `(#:phases
279 (alist-cons-after
280 'patch-source-shebangs 'unpatch-source-shebang
281 ;; revert the patch-shebang phase on a script which is
282 ;; in fact test data
283 (lambda* (#:key #:allow-other-keys)
284 (substitute* "tests/shar-1.ok"
285 (((which "sh")) "/bin/sh")))
286 %standard-phases)))
287 (home-page "http://www.gnu.org/software/sharutils/")
288 (synopsis "Archives in shell scripts, uuencode/uudecode")
289 (description
290 "GNU sharutils is a package for creating and manipulating shell
291 archives that can be readily emailed. A shell archive is a file that can be
292 processed by a Bourne-type shell to unpack the original collection of files.
293 This package is mostly for compatibility and historical interest.")
294 (license license:gpl3+)))