1 # Copyright 1999-2018 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 JAVA_PKG_BSFIX_NAME="build.xml build-unix.xml"
7 inherit autotools java-pkg-opt-2 java-ant-2
9 DESCRIPTION="A collection of file system and media management forensic analysis tools"
10 HOMEPAGE="https://www.sleuthkit.org/sleuthkit/"
11 # TODO: sqlite-jdbc does not exist in the tree, we bundle it for now
12 # TODO: Upstream uses a very specific version of libewf which is not in
13 # the tree anymore. So we statically compile and link to sleuthkit.
14 # Hopefully upstream will figure something out in the future.
15 SRC_URI="https://github.com/${PN}/${PN}/releases/download/${P}/${P}.tar.gz
16 java? ( http://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.8.11/sqlite-jdbc-3.8.11.jar )
17 ewf? ( https://dev.gentoo.org/~gokturk/distfiles/app-forensics/libewf/libewf-20130128.tar.gz )"
19 LICENSE="BSD CPL-1.0 GPL-2+ IBM java? ( Apache-2.0 )"
20 SLOT="0/13" # subslot = major soname version
21 KEYWORDS="~amd64 ~hppa ~ppc ~x86"
22 IUSE="aff doc ewf java static-libs test +threads zlib"
27 aff? ( app-forensics/afflib )
28 ewf? ( sys-libs/zlib )
31 >=dev-java/c3p0-0.9.5:0
32 >=dev-java/jdbc-postgresql-9.4:0
34 zlib? ( sys-libs/zlib )
37 java? ( >=virtual/jre-1.8:= )
40 doc? ( app-doc/doxygen )
41 test? ( >=dev-util/cppunit-1.2.1 )
45 "${FILESDIR}"/${PN}-4.1.0-tools-shared-libs.patch
53 # Ick, the upstream is stuck at libewf-20130128 which is
54 # not even in the tree anymore. So we have to bundle it.
56 pushd "${T}" &>/dev/null || die
57 unpack libewf-20130128.tar.gz
58 export TSK_LIBEWF_SRCDIR="${T}"/libewf-20130128
59 popd &>/dev/null || die
62 # Copy the jar files that don't exist in the tree yet
64 TSK_JAR_DIR="${S}/bindings/java/lib"
65 mkdir "${TSK_JAR_DIR}" || die
67 if [[ ${f} =~ .jar$ ]]; then
68 cp "${DISTDIR}"/"${f}" "${TSK_JAR_DIR}" || die
77 # Yeah, libewf-20130128 obviously doesn't just nicely compile
78 sed -e 's/LIBUNA_INLINE inline/LIBUNA_INLINE/' \
79 -i "${TSK_LIBEWF_SRCDIR}"/libuna/libuna_inline.h || die
83 pushd "${S}"/bindings/java &>/dev/null || die
85 # Prevent "make install" from installing
86 # jar files under /usr/share/java
87 # We'll use the java eclasses for this
88 sed -e '/^jar_DATA/ d;' -i Makefile.am || die
90 # Disable dependency retrieval using ivy
91 # We will handle it ourselves
92 sed -e '/name="compile"/ s/, retrieve-deps//' \
93 -e '/name="dist-/ s/, init-ivy//g' \
96 java-pkg-opt-2_src_prepare
98 popd &>/dev/null || die
101 # Override the doxygen output directories
103 sed -e "/^OUTPUT_DIRECTORY/ s|=.*$|= ${T}/doc|" \
104 -i tsk/docs/Doxyfile \
105 -i bindings/java/doxygen/Doxyfile || die
108 # It's safe to call this even after java-pkg-opt-2_src_prepare
109 # because future calls to eapply_user do nothing and return 0
115 tsk_compile_libewf() {
130 # We want to contain our build flags
131 local CFLAGS="${CFLAGS}"
132 local LDFLAGS="${LDFLAGS}"
134 pushd "${TSK_LIBEWF_SRCDIR}" &>/dev/null || die
136 # Produce relocatable code
139 econf "${myeconfargs[@]}"
141 # Do not waste CPU cycles on building ewftools
142 sed -e '/ewftools/ d' -i Makefile || die
145 # Only install the headers and the library
146 emake -C libewf DESTDIR="${T}"/image install
147 emake -C include DESTDIR="${T}"/image install
149 popd &>/dev/null || die
155 $(use_enable static-libs static)
156 $(use_enable threads multithreading)
157 $(use_with aff afflib)
158 $(use_with ewf libewf)
164 myeconfargs+=( $(use_with ewf libewf "${T}"/image) )
168 pushd "${S}"/bindings/java &>/dev/null || die
169 java-ant-2_src_configure
170 popd &>/dev/null || die
173 econf "${myeconfargs[@]}"
177 # Create symlinks of jars for the required dependencies
179 pushd "${S}"/bindings/java &>/dev/null || die
181 java-pkg_jar-from --into "${TSK_JAR_DIR}" c3p0
182 java-pkg_jar-from --into "${TSK_JAR_DIR}" jdbc-postgresql
184 popd &>/dev/null || die
187 # Create the doc output dirs if requested
189 mkdir -p "${T}"/doc/{api-docs,jni-docs} || die
192 emake all $(usex doc api-docs "")
199 pushd "${S}"/bindings/java &>/dev/null || die
201 java-pkg_dojar dist/${P}.jar
203 # Install the bundled jar files
204 pushd "${TSK_JAR_DIR}" &>/dev/null || die
206 # Skip the symlinks java-pkg_jar-from created
207 [[ -f ${f} ]] || continue
209 # Strip the version numbers as per eclass recommendation
210 [[ ${f} =~ -([0-9].)+.jar$ ]] || continue
212 java-pkg_newjar "${f}" "${f/${BASH_REMATCH[0]}/.jar}"
214 popd &>/dev/null || die
216 popd &>/dev/null || die
221 # It unconditionally builds both api and jni docs
222 # We install conditionally based on the provided use flags
224 dodoc -r "${T}"/doc/api-docs
225 use java && dodoc -r "${T}"/doc/jni-docs
228 find "${D}" -name '*.la' -delete || die