java-compression.scm 14 KB

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