gnu: Move Python compression packages to new module.
[jackhill/guix/guix.git] / gnu / packages / java-compression.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2017, 2018 Julien Lepiller <julien@lepiller.eu>
4 ;;; Copyright © 2018 Marius Bakke <mbakke@fastmail.com>
5 ;;; Copyright © 2018 Mark H Weaver <mhw@netris.org>
6 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;;
8 ;;; This file is part of GNU Guix.
9 ;;;
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
14 ;;;
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
22
23 (define-module (gnu packages java-compression)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix utils)
26 #:use-module (guix packages)
27 #:use-module (guix download)
28 #:use-module (guix build-system ant)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages compression)
31 #:use-module (gnu packages java)
32 #:use-module (gnu packages perl)
33 #:use-module (gnu packages python-compression))
34
35 (define-public java-snappy
36 (package
37 (name "java-snappy")
38 (version "1.1.7.2")
39 (source (origin
40 (method url-fetch)
41 (uri (string-append "https://github.com/xerial/snappy-java/archive/"
42 version ".tar.gz"))
43 (file-name (string-append name "-" version ".tar.gz"))
44 (sha256
45 (base32
46 "1p557vdv006ysgxbpp83krmq0066k46108vyiyka69w8i4i8rbbm"))))
47 (build-system ant-build-system)
48 (arguments
49 `(#:jar-name "snappy.jar"
50 #:source-dir "src/main/java"
51 #:phases
52 (modify-phases %standard-phases
53 (add-before 'build 'remove-binaries
54 (lambda _
55 (delete-file "lib/org/xerial/snappy/OSInfo.class")
56 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
57 #t))
58 (add-before 'build 'build-jni
59 (lambda _
60 ;; Rebuild one of the binaries we removed earlier
61 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
62 "-d" "lib")
63 ;; Link to the dynamic bitshuffle and snappy, not the static ones
64 (substitute* "Makefile.common"
65 (("-shared")
66 "-shared -lbitshuffle -lsnappy"))
67 (substitute* "Makefile"
68 ;; Don't try to use git, don't download bitshuffle source
69 ;; and don't build it.
70 (("\\$\\(SNAPPY_GIT_UNPACKED\\) ")
71 "")
72 ((": \\$\\(SNAPPY_GIT_UNPACKED\\)")
73 ":")
74 (("\\$\\(BITSHUFFLE_UNPACKED\\) ")
75 "")
76 ((": \\$\\(SNAPPY_SOURCE_CONFIGURED\\)") ":")
77 ;; What we actually want to build
78 (("SNAPPY_OBJ:=.*")
79 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, \
80 SnappyNative.o BitShuffleNative.o)\n")
81 ;; Since we removed the directory structure in "native" during
82 ;; the previous phase, we need to recreate it.
83 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
84 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
85 ;; Finally we can run the Makefile to build the dynamic library.
86 ;; Use the -nocmake target to avoid a dependency on cmake,
87 ;; which in turn requires the "git_unpacked" directory.
88 (invoke "make" "native-nocmake")))
89 ;; Once we have built the shared library, we need to place it in the
90 ;; "build" directory so it can be added to the jar file.
91 (add-after 'build-jni 'copy-jni
92 (lambda _
93 (copy-recursively "src/main/resources/org/xerial/snappy/native"
94 "build/classes/org/xerial/snappy/native")
95 #t))
96 (add-before 'check 'fix-failing
97 (lambda _
98 (with-directory-excursion "src/test/java/org/xerial/snappy"
99 ;; This package assumes maven build, which puts results in "target".
100 ;; We put them in "build" instead, so fix that.
101 (substitute* "SnappyLoaderTest.java"
102 (("target/classes") "build/classes"))
103 ;; This requires Hadoop, which is not in Guix yet.
104 (delete-file "SnappyHadoopCompatibleOutputStreamTest.java"))
105 #t)))))
106 (inputs
107 `(("osgi-framework" ,java-osgi-framework)))
108 (propagated-inputs
109 `(("bitshuffle" ,bitshuffle-for-snappy)
110 ("snappy" ,snappy)))
111 (native-inputs
112 `(("junit" ,java-junit)
113 ("hamcrest" ,java-hamcrest-core)
114 ("xerial-core" ,java-xerial-core)
115 ("classworlds" ,java-plexus-classworlds)
116 ("commons-lang" ,java-commons-lang)
117 ("commons-io" ,java-commons-io)
118 ("perl" ,perl)))
119 (home-page "https://github.com/xerial/snappy-java")
120 (synopsis "Compression/decompression algorithm in Java")
121 (description "Snappy-java is a Java port of snappy, a fast C++
122 compressor/decompressor.")
123 (license license:asl2.0)))
124
125 (define-public java-snappy-1
126 (package
127 (inherit java-snappy)
128 (version "1.0.3-rc3")
129 (source (origin
130 (method url-fetch)
131 (uri (string-append "https://github.com/xerial/snappy-java/archive/"
132 "snappy-java-" version ".tar.gz"))
133 (sha256
134 (base32
135 "08hsxlqidiqck0q57fshwyv3ynyxy18vmhrai9fyc8mz17m7gsa3"))))
136 (arguments
137 `(#:jar-name "snappy.jar"
138 #:source-dir "src/main/java"
139 #:phases
140 (modify-phases %standard-phases
141 (add-before 'build 'remove-binaries
142 (lambda _
143 (delete-file "lib/org/xerial/snappy/OSInfo.class")
144 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
145 #t))
146 (add-before 'build 'build-jni
147 (lambda _
148 ;; Rebuild one of the binaries we removed earlier
149 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
150 "-d" "lib")
151 ;; Link to the dynamic snappy, not the static ones
152 (substitute* "Makefile.common"
153 (("-shared") "-shared -lsnappy"))
154 (substitute* "Makefile"
155 ;; Don't download the sources here.
156 (("\\$\\(SNAPPY_UNPACKED\\) ") "")
157 ((": \\$\\(SNAPPY_UNPACKED\\) ") ":")
158 ;; What we actually want to build
159 (("SNAPPY_OBJ:=.*")
160 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, SnappyNative.o)\n")
161 ;; Since we removed the directory structure in "native" during
162 ;; the previous phase, we need to recreate it.
163 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
164 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
165 ;; Finally we can run the Makefile to build the dynamic library.
166 (invoke "make" "native")))
167 ;; Once we have built the shared library, we need to place it in the
168 ;; "build" directory so it can be added to the jar file.
169 (add-after 'build-jni 'copy-jni
170 (lambda _
171 (copy-recursively "src/main/resources/org/xerial/snappy/native"
172 "build/classes/org/xerial/snappy/native")
173 #t))
174 (add-before 'check 'fix-tests
175 (lambda _
176 (mkdir-p "src/test/resources/org/xerial/snappy/")
177 (copy-recursively "src/test/java/org/xerial/snappy/testdata"
178 "src/test/resources/org/xerial/snappy/testdata")
179 (install-file "src/test/java/org/xerial/snappy/alice29.txt"
180 "src/test/resources/org/xerial/snappy/")
181 #t)))))))
182
183 (define-public java-iq80-snappy
184 (package
185 (name "java-iq80-snappy")
186 (version "0.4")
187 (source (origin
188 (method url-fetch)
189 (uri (string-append "https://github.com/dain/snappy/archive/snappy-"
190 version ".tar.gz"))
191 (sha256
192 (base32
193 "0rb3zhci7w9wzd65lfnk7p3ip0n6gb58a9qpx8n7r0231gahyamf"))))
194 (build-system ant-build-system)
195 (arguments
196 `(#:jar-name "iq80-snappy.jar"
197 #:source-dir "src/main/java"
198 #:test-dir "src/test"
199 #:jdk ,icedtea-8
200 #:phases
201 (modify-phases %standard-phases
202 (replace 'check
203 (lambda _
204 (define (test class)
205 (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
206 ":build/classes"
207 ":build/test-classes")
208 "-Dtest.resources.dir=src/test/resources"
209 "org.testng.TestNG" "-testclass"
210 class))
211 (invoke "ant" "compile-tests")
212 (test "org.iq80.snappy.SnappyFramedStreamTest")
213 (test "org.iq80.snappy.SnappyStreamTest")
214 #t))
215 (add-before 'build 'remove-hadoop-dependency
216 (lambda _
217 ;; We don't have hadoop
218 (delete-file "src/main/java/org/iq80/snappy/HadoopSnappyCodec.java")
219 (delete-file "src/test/java/org/iq80/snappy/TestHadoopSnappyCodec.java")
220 #t)))))
221 (home-page "https://github.com/dain/snappy")
222 (native-inputs
223 `(("guava" ,java-guava)
224 ("java-snappy" ,java-snappy)
225 ("hamcrest" ,java-hamcrest-core)
226 ("testng" ,java-testng)))
227 (synopsis "Java port of the Snappy (de)compressor")
228 (description
229 "Iq80-snappy is a port of the Snappy compressor and decompressor rewritten
230 in pure Java. This compression code produces a byte-for-byte exact copy of the
231 output created by the original C++ code, and is extremely fast.")
232 (license license:asl2.0)))
233
234 (define-public java-jbzip2
235 (package
236 (name "java-jbzip2")
237 (version "0.9.1")
238 (source (origin
239 (method url-fetch)
240 (uri (string-append "https://storage.googleapis.com/"
241 "google-code-archive-source/v2/"
242 "code.google.com/jbzip2/"
243 "source-archive.zip"))
244 (file-name (string-append name "-" version ".zip"))
245 (sha256
246 (base32
247 "0ncmhlqmrfmj96nqf6p77b9ws35lcfsvpfxzwxi2asissc83z1l3"))))
248 (build-system ant-build-system)
249 (native-inputs
250 `(("unzip" ,unzip)
251 ("java-junit" ,java-junit)))
252 (arguments
253 `(#:tests? #f ; no tests
254 #:jar-name "jbzip2.jar"
255 #:source-dir "tags/release-0.9.1/src"
256 #:phases
257 (modify-phases %standard-phases
258 (add-after 'unpack 'fix-encoding-problems
259 (lambda _
260 ;; Some of the files we're patching are
261 ;; ISO-8859-1-encoded, so choose it as the default
262 ;; encoding so the byte encoding is preserved.
263 (with-fluids ((%default-port-encoding #f))
264 (substitute* "tags/release-0.9.1/src/org/itadaki/bzip2/HuffmanAllocator.java"
265 (("Milidi.") "Milidiu")))
266 #t)))))
267 (home-page "https://code.google.com/archive/p/jbzip2/")
268 (synopsis "Java bzip2 compression/decompression library")
269 (description "Jbzip2 is a Java bzip2 compression/decompression library.
270 It can be used as a replacement for the Apache @code{CBZip2InputStream} /
271 @code{CBZip2OutputStream} classes.")
272 (license license:expat)))
273
274 (define-public java-tukaani-xz
275 (package
276 (name "java-tukaani-xz")
277 (version "1.6")
278 (source (origin
279 (method url-fetch)
280 (uri (string-append "https://tukaani.org/xz/xz-java-" version ".zip"))
281 (sha256
282 (base32
283 "1z3p1ri1gvl07inxn0agx44ck8n7wrzfmvkz8nbq3njn8r9wba8x"))))
284 (build-system ant-build-system)
285 (arguments
286 `(#:tests? #f; no tests
287 #:phases
288 (modify-phases %standard-phases
289 (add-after 'unpack 'chdir
290 (lambda _
291 ;; Our build system enters the first directory in the archive, but
292 ;; the package is not contained in a subdirectory
293 (chdir "..")
294 #t))
295 (replace 'install
296 (lambda* (#:key outputs #:allow-other-keys)
297 ;; Do we want to install *Demo.jar?
298 (install-file "build/jar/xz.jar"
299 (string-append
300 (assoc-ref outputs "out")
301 "/share/java/xz.jar"))
302 #t)))))
303 (native-inputs
304 `(("unzip" ,unzip)))
305 (home-page "https://tukaani.org")
306 (synopsis "XZ in Java")
307 (description "Tukaani-xz is an implementation of xz compression/decompression
308 algorithms in Java.")
309 (license license:public-domain)))