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.8.11/sqlite-jdbc-3.8.11.jar
18 http://repo1.maven.org/maven2/com/zaxxer/SparseBitSet/1.1/SparseBitSet-1.1.jar
20 ewf? ( https://dev.gentoo.org/~gokturk/distfiles/app-forensics/libewf/libewf-20130128.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"
27 # Note: It is not possible to move the dep on dev-java/jdbc-postgresql
28 # inside a conditional postgres? block because java sources import
29 # org.postgres unconditionally as of writing this (version 4.6.4). The
30 # postgres USE flag will be used for the TSK postgresql support however.
34 aff? ( app-forensics/afflib )
35 ewf? ( sys-libs/zlib )
38 >=dev-java/c3p0-0.9.5:0
39 >=dev-java/jdbc-postgresql-9.4:0
41 postgres? ( dev-db/postgresql:= )
42 zlib? ( sys-libs/zlib )
44 # TODO: add support for not-in-tree libraries libvhdi and libvmdk
45 # libvhdi: https://github.com/libyal/libvhdi
46 # libvmdk: https://github.com/libyal/libvmdk
48 # vhdi? ( dev-libs/libvhdi )
49 # vmdk? ( dev-libs/libvmdk )
53 java? ( >=virtual/jre-1.8:= )
56 doc? ( app-doc/doxygen )
57 test? ( >=dev-util/cppunit-1.2.1 )
61 "${FILESDIR}"/${PN}-4.1.0-tools-shared-libs.patch
62 "${FILESDIR}"/${PN}-4.6.4-default-jar-location-fix.patch
70 # Ick, the upstream is stuck at libewf-20130128 which is
71 # not even in the tree anymore. So we have to bundle it.
73 pushd "${T}" &>/dev/null || die
74 unpack libewf-20130128.tar.gz
75 export TSK_LIBEWF_SRCDIR="${T}"/libewf-20130128
76 popd &>/dev/null || die
79 # Copy the jar files that don't exist in the tree yet
81 TSK_JAR_DIR="${T}/lib"
82 mkdir "${TSK_JAR_DIR}" || die
84 if [[ ${f} =~ .jar$ ]]; then
85 cp "${DISTDIR}"/"${f}" "${TSK_JAR_DIR}" || die
92 tsk_prepare_libewf() {
93 # Yeah, libewf-20130128 obviously doesn't just nicely compile
94 sed -e 's/LIBUNA_INLINE inline/LIBUNA_INLINE/' \
95 -i "${TSK_LIBEWF_SRCDIR}"/libuna/libuna_inline.h || die
99 use ewf && tsk_prepare_libewf
102 pushd "${S}"/bindings/java &>/dev/null || die
104 # Prevent "make install" from installing
105 # jar files under /usr/share/java
106 # We'll use the java eclasses for this
107 sed -e '/^jar_DATA/ d;' -i Makefile.am || die
109 java-pkg-opt-2_src_prepare
111 popd &>/dev/null || die
114 # Override the doxygen output directories
116 sed -e "/^OUTPUT_DIRECTORY/ s|=.*$|= ${T}/doc|" \
117 -i tsk/docs/Doxyfile \
118 -i bindings/java/doxygen/Doxyfile || die
121 # It's safe to call this even after java-pkg-opt-2_src_prepare
122 # because future calls to eapply_user do nothing and return 0
128 tsk_compile_libewf() {
157 # We want to contain our build flags
158 local CFLAGS="${CFLAGS}"
159 local LDFLAGS="${LDFLAGS}"
161 pushd "${TSK_LIBEWF_SRCDIR}" &>/dev/null || die
163 # Produce relocatable code
166 econf "${myeconfargs[@]}"
168 # Do not waste CPU cycles on building ewftools
169 sed -e '/ewftools/ d' -i Makefile || die
172 # Only install the headers and the library
173 emake -C libewf DESTDIR="${T}"/image install
174 emake -C include DESTDIR="${T}"/image install
175 find "${T}"/image -name '*.la' -delete || die
177 popd &>/dev/null || die
182 --enable-offline="${TSK_JAR_DIR}"
184 $(use_enable static-libs static)
185 $(use_enable threads multithreading)
186 $(use_with aff afflib)
189 # Workaround the automagic detection of postgresql
190 local -x ac_cv_lib_pq_PQlibVersion="$(usex postgres)"
191 # TODO: add support for non-existing libraries libvhdi and libvmdk
193 # $(use_with vhdi libvhdi)
194 # $(use_with vmdk libvmdk)
201 use ewf && tsk_compile_libewf
202 myeconfargs+=( $(use_with ewf libewf "${T}"/image) )
205 pushd "${S}"/bindings/java &>/dev/null || die
206 java-ant-2_src_configure
207 popd &>/dev/null || die
210 econf "${myeconfargs[@]}"
214 # Give it an existing bogus ivy home #672220
215 local -x IVY_HOME="${T}"
217 # Create symlinks of jars for the required dependencies
219 pushd "${S}"/bindings/java &>/dev/null || die
221 java-pkg_jar-from --into "${TSK_JAR_DIR}" c3p0
222 java-pkg_jar-from --into "${TSK_JAR_DIR}" jdbc-postgresql
224 popd &>/dev/null || die
227 # Create the doc output dirs if requested
229 mkdir -p "${T}"/doc/{api-docs,jni-docs} || die
232 emake all $(usex doc api-docs "")
239 pushd "${S}"/bindings/java &>/dev/null || die
241 java-pkg_newjar "dist/${P}.jar" "${PN}.jar"
243 # Install the bundled jar files
244 pushd "${TSK_JAR_DIR}" &>/dev/null || die
246 # Skip the symlinks java-pkg_jar-from created
247 [[ -f ${f} ]] || continue
249 # Strip the version numbers as per eclass recommendation
250 [[ ${f} =~ -([0-9]+\.)+jar$ ]] || continue
252 java-pkg_newjar "${f}" "${f/${BASH_REMATCH[0]}/.jar}"
254 popd &>/dev/null || die
256 popd &>/dev/null || die
261 # It unconditionally builds both api and jni docs
262 # We install conditionally based on the provided use flags
264 dodoc -r "${T}"/doc/api-docs
265 use java && dodoc -r "${T}"/doc/jni-docs
268 find "${D}" -name '*.la' -delete || die