kde-apps/kontact: arm64 stable
[gentoo.git] / app-forensics / sleuthkit / sleuthkit-4.6.5.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.8.11/sqlite-jdbc-3.8.11.jar
18                 http://repo1.maven.org/maven2/com/zaxxer/SparseBitSet/1.1/SparseBitSet-1.1.jar
19         )
20         ewf? ( https://dev.gentoo.org/~gokturk/distfiles/app-forensics/libewf/libewf-20130128.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
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.
31 DEPEND="
32         dev-db/sqlite:3
33         dev-lang/perl:*
34         aff? ( app-forensics/afflib )
35         ewf? ( sys-libs/zlib )
36         java? (
37                 >=virtual/jdk-1.8:*
38                 >=dev-java/c3p0-0.9.5:0
39                 >=dev-java/jdbc-postgresql-9.4:0
40         )
41         postgres? ( dev-db/postgresql:= )
42         zlib? ( sys-libs/zlib )
43 "
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
47 # DEPEND="${DEPEND}
48 #       vhdi? ( dev-libs/libvhdi )
49 #       vmdk? ( dev-libs/libvmdk )
50 # "
51
52 RDEPEND="${DEPEND}
53         java? ( >=virtual/jre-1.8:= )
54 "
55 DEPEND="${DEPEND}
56         doc? ( app-doc/doxygen )
57         test? ( >=dev-util/cppunit-1.2.1 )
58 "
59
60 PATCHES=(
61         "${FILESDIR}"/${PN}-4.1.0-tools-shared-libs.patch
62         "${FILESDIR}"/${PN}-4.6.4-default-jar-location-fix.patch
63 )
64
65 src_unpack() {
66         local f
67
68         unpack ${P}.tar.gz
69
70         # Ick, the upstream is stuck at libewf-20130128 which is
71         # not even in the tree anymore. So we have to bundle it.
72         if use ewf; then
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
77         fi
78
79         # Copy the jar files that don't exist in the tree yet
80         if use java; then
81                 TSK_JAR_DIR="${T}/lib"
82                 mkdir "${TSK_JAR_DIR}" || die
83                 for f in ${A}; do
84                         if [[ ${f} =~ .jar$ ]]; then
85                                 cp "${DISTDIR}"/"${f}" "${TSK_JAR_DIR}" || die
86                         fi
87                 done
88                 export TSK_JAR_DIR
89         fi
90 }
91
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
96 }
97
98 src_prepare() {
99         use ewf && tsk_prepare_libewf
100
101         if use java; then
102                 pushd "${S}"/bindings/java &>/dev/null || die
103
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
108
109                 java-pkg-opt-2_src_prepare
110
111                 popd &>/dev/null || die
112         fi
113
114         # Override the doxygen output directories
115         if use doc; then
116                 sed -e "/^OUTPUT_DIRECTORY/ s|=.*$|= ${T}/doc|" \
117                         -i tsk/docs/Doxyfile \
118                         -i bindings/java/doxygen/Doxyfile || die
119         fi
120
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
123         default
124
125         eautoreconf
126 }
127
128 tsk_compile_libewf() {
129         local myeconfargs=(
130                 --prefix=/
131                 --libdir=/lib
132                 --enable-static
133                 --disable-shared
134                 --disable-winapi
135                 --without-libbfio
136                 --with-zlib
137                 --without-bzip2
138                 --without-libhmac
139                 --without-openssl
140                 --without-libuuid
141                 --without-libfuse
142
143                 --with-libcstring=no
144                 --with-libcerror=no
145                 --with-libcdata=no
146                 --with-libclocale=no
147                 --with-libcnotify=no
148                 --with-libcsplit=no
149                 --with-libuna=no
150                 --with-libcfile=no
151                 --with-libcpath=no
152                 --with-libbfio=no
153                 --with-libfcache=no
154                 --with-libfvalue=no
155
156         )
157         # We want to contain our build flags
158         local CFLAGS="${CFLAGS}"
159         local LDFLAGS="${LDFLAGS}"
160
161         pushd "${TSK_LIBEWF_SRCDIR}" &>/dev/null || die
162
163         # Produce relocatable code
164         CFLAGS+=" -fPIC"
165         LDFLAGS+=" -fPIC"
166         econf "${myeconfargs[@]}"
167
168         # Do not waste CPU cycles on building ewftools
169         sed -e '/ewftools/ d' -i Makefile || die
170         emake
171
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
176
177         popd &>/dev/null || die
178 }
179
180 src_configure() {
181         local myeconfargs=(
182                 --enable-offline="${TSK_JAR_DIR}"
183                 $(use_enable java)
184                 $(use_enable static-libs static)
185                 $(use_enable threads multithreading)
186                 $(use_with aff afflib)
187                 $(use_with zlib)
188         )
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
192         # myeconfargs+=(
193         #       $(use_with vhdi libvhdi)
194         #       $(use_with vmdk libvmdk)
195         # )
196         myeconfargs+=(
197                 --without-libvhdi
198                 --without-libvmdk
199         )
200
201         use ewf && tsk_compile_libewf
202         myeconfargs+=( $(use_with ewf libewf "${T}"/image) )
203
204         if use java; then
205                 pushd "${S}"/bindings/java &>/dev/null || die
206                 java-ant-2_src_configure
207                 popd &>/dev/null || die
208         fi
209
210         econf "${myeconfargs[@]}"
211 }
212
213 src_compile() {
214         # Give it an existing bogus ivy home #672220
215         local -x IVY_HOME="${T}"
216
217         # Create symlinks of jars for the required dependencies
218         if use java; then
219                 pushd "${S}"/bindings/java &>/dev/null || die
220
221                 java-pkg_jar-from --into "${TSK_JAR_DIR}" c3p0
222                 java-pkg_jar-from --into "${TSK_JAR_DIR}" jdbc-postgresql
223
224                 popd &>/dev/null || die
225         fi
226
227         # Create the doc output dirs if requested
228         if use doc; then
229                 mkdir -p "${T}"/doc/{api-docs,jni-docs} || die
230         fi
231
232         emake all $(usex doc api-docs "")
233 }
234
235 src_install() {
236         local f
237
238         if use java; then
239                 pushd "${S}"/bindings/java &>/dev/null || die
240
241                 java-pkg_newjar "dist/${P}.jar" "${PN}.jar"
242
243                 # Install the bundled jar files
244                 pushd "${TSK_JAR_DIR}" &>/dev/null || die
245                 for f in *; do
246                         # Skip the symlinks java-pkg_jar-from created
247                         [[ -f ${f} ]] || continue
248
249                         # Strip the version numbers as per eclass recommendation
250                         [[ ${f} =~ -([0-9]+\.)+jar$ ]] || continue
251
252                         java-pkg_newjar "${f}" "${f/${BASH_REMATCH[0]}/.jar}"
253                 done
254                 popd &>/dev/null || die
255
256                 popd &>/dev/null || die
257         fi
258
259         default
260
261         # It unconditionally builds both api and jni docs
262         # We install conditionally based on the provided use flags
263         if use doc; then
264                 dodoc -r "${T}"/doc/api-docs
265                 use java && dodoc -r "${T}"/doc/jni-docs
266         fi
267
268         find "${D}" -name '*.la' -delete || die
269 }