java-compression.scm 13 KB

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