app-forensics/lynis: Update cron script
[gentoo.git] / app-forensics / sleuthkit / sleuthkit-4.6.0.ebuild
1 # Copyright 1999-2018 Gentoo Foundation
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? ( http://repo1.maven.org/maven2/org/xerial/sqlite-jdbc/3.8.11/sqlite-jdbc-3.8.11.jar )
17         ewf? ( https://dev.gentoo.org/~gokturk/distfiles/app-forensics/libewf/libewf-20130128.tar.gz )"
18
19 LICENSE="BSD CPL-1.0 GPL-2+ IBM java? ( Apache-2.0 )"
20 SLOT="0/13" # subslot = major soname version
21 KEYWORDS="~amd64 ~hppa ~ppc ~x86"
22 IUSE="aff doc ewf java static-libs test +threads zlib"
23
24 DEPEND="
25         dev-db/sqlite:3
26         dev-lang/perl:*
27         aff? ( app-forensics/afflib )
28         ewf? ( sys-libs/zlib )
29         java? (
30                 >=virtual/jdk-1.8:*
31                 >=dev-java/c3p0-0.9.5:0
32                 >=dev-java/jdbc-postgresql-9.4:0
33         )
34         zlib? ( sys-libs/zlib )
35 "
36 RDEPEND="${DEPEND}
37         java? ( >=virtual/jre-1.8:= )
38 "
39 DEPEND="${DEPEND}
40         doc? ( app-doc/doxygen )
41         test? ( >=dev-util/cppunit-1.2.1 )
42 "
43
44 PATCHES=(
45         "${FILESDIR}"/${PN}-4.1.0-tools-shared-libs.patch
46 )
47
48 src_unpack() {
49         local f
50
51         unpack ${P}.tar.gz
52
53         # Ick, the upstream is stuck at libewf-20130128 which is
54         # not even in the tree anymore. So we have to bundle it.
55         if use ewf; then
56                 pushd "${T}" &>/dev/null || die
57                 unpack libewf-20130128.tar.gz
58                 export TSK_LIBEWF_SRCDIR="${T}"/libewf-20130128
59                 popd &>/dev/null || die
60         fi
61
62         # Copy the jar files that don't exist in the tree yet
63         if use java; then
64                 TSK_JAR_DIR="${S}/bindings/java/lib"
65                 mkdir "${TSK_JAR_DIR}" || die
66                 for f in ${A}; do
67                         if [[ ${f} =~ .jar$ ]]; then
68                                 cp "${DISTDIR}"/"${f}" "${TSK_JAR_DIR}" || die
69                         fi
70                 done
71                 export TSK_JAR_DIR
72         fi
73 }
74
75 src_prepare() {
76         if use ewf; then
77                 # Yeah, libewf-20130128 obviously doesn't just nicely compile
78                 sed -e 's/LIBUNA_INLINE inline/LIBUNA_INLINE/' \
79                         -i "${TSK_LIBEWF_SRCDIR}"/libuna/libuna_inline.h || die
80         fi
81
82         if use java; then
83                 pushd "${S}"/bindings/java &>/dev/null || die
84
85                 # Prevent "make install" from installing
86                 # jar files under /usr/share/java
87                 # We'll use the java eclasses for this
88                 sed -e '/^jar_DATA/ d;' -i Makefile.am || die
89
90                 # Disable dependency retrieval using ivy
91                 # We will handle it ourselves
92                 sed -e '/name="compile"/ s/, retrieve-deps//' \
93                         -e '/name="dist-/ s/, init-ivy//g' \
94                         -i build.xml || die
95
96                 java-pkg-opt-2_src_prepare
97
98                 popd &>/dev/null || die
99         fi
100
101         # Override the doxygen output directories
102         if use doc; then
103                 sed -e "/^OUTPUT_DIRECTORY/ s|=.*$|= ${T}/doc|" \
104                         -i tsk/docs/Doxyfile \
105                         -i bindings/java/doxygen/Doxyfile || die
106         fi
107
108         # It's safe to call this even after java-pkg-opt-2_src_prepare
109         # because future calls to eapply_user do nothing and return 0
110         default
111
112         eautoreconf
113 }
114
115 tsk_compile_libewf() {
116         local myeconfargs=(
117                 --prefix=/
118                 --libdir=/lib
119                 --enable-static
120                 --disable-shared
121                 --disable-winapi
122                 --without-libbfio
123                 --with-zlib
124                 --without-bzip2
125                 --without-libhmac
126                 --without-openssl
127                 --without-libuuid
128                 --without-libfuse
129         )
130         # We want to contain our build flags
131         local CFLAGS="${CFLAGS}"
132         local LDFLAGS="${LDFLAGS}"
133
134         pushd "${TSK_LIBEWF_SRCDIR}" &>/dev/null || die
135
136         # Produce relocatable code
137         CFLAGS+=" -fPIC"
138         LDFLAGS+=" -fPIC"
139         econf "${myeconfargs[@]}"
140
141         # Do not waste CPU cycles on building ewftools
142         sed -e '/ewftools/ d' -i Makefile || die
143         emake
144
145         # Only install the headers and the library
146         emake -C libewf DESTDIR="${T}"/image install
147         emake -C include DESTDIR="${T}"/image install
148
149         popd &>/dev/null || die
150 }
151
152 src_configure() {
153         local myeconfargs=(
154                 $(use_enable java)
155                 $(use_enable static-libs static)
156                 $(use_enable threads multithreading)
157                 $(use_with aff afflib)
158                 $(use_with ewf libewf)
159                 $(use_with zlib)
160         )
161
162         if use ewf; then
163                 tsk_compile_libewf
164                 myeconfargs+=( $(use_with ewf libewf "${T}"/image) )
165         fi
166
167         if use java; then
168                 pushd "${S}"/bindings/java &>/dev/null || die
169                 java-ant-2_src_configure
170                 popd &>/dev/null || die
171         fi
172
173         econf "${myeconfargs[@]}"
174 }
175
176 src_compile() {
177         # Create symlinks of jars for the required dependencies
178         if use java; then
179                 pushd "${S}"/bindings/java &>/dev/null || die
180
181                 java-pkg_jar-from --into "${TSK_JAR_DIR}" c3p0
182                 java-pkg_jar-from --into "${TSK_JAR_DIR}" jdbc-postgresql
183
184                 popd &>/dev/null || die
185         fi
186
187         # Create the doc output dirs if requested
188         if use doc; then
189                 mkdir -p "${T}"/doc/{api-docs,jni-docs} || die
190         fi
191
192         emake all $(usex doc api-docs "")
193 }
194
195 src_install() {
196         local f
197
198         if use java; then
199                 pushd "${S}"/bindings/java &>/dev/null || die
200
201                 java-pkg_dojar dist/${P}.jar
202
203                 # Install the bundled jar files
204                 pushd "${TSK_JAR_DIR}" &>/dev/null || die
205                 for f in *; do
206                         # Skip the symlinks java-pkg_jar-from created
207                         [[ -f ${f} ]] || continue
208
209                         # Strip the version numbers as per eclass recommendation
210                         [[ ${f} =~ -([0-9].)+.jar$ ]] || continue
211
212                         java-pkg_newjar "${f}" "${f/${BASH_REMATCH[0]}/.jar}"
213                 done
214                 popd &>/dev/null || die
215
216                 popd &>/dev/null || die
217         fi
218
219         default
220
221         # It unconditionally builds both api and jni docs
222         # We install conditionally based on the provided use flags
223         if use doc; then
224                 dodoc -r "${T}"/doc/api-docs
225                 use java && dodoc -r "${T}"/doc/jni-docs
226         fi
227
228         find "${D}" -name '*.la' -delete || die
229 }