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 # Depending specifically on oracle-jdk-bin is an overkill but we have no
29 # other options right now. OpenJDK would also work, but there is no
30 # openjfx to provide javafx support for OpenJDK-8 in Gentoo. That also
33 JAVA_PKG_WANT_BUILD_VM="oracle-jdk-bin-1.8"
34 JAVA_PKG_WANT_SOURCE=1.8
35 JAVA_PKG_WANT_TARGET=1.8
37 # Note: It is not possible to move the dep on dev-java/jdbc-postgresql
38 # inside a conditional postgres? block because java sources import
39 # org.postgres unconditionally as of writing this (version 4.6.4). The
40 # postgres USE flag will be used for the TSK postgresql support however.
45 aff? ( app-forensics/afflib )
46 ewf? ( sys-libs/zlib )
48 >=dev-java/c3p0-0.9.5:0
49 dev-java/commons-lang:3.1
51 >=dev-java/jdbc-postgresql-9.4:0
52 >=dev-java/joda-time-2.4:0
54 postgres? ( dev-db/postgresql:= )
55 zlib? ( sys-libs/zlib )
57 # TODO: add support for not-in-tree libraries libvhdi and libvmdk
58 # libvhdi: https://github.com/libyal/libvhdi
59 # libvmdk: https://github.com/libyal/libvmdk
61 # vhdi? ( dev-libs/libvhdi )
62 # vmdk? ( dev-libs/libvmdk )
68 dev-java/oracle-jre-bin:1.8[javafx]
69 dev-java/oracle-jdk-bin:1.8[javafx]
74 java? ( dev-java/oracle-jdk-bin:1.8[javafx] )
75 doc? ( app-doc/doxygen )
76 test? ( >=dev-util/cppunit-1.2.1 )
80 "${FILESDIR}"/${PN}-4.1.0-tools-shared-libs.patch
81 "${FILESDIR}"/${PN}-4.6.4-default-jar-location-fix.patch
90 pushd "${T}" &>/dev/null || die
91 unpack sleuthkit-libewf_64bit-20130416.tar.gz
92 export TSK_LIBEWF_SRCDIR="${T}"/libewf_64bit-VisualStudio_2010
93 popd &>/dev/null || die
96 # Copy the jar files that don't exist in the tree yet
98 TSK_JAR_DIR="${T}/lib"
99 mkdir "${TSK_JAR_DIR}" || die
101 if [[ ${f} =~ .jar$ ]]; then
102 cp "${DISTDIR}"/"${f}" "${TSK_JAR_DIR}" || die
109 tsk_prepare_libewf() {
110 # Inlining breaks the compilation, disable it
111 sed -e 's/LIBUNA_INLINE inline/LIBUNA_INLINE/' \
112 -i "${TSK_LIBEWF_SRCDIR}"/libuna/libuna_inline.h || die
116 use ewf && tsk_prepare_libewf
119 pushd "${S}"/bindings/java &>/dev/null || die
121 # Prevent "make install" from installing
122 # jar files under /usr/share/java
123 # We'll use the java eclasses for this
124 sed -e '/^jar_DATA/ d;' -i Makefile.am || die
126 java-pkg-opt-2_src_prepare
128 popd &>/dev/null || die
131 # Override the doxygen output directories
133 sed -e "/^OUTPUT_DIRECTORY/ s|=.*$|= ${T}/doc|" \
134 -i tsk/docs/Doxyfile \
135 -i bindings/java/doxygen/Doxyfile || die
138 # It's safe to call this even after java-pkg-opt-2_src_prepare
139 # because future calls to eapply_user do nothing and return 0
145 tsk_compile_libewf() {
174 # We want to contain our build flags
175 local CFLAGS="${CFLAGS}"
176 local LDFLAGS="${LDFLAGS}"
178 pushd "${TSK_LIBEWF_SRCDIR}" &>/dev/null || die
180 # Produce relocatable code
183 econf "${myeconfargs[@]}"
185 # Do not waste CPU cycles on building ewftools
186 sed -e '/ewftools/ d' -i Makefile || die
189 # Only install the headers and the library
190 emake -C libewf DESTDIR="${T}"/image install
191 emake -C include DESTDIR="${T}"/image install
192 find "${T}"/image -name '*.la' -delete || die
194 popd &>/dev/null || die
199 --enable-offline="${TSK_JAR_DIR}"
201 $(use_enable static-libs static)
202 $(use_enable threads multithreading)
203 $(use_with aff afflib)
206 # Workaround the automagic detection of postgresql
207 local -x ac_cv_lib_pq_PQlibVersion="$(usex postgres)"
208 # TODO: add support for non-existing libraries libvhdi and libvmdk
210 # $(use_with vhdi libvhdi)
211 # $(use_with vmdk libvmdk)
218 use ewf && tsk_compile_libewf
219 myeconfargs+=( $(use_with ewf libewf "${T}"/image) )
222 pushd "${S}"/bindings/java &>/dev/null || die
223 java-ant-2_src_configure
224 popd &>/dev/null || die
227 econf "${myeconfargs[@]}"
231 # Give it an existing bogus ivy home #672220
232 local -x IVY_HOME="${T}"
234 # Create symlinks of jars for the required dependencies
236 pushd "${S}"/bindings/java &>/dev/null || die
238 java-pkg_jar-from --into "${TSK_JAR_DIR}" c3p0
239 java-pkg_jar-from --into "${TSK_JAR_DIR}" commons-lang:3.1
240 java-pkg_jar-from --into "${TSK_JAR_DIR}" guava:20
241 java-pkg_jar-from --into "${TSK_JAR_DIR}" jdbc-postgresql
242 java-pkg_jar-from --into "${TSK_JAR_DIR}" joda-time
244 popd &>/dev/null || die
247 # Create the doc output dirs if requested
249 mkdir -p "${T}"/doc/{api-docs,jni-docs} || die
252 emake all $(usex doc api-docs "")
259 pushd "${S}"/bindings/java &>/dev/null || die
261 java-pkg_newjar "dist/${P}.jar" "${PN}.jar"
263 # Install the bundled jar files
264 pushd "${TSK_JAR_DIR}" &>/dev/null || die
266 # Skip the symlinks java-pkg_jar-from created
267 [[ -f ${f} ]] || continue
269 # Strip the version numbers as per eclass recommendation
270 [[ ${f} =~ -([0-9]+\.)+jar$ ]] || continue
272 java-pkg_newjar "${f}" "${f/${BASH_REMATCH[0]}/.jar}"
274 popd &>/dev/null || die
276 popd &>/dev/null || die
281 # It unconditionally builds both api and jni docs
282 # We install conditionally based on the provided use flags
284 dodoc -r "${T}"/doc/api-docs
285 use java && dodoc -r "${T}"/doc/jni-docs
288 find "${D}" -name '*.la' -delete || die