media-plugins/gst-plugins-jack: alpha stable wrt bug #702246
[gentoo.git] / app-forensics / sleuthkit / sleuthkit-4.7.0.ebuild
1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 JAVA_PKG_BSFIX_NAME="build.xml build-unix.xml"
7 inherit autotools java-pkg-opt-2 java-ant-2
8
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? (
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
19         )
20         ewf? ( https://github.com/sleuthkit/libewf_64bit/archive/VisualStudio_2010.tar.gz -> sleuthkit-libewf_64bit-20130416.tar.gz )"
21
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 )"
27
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
31 # eliminates IcedTea.
32 #
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
36 #
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.
41 #
42 DEPEND="
43         dev-db/sqlite:3
44         dev-lang/perl:*
45         aff? ( app-forensics/afflib )
46         ewf? ( sys-libs/zlib )
47         java? (
48                 >=dev-java/c3p0-0.9.5:0
49                 dev-java/commons-lang:3.1
50                 dev-java/guava:20
51                 >=dev-java/jdbc-postgresql-9.4:0
52                 >=dev-java/joda-time-2.4:0
53         )
54         postgres? ( dev-db/postgresql:= )
55         zlib? ( sys-libs/zlib )
56 "
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
60 # DEPEND="${DEPEND}
61 #       vhdi? ( dev-libs/libvhdi )
62 #       vmdk? ( dev-libs/libvmdk )
63 # "
64
65 RDEPEND="${DEPEND}
66         java? (
67                 || (
68                         dev-java/oracle-jre-bin:1.8[javafx]
69                         dev-java/oracle-jdk-bin:1.8[javafx]
70                 )
71         )
72 "
73 DEPEND="${DEPEND}
74         java? ( dev-java/oracle-jdk-bin:1.8[javafx] )
75         doc? ( app-doc/doxygen )
76         test? ( >=dev-util/cppunit-1.2.1 )
77 "
78
79 PATCHES=(
80         "${FILESDIR}"/${PN}-4.1.0-tools-shared-libs.patch
81         "${FILESDIR}"/${PN}-4.6.4-default-jar-location-fix.patch
82 )
83
84 src_unpack() {
85         local f
86
87         unpack ${P}.tar.gz
88
89         if use ewf; then
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
94         fi
95
96         # Copy the jar files that don't exist in the tree yet
97         if use java; then
98                 TSK_JAR_DIR="${T}/lib"
99                 mkdir "${TSK_JAR_DIR}" || die
100                 for f in ${A}; do
101                         if [[ ${f} =~ .jar$ ]]; then
102                                 cp "${DISTDIR}"/"${f}" "${TSK_JAR_DIR}" || die
103                         fi
104                 done
105                 export TSK_JAR_DIR
106         fi
107 }
108
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
113 }
114
115 src_prepare() {
116         use ewf && tsk_prepare_libewf
117
118         if use java; then
119                 pushd "${S}"/bindings/java &>/dev/null || die
120
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
125
126                 java-pkg-opt-2_src_prepare
127
128                 popd &>/dev/null || die
129         fi
130
131         # Override the doxygen output directories
132         if use doc; then
133                 sed -e "/^OUTPUT_DIRECTORY/ s|=.*$|= ${T}/doc|" \
134                         -i tsk/docs/Doxyfile \
135                         -i bindings/java/doxygen/Doxyfile || die
136         fi
137
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
140         default
141
142         eautoreconf
143 }
144
145 tsk_compile_libewf() {
146         local myeconfargs=(
147                 --prefix=/
148                 --libdir=/lib
149                 --enable-static
150                 --disable-shared
151                 --disable-winapi
152                 --without-libbfio
153                 --with-zlib
154                 --without-bzip2
155                 --without-libhmac
156                 --without-openssl
157                 --without-libuuid
158                 --without-libfuse
159
160                 --with-libcstring=no
161                 --with-libcerror=no
162                 --with-libcdata=no
163                 --with-libclocale=no
164                 --with-libcnotify=no
165                 --with-libcsplit=no
166                 --with-libuna=no
167                 --with-libcfile=no
168                 --with-libcpath=no
169                 --with-libbfio=no
170                 --with-libfcache=no
171                 --with-libfvalue=no
172
173         )
174         # We want to contain our build flags
175         local CFLAGS="${CFLAGS}"
176         local LDFLAGS="${LDFLAGS}"
177
178         pushd "${TSK_LIBEWF_SRCDIR}" &>/dev/null || die
179
180         # Produce relocatable code
181         CFLAGS+=" -fPIC"
182         LDFLAGS+=" -fPIC"
183         econf "${myeconfargs[@]}"
184
185         # Do not waste CPU cycles on building ewftools
186         sed -e '/ewftools/ d' -i Makefile || die
187         emake
188
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
193
194         popd &>/dev/null || die
195 }
196
197 src_configure() {
198         local myeconfargs=(
199                 --enable-offline="${TSK_JAR_DIR}"
200                 $(use_enable java)
201                 $(use_enable static-libs static)
202                 $(use_enable threads multithreading)
203                 $(use_with aff afflib)
204                 $(use_with zlib)
205         )
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
209         # myeconfargs+=(
210         #       $(use_with vhdi libvhdi)
211         #       $(use_with vmdk libvmdk)
212         # )
213         myeconfargs+=(
214                 --without-libvhdi
215                 --without-libvmdk
216         )
217
218         use ewf && tsk_compile_libewf
219         myeconfargs+=( $(use_with ewf libewf "${T}"/image) )
220
221         if use java; then
222                 pushd "${S}"/bindings/java &>/dev/null || die
223                 java-ant-2_src_configure
224                 popd &>/dev/null || die
225         fi
226
227         econf "${myeconfargs[@]}"
228 }
229
230 src_compile() {
231         # Give it an existing bogus ivy home #672220
232         local -x IVY_HOME="${T}"
233
234         # Create symlinks of jars for the required dependencies
235         if use java; then
236                 pushd "${S}"/bindings/java &>/dev/null || die
237
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
243
244                 popd &>/dev/null || die
245         fi
246
247         # Create the doc output dirs if requested
248         if use doc; then
249                 mkdir -p "${T}"/doc/{api-docs,jni-docs} || die
250         fi
251
252         emake all $(usex doc api-docs "")
253 }
254
255 src_install() {
256         local f
257
258         if use java; then
259                 pushd "${S}"/bindings/java &>/dev/null || die
260
261                 java-pkg_newjar "dist/${P}.jar" "${PN}.jar"
262
263                 # Install the bundled jar files
264                 pushd "${TSK_JAR_DIR}" &>/dev/null || die
265                 for f in *; do
266                         # Skip the symlinks java-pkg_jar-from created
267                         [[ -f ${f} ]] || continue
268
269                         # Strip the version numbers as per eclass recommendation
270                         [[ ${f} =~ -([0-9]+\.)+jar$ ]] || continue
271
272                         java-pkg_newjar "${f}" "${f/${BASH_REMATCH[0]}/.jar}"
273                 done
274                 popd &>/dev/null || die
275
276                 popd &>/dev/null || die
277         fi
278
279         default
280
281         # It unconditionally builds both api and jni docs
282         # We install conditionally based on the provided use flags
283         if use doc; then
284                 dodoc -r "${T}"/doc/api-docs
285                 use java && dodoc -r "${T}"/doc/jni-docs
286         fi
287
288         find "${D}" -name '*.la' -delete || die
289 }