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, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
9 ;;; This file is part of GNU Guix.
11 ;;; GNU Guix is free software; you can redistribute it and/or modify it
12 ;;; under the terms of the GNU General Public License as published by
13 ;;; the Free Software Foundation; either version 3 of the License, or (at
14 ;;; your option) any later version.
16 ;;; GNU Guix is distributed in the hope that it will be useful, but
17 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;;; GNU General Public License for more details.
21 ;;; You should have received a copy of the GNU General Public License
22 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24 (define-module (gnu packages java-compression)
25 #:use-module ((guix licenses) #:prefix license:)
26 #:use-module (guix utils)
27 #:use-module (guix packages)
28 #:use-module (guix download)
29 #:use-module (guix git-download)
30 #:use-module (guix build-system ant)
31 #:use-module (gnu packages)
32 #:use-module (gnu packages compression)
33 #:use-module (gnu packages java)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages python-compression))
37 (define-public java-snappy
45 (url "https://github.com/xerial/snappy-java")
48 (base32 "0894zyasrmbi268d1ky9db16wrnc6x8b9ilq0b5paaxi2pwgjlrp"))
49 (file-name (git-file-name name version))))
50 (build-system ant-build-system)
52 `(#:jar-name "snappy.jar"
53 #:source-dir "src/main/java"
55 (modify-phases %standard-phases
56 (add-after 'unpack 'make-git-checkout-writable
58 (for-each make-file-writable (find-files "."))
60 (add-before 'build 'remove-binaries
62 (delete-file "lib/org/xerial/snappy/OSInfo.class")
63 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
65 (add-before 'build 'build-jni
67 ;; Rebuild one of the binaries we removed earlier
68 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
70 ;; Link to the dynamic bitshuffle and snappy, not the static ones
71 (substitute* "Makefile.common"
73 "-shared -lbitshuffle -lsnappy"))
74 (substitute* "Makefile"
75 ;; Don't try to use git, don't download bitshuffle source
76 ;; and don't build it.
77 (("\\$\\(SNAPPY_GIT_UNPACKED\\) ")
79 ((": \\$\\(SNAPPY_GIT_UNPACKED\\)")
81 (("\\$\\(BITSHUFFLE_UNPACKED\\) ")
83 ((": \\$\\(SNAPPY_SOURCE_CONFIGURED\\)") ":")
84 ;; What we actually want to build
86 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, \
87 SnappyNative.o BitShuffleNative.o)\n")
88 ;; Since we removed the directory structure in "native" during
89 ;; the previous phase, we need to recreate it.
90 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
91 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
92 ;; Finally we can run the Makefile to build the dynamic library.
93 ;; Use the -nocmake target to avoid a dependency on cmake,
94 ;; which in turn requires the "git_unpacked" directory.
95 (invoke "make" "native-nocmake")))
96 ;; Once we have built the shared library, we need to place it in the
97 ;; "build" directory so it can be added to the jar file.
98 (add-after 'build-jni 'copy-jni
100 (copy-recursively "src/main/resources/org/xerial/snappy/native"
101 "build/classes/org/xerial/snappy/native")
103 (add-before 'build 'set-test-memory-size
105 (substitute* "build.xml"
106 (("<junit printsummary=") "<junit maxmemory=\"2G\" printsummary="))
108 (add-before 'check 'fix-failing
110 (with-directory-excursion "src/test/java/org/xerial/snappy"
111 ;; This package assumes maven build, which puts results in "target".
112 ;; We put them in "build" instead, so fix that.
113 (substitute* "SnappyLoaderTest.java"
114 (("target/classes") "build/classes"))
115 ;; This requires Hadoop, which is not in Guix yet.
116 (delete-file "SnappyHadoopCompatibleOutputStreamTest.java"))
119 `(("osgi-framework" ,java-osgi-framework)))
121 `(("bitshuffle" ,bitshuffle-for-snappy)
124 `(("junit" ,java-junit)
125 ("hamcrest" ,java-hamcrest-core)
126 ("xerial-core" ,java-xerial-core)
127 ("classworlds" ,java-plexus-classworlds)
128 ("commons-lang" ,java-commons-lang)
129 ("commons-io" ,java-commons-io)
131 (home-page "https://github.com/xerial/snappy-java")
132 (synopsis "Compression/decompression algorithm in Java")
133 (description "Snappy-java is a Java port of snappy, a fast C++
134 compressor/decompressor.")
135 (license license:asl2.0)))
137 (define-public java-snappy-1
139 (inherit java-snappy)
141 (version "1.0.3-rc3")
146 (url (string-append "https://github.com/xerial/snappy-java"))
147 (commit (string-append "snappy-java-" version))))
149 (base32 "0gbg3xmhniyh5p6w5zqj16fr15fa8j4raswd8pj00l4ixf5qa6m4"))
150 (file-name (git-file-name name version))))
152 `(#:jar-name "snappy.jar"
153 #:source-dir "src/main/java"
155 (modify-phases %standard-phases
156 (add-before 'build 'remove-binaries
158 (delete-file "lib/org/xerial/snappy/OSInfo.class")
159 (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
161 (add-before 'build 'build-jni
163 ;; Rebuild one of the binaries we removed earlier
164 (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
166 ;; Link to the dynamic snappy, not the static ones
167 (substitute* "Makefile.common"
168 (("-shared") "-shared -lsnappy"))
169 (substitute* "Makefile"
170 ;; Don't download the sources here.
171 (("\\$\\(SNAPPY_UNPACKED\\) ") "")
172 ((": \\$\\(SNAPPY_UNPACKED\\) ") ":")
173 ;; What we actually want to build
175 "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, SnappyNative.o)\n")
176 ;; Since we removed the directory structure in "native" during
177 ;; the previous phase, we need to recreate it.
178 (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
179 "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
180 ;; Finally we can run the Makefile to build the dynamic library.
181 (invoke "make" "native")))
182 ;; Once we have built the shared library, we need to place it in the
183 ;; "build" directory so it can be added to the jar file.
184 (add-after 'build-jni 'copy-jni
186 (copy-recursively "src/main/resources/org/xerial/snappy/native"
187 "build/classes/org/xerial/snappy/native")
189 (add-before 'check 'fix-tests
191 (mkdir-p "src/test/resources/org/xerial/snappy/")
192 (copy-recursively "src/test/java/org/xerial/snappy/testdata"
193 "src/test/resources/org/xerial/snappy/testdata")
194 (install-file "src/test/java/org/xerial/snappy/alice29.txt"
195 "src/test/resources/org/xerial/snappy/")
198 (define-public java-iq80-snappy
200 (name "java-iq80-snappy")
206 (url "https://github.com/dain/snappy")
207 (commit (string-append "snappy-" version))))
209 (base32 "1mswh207065rdzbxk6rxaqlxhbg1ngxa0vjc20knsn31kqbq1bcz"))
210 (file-name (git-file-name name version))))
211 (build-system ant-build-system)
213 `(#:jar-name "iq80-snappy.jar"
214 #:source-dir "src/main/java"
215 #:test-dir "src/test"
217 (modify-phases %standard-phases
221 (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
223 ":build/test-classes")
224 "-Dtest.resources.dir=src/test/resources"
225 "org.testng.TestNG" "-testclass"
227 (invoke "ant" "compile-tests")
228 (test "org.iq80.snappy.SnappyFramedStreamTest")
229 (test "org.iq80.snappy.SnappyStreamTest")
231 (add-before 'build 'remove-hadoop-dependency
233 ;; We don't have hadoop
234 (delete-file "src/main/java/org/iq80/snappy/HadoopSnappyCodec.java")
235 (delete-file "src/test/java/org/iq80/snappy/TestHadoopSnappyCodec.java")
237 (replace 'install (install-from-pom "pom.xml")))))
238 (home-page "https://github.com/dain/snappy")
240 (list java-guava java-snappy java-testng))
241 (synopsis "Java port of the Snappy (de)compressor")
243 "Iq80-snappy is a port of the Snappy compressor and decompressor rewritten
244 in pure Java. This compression code produces a byte-for-byte exact copy of the
245 output created by the original C++ code, and is extremely fast.")
246 (license license:asl2.0)))
248 (define-public java-jbzip2
254 (uri (string-append "https://storage.googleapis.com/"
255 "google-code-archive-source/v2/"
256 "code.google.com/jbzip2/"
257 "source-archive.zip"))
258 (file-name (string-append name "-" version ".zip"))
261 "0ncmhlqmrfmj96nqf6p77b9ws35lcfsvpfxzwxi2asissc83z1l3"))))
262 (build-system ant-build-system)
264 (list unzip java-junit))
266 `(#:tests? #f ; no tests
267 #:jar-name "jbzip2.jar"
268 #:source-dir "tags/release-0.9.1/src"
270 (modify-phases %standard-phases
271 (add-after 'unpack 'fix-encoding-problems
273 ;; Some of the files we're patching are
274 ;; ISO-8859-1-encoded, so choose it as the default
275 ;; encoding so the byte encoding is preserved.
276 (with-fluids ((%default-port-encoding #f))
277 (substitute* "tags/release-0.9.1/src/org/itadaki/bzip2/HuffmanAllocator.java"
278 (("Milidi.") "Milidiu")))
280 (home-page "https://code.google.com/archive/p/jbzip2/")
281 (synopsis "Java bzip2 compression/decompression library")
282 (description "Jbzip2 is a Java bzip2 compression/decompression library.
283 It can be used as a replacement for the Apache @code{CBZip2InputStream} /
284 @code{CBZip2OutputStream} classes.")
285 (license license:expat)))
287 (define-public java-xz
292 (method url-fetch/zipbomb)
293 (uri (string-append "https://tukaani.org/xz/xz-java-" version ".zip"))
296 "007d9f83277qn70swz9inqhyf0qxq6ygajpq5rqg0xgsyh1sdndi"))))
297 (build-system ant-build-system)
299 `(#:tests? #f; no tests
302 (modify-phases %standard-phases
303 (add-before 'install 'generate-pom
305 (copy-file "maven/pom_template.xml" "pom.xml")
306 (substitute* "pom.xml"
307 (("@VERSION@") ,version)
308 (("@TITLE@") "XZ data compression")
309 (("@HOMEPAGE@") "http://tukaani.org/xz/java.html"))
311 (add-before 'install 'rename-jar
313 (rename-file "build/jar/xz.jar"
314 (string-append "build/jar/xz-" ,version ".jar"))
317 (install-from-pom "pom.xml")))))
320 (home-page "https://tukaani.org")
321 (synopsis "XZ in Java")
322 (description "Tukaani-xz is an implementation of xz compression/decompression
323 algorithms in Java.")
324 (license license:public-domain)))