Commit | Line | Data |
---|---|---|
24155bf4 RW |
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> | |
ca0fe294 | 6 | ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr> |
24155bf4 RW |
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) | |
0308944a | 28 | #:use-module (guix git-download) |
24155bf4 RW |
29 | #:use-module (guix build-system ant) |
30 | #:use-module (gnu packages) | |
31 | #:use-module (gnu packages compression) | |
32 | #:use-module (gnu packages java) | |
4fec042b RW |
33 | #:use-module (gnu packages perl) |
34 | #:use-module (gnu packages python-compression)) | |
24155bf4 RW |
35 | |
36 | (define-public java-snappy | |
37 | (package | |
38 | (name "java-snappy") | |
affae324 | 39 | (version "1.1.7.5") |
0308944a TGR |
40 | (source |
41 | (origin | |
42 | (method git-fetch) | |
43 | (uri (git-reference | |
44 | (url "https://github.com/xerial/snappy-java") | |
45 | (commit version))) | |
46 | (sha256 | |
affae324 | 47 | (base32 "0894zyasrmbi268d1ky9db16wrnc6x8b9ilq0b5paaxi2pwgjlrp")) |
0308944a | 48 | (file-name (git-file-name name version)))) |
24155bf4 RW |
49 | (build-system ant-build-system) |
50 | (arguments | |
51 | `(#:jar-name "snappy.jar" | |
52 | #:source-dir "src/main/java" | |
53 | #:phases | |
54 | (modify-phases %standard-phases | |
0308944a TGR |
55 | (add-after 'unpack 'make-git-checkout-writable |
56 | (lambda _ | |
57 | (for-each make-file-writable (find-files ".")) | |
58 | #t)) | |
24155bf4 RW |
59 | (add-before 'build 'remove-binaries |
60 | (lambda _ | |
61 | (delete-file "lib/org/xerial/snappy/OSInfo.class") | |
62 | (delete-file-recursively "src/main/resources/org/xerial/snappy/native") | |
63 | #t)) | |
64 | (add-before 'build 'build-jni | |
65 | (lambda _ | |
66 | ;; Rebuild one of the binaries we removed earlier | |
67 | (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java" | |
68 | "-d" "lib") | |
69 | ;; Link to the dynamic bitshuffle and snappy, not the static ones | |
70 | (substitute* "Makefile.common" | |
71 | (("-shared") | |
72 | "-shared -lbitshuffle -lsnappy")) | |
73 | (substitute* "Makefile" | |
74 | ;; Don't try to use git, don't download bitshuffle source | |
75 | ;; and don't build it. | |
76 | (("\\$\\(SNAPPY_GIT_UNPACKED\\) ") | |
77 | "") | |
78 | ((": \\$\\(SNAPPY_GIT_UNPACKED\\)") | |
79 | ":") | |
80 | (("\\$\\(BITSHUFFLE_UNPACKED\\) ") | |
81 | "") | |
82 | ((": \\$\\(SNAPPY_SOURCE_CONFIGURED\\)") ":") | |
83 | ;; What we actually want to build | |
84 | (("SNAPPY_OBJ:=.*") | |
85 | "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, \ | |
86 | SnappyNative.o BitShuffleNative.o)\n") | |
87 | ;; Since we removed the directory structure in "native" during | |
88 | ;; the previous phase, we need to recreate it. | |
89 | (("NAME\\): \\$\\(SNAPPY_OBJ\\)") | |
90 | "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)")) | |
91 | ;; Finally we can run the Makefile to build the dynamic library. | |
92 | ;; Use the -nocmake target to avoid a dependency on cmake, | |
93 | ;; which in turn requires the "git_unpacked" directory. | |
94 | (invoke "make" "native-nocmake"))) | |
95 | ;; Once we have built the shared library, we need to place it in the | |
96 | ;; "build" directory so it can be added to the jar file. | |
97 | (add-after 'build-jni 'copy-jni | |
98 | (lambda _ | |
99 | (copy-recursively "src/main/resources/org/xerial/snappy/native" | |
100 | "build/classes/org/xerial/snappy/native") | |
101 | #t)) | |
23dcf433 BH |
102 | (add-before 'build 'set-test-memory-size |
103 | (lambda _ | |
104 | (substitute* "build.xml" | |
105 | (("<junit printsummary=") "<junit maxmemory=\"2G\" printsummary=")) | |
106 | #t)) | |
24155bf4 RW |
107 | (add-before 'check 'fix-failing |
108 | (lambda _ | |
109 | (with-directory-excursion "src/test/java/org/xerial/snappy" | |
110 | ;; This package assumes maven build, which puts results in "target". | |
111 | ;; We put them in "build" instead, so fix that. | |
112 | (substitute* "SnappyLoaderTest.java" | |
113 | (("target/classes") "build/classes")) | |
114 | ;; This requires Hadoop, which is not in Guix yet. | |
115 | (delete-file "SnappyHadoopCompatibleOutputStreamTest.java")) | |
116 | #t))))) | |
117 | (inputs | |
118 | `(("osgi-framework" ,java-osgi-framework))) | |
119 | (propagated-inputs | |
120 | `(("bitshuffle" ,bitshuffle-for-snappy) | |
121 | ("snappy" ,snappy))) | |
122 | (native-inputs | |
123 | `(("junit" ,java-junit) | |
124 | ("hamcrest" ,java-hamcrest-core) | |
125 | ("xerial-core" ,java-xerial-core) | |
126 | ("classworlds" ,java-plexus-classworlds) | |
127 | ("commons-lang" ,java-commons-lang) | |
128 | ("commons-io" ,java-commons-io) | |
129 | ("perl" ,perl))) | |
130 | (home-page "https://github.com/xerial/snappy-java") | |
131 | (synopsis "Compression/decompression algorithm in Java") | |
132 | (description "Snappy-java is a Java port of snappy, a fast C++ | |
133 | compressor/decompressor.") | |
134 | (license license:asl2.0))) | |
135 | ||
136 | (define-public java-snappy-1 | |
137 | (package | |
138 | (inherit java-snappy) | |
e2528a3c | 139 | (name "java-snappy") |
24155bf4 | 140 | (version "1.0.3-rc3") |
e2528a3c TGR |
141 | (source |
142 | (origin | |
143 | (method git-fetch) | |
144 | (uri (git-reference | |
145 | (url (string-append "https://github.com/xerial/snappy-java")) | |
146 | (commit (string-append "snappy-java-" version)))) | |
147 | (sha256 | |
148 | (base32 "0gbg3xmhniyh5p6w5zqj16fr15fa8j4raswd8pj00l4ixf5qa6m4")) | |
149 | (file-name (git-file-name name version)))) | |
24155bf4 RW |
150 | (arguments |
151 | `(#:jar-name "snappy.jar" | |
152 | #:source-dir "src/main/java" | |
153 | #:phases | |
154 | (modify-phases %standard-phases | |
155 | (add-before 'build 'remove-binaries | |
156 | (lambda _ | |
157 | (delete-file "lib/org/xerial/snappy/OSInfo.class") | |
158 | (delete-file-recursively "src/main/resources/org/xerial/snappy/native") | |
159 | #t)) | |
160 | (add-before 'build 'build-jni | |
161 | (lambda _ | |
162 | ;; Rebuild one of the binaries we removed earlier | |
163 | (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java" | |
164 | "-d" "lib") | |
165 | ;; Link to the dynamic snappy, not the static ones | |
166 | (substitute* "Makefile.common" | |
167 | (("-shared") "-shared -lsnappy")) | |
168 | (substitute* "Makefile" | |
169 | ;; Don't download the sources here. | |
170 | (("\\$\\(SNAPPY_UNPACKED\\) ") "") | |
171 | ((": \\$\\(SNAPPY_UNPACKED\\) ") ":") | |
172 | ;; What we actually want to build | |
173 | (("SNAPPY_OBJ:=.*") | |
174 | "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, SnappyNative.o)\n") | |
175 | ;; Since we removed the directory structure in "native" during | |
176 | ;; the previous phase, we need to recreate it. | |
177 | (("NAME\\): \\$\\(SNAPPY_OBJ\\)") | |
178 | "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)")) | |
179 | ;; Finally we can run the Makefile to build the dynamic library. | |
180 | (invoke "make" "native"))) | |
181 | ;; Once we have built the shared library, we need to place it in the | |
182 | ;; "build" directory so it can be added to the jar file. | |
183 | (add-after 'build-jni 'copy-jni | |
184 | (lambda _ | |
185 | (copy-recursively "src/main/resources/org/xerial/snappy/native" | |
186 | "build/classes/org/xerial/snappy/native") | |
187 | #t)) | |
188 | (add-before 'check 'fix-tests | |
189 | (lambda _ | |
190 | (mkdir-p "src/test/resources/org/xerial/snappy/") | |
191 | (copy-recursively "src/test/java/org/xerial/snappy/testdata" | |
192 | "src/test/resources/org/xerial/snappy/testdata") | |
193 | (install-file "src/test/java/org/xerial/snappy/alice29.txt" | |
194 | "src/test/resources/org/xerial/snappy/") | |
195 | #t))))))) | |
196 | ||
197 | (define-public java-iq80-snappy | |
198 | (package | |
199 | (name "java-iq80-snappy") | |
200 | (version "0.4") | |
287e3d31 TGR |
201 | (source |
202 | (origin | |
203 | (method git-fetch) | |
204 | (uri (git-reference | |
205 | (url "https://github.com/dain/snappy") | |
206 | (commit (string-append "snappy-" version)))) | |
207 | (sha256 | |
208 | (base32 "1mswh207065rdzbxk6rxaqlxhbg1ngxa0vjc20knsn31kqbq1bcz")) | |
209 | (file-name (git-file-name name version)))) | |
24155bf4 RW |
210 | (build-system ant-build-system) |
211 | (arguments | |
212 | `(#:jar-name "iq80-snappy.jar" | |
213 | #:source-dir "src/main/java" | |
214 | #:test-dir "src/test" | |
24155bf4 RW |
215 | #:phases |
216 | (modify-phases %standard-phases | |
217 | (replace 'check | |
218 | (lambda _ | |
219 | (define (test class) | |
220 | (invoke "java" "-cp" (string-append (getenv "CLASSPATH") | |
221 | ":build/classes" | |
222 | ":build/test-classes") | |
223 | "-Dtest.resources.dir=src/test/resources" | |
224 | "org.testng.TestNG" "-testclass" | |
225 | class)) | |
226 | (invoke "ant" "compile-tests") | |
227 | (test "org.iq80.snappy.SnappyFramedStreamTest") | |
228 | (test "org.iq80.snappy.SnappyStreamTest") | |
229 | #t)) | |
230 | (add-before 'build 'remove-hadoop-dependency | |
231 | (lambda _ | |
232 | ;; We don't have hadoop | |
233 | (delete-file "src/main/java/org/iq80/snappy/HadoopSnappyCodec.java") | |
234 | (delete-file "src/test/java/org/iq80/snappy/TestHadoopSnappyCodec.java") | |
02ed96dc JL |
235 | #t)) |
236 | (replace 'install (install-from-pom "pom.xml"))))) | |
24155bf4 RW |
237 | (home-page "https://github.com/dain/snappy") |
238 | (native-inputs | |
51087d51 | 239 | `(("java-guava" ,java-guava) |
24155bf4 | 240 | ("java-snappy" ,java-snappy) |
51087d51 | 241 | ("java-testng" ,java-testng))) |
24155bf4 RW |
242 | (synopsis "Java port of the Snappy (de)compressor") |
243 | (description | |
244 | "Iq80-snappy is a port of the Snappy compressor and decompressor rewritten | |
245 | in pure Java. This compression code produces a byte-for-byte exact copy of the | |
246 | output created by the original C++ code, and is extremely fast.") | |
247 | (license license:asl2.0))) | |
248 | ||
249 | (define-public java-jbzip2 | |
250 | (package | |
251 | (name "java-jbzip2") | |
252 | (version "0.9.1") | |
253 | (source (origin | |
254 | (method url-fetch) | |
255 | (uri (string-append "https://storage.googleapis.com/" | |
256 | "google-code-archive-source/v2/" | |
257 | "code.google.com/jbzip2/" | |
258 | "source-archive.zip")) | |
259 | (file-name (string-append name "-" version ".zip")) | |
260 | (sha256 | |
261 | (base32 | |
262 | "0ncmhlqmrfmj96nqf6p77b9ws35lcfsvpfxzwxi2asissc83z1l3")))) | |
263 | (build-system ant-build-system) | |
264 | (native-inputs | |
265 | `(("unzip" ,unzip) | |
266 | ("java-junit" ,java-junit))) | |
267 | (arguments | |
268 | `(#:tests? #f ; no tests | |
269 | #:jar-name "jbzip2.jar" | |
270 | #:source-dir "tags/release-0.9.1/src" | |
271 | #:phases | |
272 | (modify-phases %standard-phases | |
273 | (add-after 'unpack 'fix-encoding-problems | |
274 | (lambda _ | |
275 | ;; Some of the files we're patching are | |
276 | ;; ISO-8859-1-encoded, so choose it as the default | |
277 | ;; encoding so the byte encoding is preserved. | |
278 | (with-fluids ((%default-port-encoding #f)) | |
279 | (substitute* "tags/release-0.9.1/src/org/itadaki/bzip2/HuffmanAllocator.java" | |
280 | (("Milidi.") "Milidiu"))) | |
281 | #t))))) | |
282 | (home-page "https://code.google.com/archive/p/jbzip2/") | |
283 | (synopsis "Java bzip2 compression/decompression library") | |
284 | (description "Jbzip2 is a Java bzip2 compression/decompression library. | |
285 | It can be used as a replacement for the Apache @code{CBZip2InputStream} / | |
286 | @code{CBZip2OutputStream} classes.") | |
287 | (license license:expat))) | |
288 | ||
d308bc01 | 289 | (define-public java-xz |
24155bf4 | 290 | (package |
d308bc01 | 291 | (name "java-xz") |
24155bf4 RW |
292 | (version "1.6") |
293 | (source (origin | |
294 | (method url-fetch) | |
295 | (uri (string-append "https://tukaani.org/xz/xz-java-" version ".zip")) | |
296 | (sha256 | |
297 | (base32 | |
298 | "1z3p1ri1gvl07inxn0agx44ck8n7wrzfmvkz8nbq3njn8r9wba8x")))) | |
299 | (build-system ant-build-system) | |
300 | (arguments | |
301 | `(#:tests? #f; no tests | |
302 | #:phases | |
303 | (modify-phases %standard-phases | |
304 | (add-after 'unpack 'chdir | |
305 | (lambda _ | |
306 | ;; Our build system enters the first directory in the archive, but | |
307 | ;; the package is not contained in a subdirectory | |
308 | (chdir "..") | |
309 | #t)) | |
02ed96dc JL |
310 | (add-before 'install 'generate-pom |
311 | (lambda _ | |
312 | (copy-file "maven/pom_template.xml" "pom.xml") | |
313 | (substitute* "pom.xml" | |
314 | (("@VERSION@") ,version) | |
315 | (("@TITLE@") "XZ data compression") | |
316 | (("@HOMEPAGE@") "http://tukaani.org/xz/java.html")) | |
317 | #t)) | |
318 | (add-before 'install 'rename-jar | |
319 | (lambda _ | |
320 | (rename-file "build/jar/xz.jar" | |
321 | (string-append "build/jar/xz-" ,version ".jar")) | |
322 | #t)) | |
323 | (replace 'install | |
324 | (install-from-pom "pom.xml"))))) | |
24155bf4 RW |
325 | (native-inputs |
326 | `(("unzip" ,unzip))) | |
327 | (home-page "https://tukaani.org") | |
328 | (synopsis "XZ in Java") | |
329 | (description "Tukaani-xz is an implementation of xz compression/decompression | |
330 | algorithms in Java.") | |
331 | (license license:public-domain))) |