1 # Copyright 1999-2019 Gentoo Authors
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
17 http://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.25.2/sqlite-jdbc-3.25.2.jar
18 http://repo1.maven.org/maven2/com/zaxxer/SparseBitSet/1.1/SparseBitSet-1.1.jar
20 ewf? ( https://github.com/sleuthkit/libewf_64bit/archive/VisualStudio_2010.tar.gz -> sleuthkit-libewf_64bit-20130416.tar.gz )"
22 LICENSE="BSD CPL-1.0 GPL-2+ IBM java? ( Apache-2.0 )"
23 SLOT="0/13" # subslot = major soname version
24 KEYWORDS="~amd64 ~hppa ~ppc ~x86"
25 IUSE="aff doc ewf java postgres static-libs test +threads zlib"
26 RESTRICT="!test? ( test )"
28 # Note: It is not possible to move the dep on dev-java/jdbc-postgresql
29 # inside a conditional postgres? block because java sources import
30 # org.postgres unconditionally as of writing this (version 4.6.4). The
31 # postgres USE flag will be used for the TSK postgresql support however.
35 aff? ( app-forensics/afflib )
36 ewf? ( sys-libs/zlib )
39 >=dev-java/c3p0-0.9.5:0
40 >=dev-java/jdbc-postgresql-9.4:0
42 postgres? ( dev-db/postgresql:= )
43 zlib? ( sys-libs/zlib )
45 # TODO: add support for not-in-tree libraries libvhdi and libvmdk
46 # libvhdi: https://github.com/libyal/libvhdi
47 # libvmdk: https://github.com/libyal/libvmdk
49 # vhdi? ( dev-libs/libvhdi )
50 # vmdk? ( dev-libs/libvmdk )
54 java? ( >=virtual/jre-1.8:= )
57 doc? ( app-doc/doxygen )
58 test? ( >=dev-util/cppunit-1.2.1 )
62 "${FILESDIR}"/${PN}-4.1.0-tools-shared-libs.patch
63 "${FILESDIR}"/${PN}-4.6.4-default-jar-location-fix.patch
72 pushd "${T}" &>/dev/null || die
73 unpack sleuthkit-libewf_64bit-20130416.tar.gz
74 export TSK_LIBEWF_SRCDIR="${T}"/libewf_64bit-VisualStudio_2010
75 popd &>/dev/null || die
78 # Copy the jar files that don't exist in the tree yet
80 TSK_JAR_DIR="${T}/lib"
81 mkdir "${TSK_JAR_DIR}" || die
83 if [[ ${f} =~ .jar$ ]]; then
84 cp "${DISTDIR}"/"${f}" "${TSK_JAR_DIR}" || die
91 tsk_prepare_libewf() {
92 # Inlining breaks the compilation, disable it
93 sed -e 's/LIBUNA_INLINE inline/LIBUNA_INLINE/' \
94 -i "${TSK_LIBEWF_SRCDIR}"/libuna/libuna_inline.h || die
98 use ewf && tsk_prepare_libewf
101 pushd "${S}"/bindings/java &>/dev/null || die
103 # Prevent "make install" from installing
104 # jar files under /usr/share/java
105 # We'll use the java eclasses for this
106 sed -e '/^jar_DATA/ d;' -i Makefile.am || die
108 java-pkg-opt-2_src_prepare
110 popd &>/dev/null || die
113 # Override the doxygen output directories
115 sed -e "/^OUTPUT_DIRECTORY/ s|=.*$|= ${T}/doc|" \
116 -i tsk/docs/Doxyfile \
117 -i bindings/java/doxygen/Doxyfile || die
120 # It's safe to call this even after java-pkg-opt-2_src_prepare
121 # because future calls to eapply_user do nothing and return 0
127 tsk_compile_libewf() {
156 # We want to contain our build flags
157 local CFLAGS="${CFLAGS}"
158 local LDFLAGS="${LDFLAGS}"
160 pushd "${TSK_LIBEWF_SRCDIR}" &>/dev/null || die
162 # Produce relocatable code
165 econf "${myeconfargs[@]}"
167 # Do not waste CPU cycles on building ewftools
168 sed -e '/ewftools/ d' -i Makefile || die
171 # Only install the headers and the library
172 emake -C libewf DESTDIR="${T}"/image install
173 emake -C include DESTDIR="${T}"/image install
174 find "${T}"/image -name '*.la' -delete || die
176 popd &>/dev/null || die
181 --enable-offline="${TSK_JAR_DIR}"
183 $(use_enable static-libs static)
184 $(use_enable threads multithreading)
185 $(use_with aff afflib)
188 # Workaround the automagic detection of postgresql
189 local -x ac_cv_lib_pq_PQlibVersion="$(usex postgres)"
190 # TODO: add support for non-existing libraries libvhdi and libvmdk
192 # $(use_with vhdi libvhdi)
193 # $(use_with vmdk libvmdk)
200 use ewf && tsk_compile_libewf
201 myeconfargs+=( $(use_with ewf libewf "${T}"/image) )
204 pushd "${S}"/bindings/java &>/dev/null || die
205 java-ant-2_src_configure
206 popd &>/dev/null || die
209 econf "${myeconfargs[@]}"
213 # Give it an existing bogus ivy home #672220
214 local -x IVY_HOME="${T}"
216 # Create symlinks of jars for the required dependencies
218 pushd "${S}"/bindings/java &>/dev/null || die
220 java-pkg_jar-from --into "${TSK_JAR_DIR}" c3p0
221 java-pkg_jar-from --into "${TSK_JAR_DIR}" jdbc-postgresql
223 popd &>/dev/null || die
226 # Create the doc output dirs if requested
228 mkdir -p "${T}"/doc/{api-docs,jni-docs} || die
231 emake all $(usex doc api-docs "")
238 pushd "${S}"/bindings/java &>/dev/null || die
240 java-pkg_newjar "dist/${P}.jar" "${PN}.jar"
242 # Install the bundled jar files
243 pushd "${TSK_JAR_DIR}" &>/dev/null || die
245 # Skip the symlinks java-pkg_jar-from created
246 [[ -f ${f} ]] || continue
248 # Strip the version numbers as per eclass recommendation
249 [[ ${f} =~ -([0-9]+\.)+jar$ ]] || continue
251 java-pkg_newjar "${f}" "${f/${BASH_REMATCH[0]}/.jar}"
253 popd &>/dev/null || die
255 popd &>/dev/null || die
260 # It unconditionally builds both api and jni docs
261 # We install conditionally based on the provided use flags
263 dodoc -r "${T}"/doc/api-docs
264 use java && dodoc -r "${T}"/doc/jni-docs
267 find "${D}" -name '*.la' -delete || die