-(define bitshuffle-for-snappy
- (package
- (inherit bitshuffle)
- (name "bitshuffle-for-snappy")
- (build-system gnu-build-system)
- (arguments
- `(#:tests? #f
- #:phases
- (modify-phases %standard-phases
- (replace 'configure
- (lambda* (#:key outputs #:allow-other-keys)
- (with-output-to-file "Makefile"
- (lambda _
- (format #t "\
-libbitshuffle.so: src/bitshuffle.o src/bitshuffle_core.o src/iochain.o lz4/lz4.o
-\tgcc -O3 -ffast-math -std=c99 -o $@ -shared -fPIC $^
-
-%.o: %.c
-\tgcc -O3 -ffast-math -std=c99 -fPIC -Isrc -Ilz4 -c $< -o $@
-
-PREFIX:=~a
-LIBDIR:=$(PREFIX)/lib
-INCLUDEDIR:=$(PREFIX)/include
-
-install: libbitshuffle.so
-\tinstall -dm755 $(LIBDIR)
-\tinstall -dm755 $(INCLUDEDIR)
-\tinstall -m755 libbitshuffle.so $(LIBDIR)
-\tinstall -m644 src/bitshuffle.h $(INCLUDEDIR)
-\tinstall -m644 src/bitshuffle_core.h $(INCLUDEDIR)
-\tinstall -m644 src/iochain.h $(INCLUDEDIR)
-\tinstall -m644 lz4/lz4.h $(INCLUDEDIR)
-" (assoc-ref outputs "out"))))
- #t)))))
- (inputs '())
- (native-inputs '())))
-
-(define-public java-snappy
- (package
- (name "java-snappy")
- (version "1.1.7.2")
- (source (origin
- (method url-fetch)
- (uri (string-append "https://github.com/xerial/snappy-java/archive/"
- version ".tar.gz"))
- (file-name (string-append name "-" version ".tar.gz"))
- (sha256
- (base32
- "1p557vdv006ysgxbpp83krmq0066k46108vyiyka69w8i4i8rbbm"))))
- (build-system ant-build-system)
- (arguments
- `(#:jar-name "snappy.jar"
- #:source-dir "src/main/java"
- #:phases
- (modify-phases %standard-phases
- (add-before 'build 'remove-binaries
- (lambda _
- (delete-file "lib/org/xerial/snappy/OSInfo.class")
- (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
- #t))
- (add-before 'build 'build-jni
- (lambda _
- ;; Rebuild one of the binaries we removed earlier
- (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
- "-d" "lib")
- ;; Link to the dynamic bitshuffle and snappy, not the static ones
- (substitute* "Makefile.common"
- (("-shared")
- "-shared -lbitshuffle -lsnappy"))
- (substitute* "Makefile"
- ;; Don't try to use git, don't download bitshuffle source
- ;; and don't build it.
- (("\\$\\(SNAPPY_GIT_UNPACKED\\) ")
- "")
- ((": \\$\\(SNAPPY_GIT_UNPACKED\\)")
- ":")
- (("\\$\\(BITSHUFFLE_UNPACKED\\) ")
- "")
- ((": \\$\\(SNAPPY_SOURCE_CONFIGURED\\)") ":")
- ;; What we actually want to build
- (("SNAPPY_OBJ:=.*")
- "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, \
- SnappyNative.o BitShuffleNative.o)\n")
- ;; Since we removed the directory structure in "native" during
- ;; the previous phase, we need to recreate it.
- (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
- "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
- ;; Finally we can run the Makefile to build the dynamic library.
- ;; Use the -nocmake target to avoid a dependency on cmake,
- ;; which in turn requires the "git_unpacked" directory.
- (invoke "make" "native-nocmake")))
- ;; Once we have built the shared library, we need to place it in the
- ;; "build" directory so it can be added to the jar file.
- (add-after 'build-jni 'copy-jni
- (lambda _
- (copy-recursively "src/main/resources/org/xerial/snappy/native"
- "build/classes/org/xerial/snappy/native")))
- (add-before 'check 'fix-failing
- (lambda _
- (with-directory-excursion "src/test/java/org/xerial/snappy"
- ;; This package assumes maven build, which puts results in "target".
- ;; We put them in "build" instead, so fix that.
- (substitute* "SnappyLoaderTest.java"
- (("target/classes") "build/classes"))
- ;; This requires Hadoop, which is not in Guix yet.
- (delete-file "SnappyHadoopCompatibleOutputStreamTest.java"))
- #t)))))
- (inputs
- `(("osgi-framework" ,java-osgi-framework)))
- (propagated-inputs
- `(("bitshuffle" ,bitshuffle-for-snappy)
- ("snappy" ,snappy)))
- (native-inputs
- `(("junit" ,java-junit)
- ("hamcrest" ,java-hamcrest-core)
- ("xerial-core" ,java-xerial-core)
- ("classworlds" ,java-plexus-classworlds)
- ("commons-lang" ,java-commons-lang)
- ("commons-io" ,java-commons-io)
- ("perl" ,perl)))
- (home-page "https://github.com/xerial/snappy-java")
- (synopsis "Compression/decompression algorithm in Java")
- (description "Snappy-java is a Java port of snappy, a fast C++
-compressor/decompressor.")
- (license license:asl2.0)))
-
-(define-public java-snappy-1
- (package
- (inherit java-snappy)
- (version "1.0.3-rc3")
- (source (origin
- (method url-fetch)
- (uri (string-append "https://github.com/xerial/snappy-java/archive/"
- "snappy-java-" version ".tar.gz"))
- (sha256
- (base32
- "08hsxlqidiqck0q57fshwyv3ynyxy18vmhrai9fyc8mz17m7gsa3"))))
- (arguments
- `(#:jar-name "snappy.jar"
- #:source-dir "src/main/java"
- #:phases
- (modify-phases %standard-phases
- (add-before 'build 'remove-binaries
- (lambda _
- (delete-file "lib/org/xerial/snappy/OSInfo.class")
- (delete-file-recursively "src/main/resources/org/xerial/snappy/native")
- #t))
- (add-before 'build 'build-jni
- (lambda _
- ;; Rebuild one of the binaries we removed earlier
- (invoke "javac" "src/main/java/org/xerial/snappy/OSInfo.java"
- "-d" "lib")
- ;; Link to the dynamic snappy, not the static ones
- (substitute* "Makefile.common"
- (("-shared") "-shared -lsnappy"))
- (substitute* "Makefile"
- ;; Don't download the sources here.
- (("\\$\\(SNAPPY_UNPACKED\\) ") "")
- ((": \\$\\(SNAPPY_UNPACKED\\) ") ":")
- ;; What we actually want to build
- (("SNAPPY_OBJ:=.*")
- "SNAPPY_OBJ:=$(addprefix $(SNAPPY_OUT)/, SnappyNative.o)\n")
- ;; Since we removed the directory structure in "native" during
- ;; the previous phase, we need to recreate it.
- (("NAME\\): \\$\\(SNAPPY_OBJ\\)")
- "NAME): $(SNAPPY_OBJ)\n\t@mkdir -p $(@D)"))
- ;; Finally we can run the Makefile to build the dynamic library.
- (invoke "make" "native")))
- ;; Once we have built the shared library, we need to place it in the
- ;; "build" directory so it can be added to the jar file.
- (add-after 'build-jni 'copy-jni
- (lambda _
- (copy-recursively "src/main/resources/org/xerial/snappy/native"
- "build/classes/org/xerial/snappy/native")
- #t))
- (add-before 'check 'fix-tests
- (lambda _
- (mkdir-p "src/test/resources/org/xerial/snappy/")
- (copy-recursively "src/test/java/org/xerial/snappy/testdata"
- "src/test/resources/org/xerial/snappy/testdata")
- (install-file "src/test/java/org/xerial/snappy/alice29.txt"
- "src/test/resources/org/xerial/snappy/")
- #t)))))))
-
-(define-public java-iq80-snappy
- (package
- (name "java-iq80-snappy")
- (version "0.4")
- (source (origin
- (method url-fetch)
- (uri (string-append "https://github.com/dain/snappy/archive/snappy-"
- version ".tar.gz"))
- (sha256
- (base32
- "0rb3zhci7w9wzd65lfnk7p3ip0n6gb58a9qpx8n7r0231gahyamf"))))
- (build-system ant-build-system)
- (arguments
- `(#:jar-name "iq80-snappy.jar"
- #:source-dir "src/main/java"
- #:test-dir "src/test"
- #:jdk ,icedtea-8
- #:phases
- (modify-phases %standard-phases
- (replace 'check
- (lambda _
- (define (test class)
- (invoke "java" "-cp" (string-append (getenv "CLASSPATH")
- ":build/classes"
- ":build/test-classes")
- "-Dtest.resources.dir=src/test/resources"
- "org.testng.TestNG" "-testclass"
- class))
- (invoke "ant" "compile-tests")
- (test "org.iq80.snappy.SnappyFramedStreamTest")
- (test "org.iq80.snappy.SnappyStreamTest")))
- (add-before 'build 'remove-hadoop-dependency
- (lambda _
- ;; We don't have hadoop
- (delete-file "src/main/java/org/iq80/snappy/HadoopSnappyCodec.java")
- (delete-file "src/test/java/org/iq80/snappy/TestHadoopSnappyCodec.java")
- #t)))))
- (home-page "https://github.com/dain/snappy")
- (native-inputs
- `(("guava" ,java-guava)
- ("java-snappy" ,java-snappy)
- ("hamcrest" ,java-hamcrest-core)
- ("testng" ,java-testng)))
- (synopsis "Java port of the Snappy (de)compressor")
- (description
- "Iq80-snappy is a port of the Snappy compressor and decompressor rewritten
-in pure Java. This compression code produces a byte-for-byte exact copy of the
-output created by the original C++ code, and is extremely fast.")
- (license license:asl2.0)))
-
-(define-public java-jbzip2
- (package
- (name "java-jbzip2")
- (version "0.9.1")
- (source (origin
- (method url-fetch)
- (uri (string-append "https://storage.googleapis.com/"
- "google-code-archive-source/v2/"
- "code.google.com/jbzip2/"
- "source-archive.zip"))
- (file-name (string-append name "-" version ".zip"))
- (sha256
- (base32
- "0ncmhlqmrfmj96nqf6p77b9ws35lcfsvpfxzwxi2asissc83z1l3"))))
- (build-system ant-build-system)
- (native-inputs
- `(("unzip" ,unzip)
- ("java-junit" ,java-junit)))
- (arguments
- `(#:tests? #f ; no tests
- #:jar-name "jbzip2.jar"
- #:source-dir "tags/release-0.9.1/src"
- #:phases
- (modify-phases %standard-phases
- (add-after 'unpack 'fix-encoding-problems
- (lambda _
- ;; Some of the files we're patching are
- ;; ISO-8859-1-encoded, so choose it as the default
- ;; encoding so the byte encoding is preserved.
- (with-fluids ((%default-port-encoding #f))
- (substitute* "tags/release-0.9.1/src/org/itadaki/bzip2/HuffmanAllocator.java"
- (("Milidi.") "Milidiu")))
- #t)))))
- (home-page "https://code.google.com/archive/p/jbzip2/")
- (synopsis "Java bzip2 compression/decompression library")
- (description "Jbzip2 is a Java bzip2 compression/decompression library.
-It can be used as a replacement for the Apache @code{CBZip2InputStream} /
-@code{CBZip2OutputStream} classes.")
- (license license:expat)))
-