Skip to content

Commit b62e87a

Browse files
authored
Merge pull request sleuthkit#3228 from sleuthkit/patch-debian
Enable java on debian GitHub actions .
2 parents ee773e2 + b51c923 commit b62e87a

File tree

8 files changed

+98
-22
lines changed

8 files changed

+98
-22
lines changed

.github/workflows/build-unix.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,27 @@ jobs:
3939
linkage: "shared"
4040
compiler: "gcc"
4141
runner: "ubuntu-24.04"
42-
configure_opts: "--with-libewf --with-libqcow --with-libvhdi --with-libvmdk --disable-java"
42+
configure_opts: "--with-libewf --with-libqcow --with-libvhdi --with-libvmdk --enable-java"
4343
make_flags: "CFLAGS=-Werror CXXFLAGS=-Werror"
4444
codecov: "no"
4545
prefix:
4646
address_sanitizer: "yes"
4747
keep_artifacts: "yes"
4848
suffix: "(with artifacts)"
49+
enable_java: "yes"
4950

5051
- os: "linux"
5152
arch: "x86_64"
5253
linkage: "shared"
5354
compiler: "clang"
5455
runner: "ubuntu-24.04"
55-
configure_opts: "--with-libewf --with-libqcow --with-libvhdi --with-libvmdk --disable-java CC=clang CXX=clang++"
56+
configure_opts: "--with-libewf --with-libqcow --with-libvhdi --with-libvmdk --enable-java CC=clang CXX=clang++"
5657
make_flags: "CFLAGS=-Werror CXXFLAGS=-Werror"
5758
codecov: "no"
5859
prefix: ""
5960
address_sanitizer: "yes"
6061
keep_artifacts: "no"
62+
enable_java: "yes"
6163

6264
- os: "mingw"
6365
arch: "x86_64"

Makefile.am

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -739,11 +739,19 @@ endif
739739
endif
740740

741741
tsk_jar = $(top_builddir)/bindings/java/dist/sleuthkit-$(PACKAGE_VERSION).jar
742+
tsk_caseuco_jar = $(top_builddir)/case-uco/java/dist/sleuthkit-caseuco-$(PACKAGE_VERSION).jar
742743
jardir = $(prefix)/share/java
743744

744-
$(tsk_jar): tsk/libtsk.la bindings/java/jni/libtsk_jni.la
745+
$(tsk_jar): tsk/libtsk.la bindings/java/jni/libtsk_jni.la tsk/.libs/@TSK_LIB@
746+
@echo '=== BEGIN manually running make as fallback ==='
747+
@$(MAKE) -j1 tsk/.libs/@TSK_LIB@
748+
@echo '=== END manually running make as fallback ==='
745749
cd bindings/java ; $(ANT) dist $(ant_args)
746750

751+
dnl Since libtool automatically creates libtsk.so or libtsk.dylib, we add this explicit rule:
752+
tsk/.libs/@TSK_LIB@: tsk/libtsk.la
753+
@true
754+
747755
CLEANFILES += $(tsk_jar)
748756

749757
jar_DATA = $(tsk_jar) $(tsk_caseuco_jar)
@@ -758,9 +766,9 @@ bindings_java_jni_libtsk_jni_la_SOURCES = \
758766
bindings/java/jni/dataModel_SleuthkitJNI.cpp \
759767
bindings/java/jni/dataModel_SleuthkitJNI.h
760768

761-
tsk_caseuco_jar = $(top_builddir)/case-uco/java/dist/sleuthkit-caseuco-$(PACKAGE_VERSION).jar
762769

763-
$(tsk_caseuco_jar):
770+
$(tsk_caseuco_jar): $(tsk_jar)
771+
@$(MAKE) -j1 tsk/.libs/@TSK_LIB@
764772
cd case-uco/java ; $(ANT) $(ant_args)
765773

766774
CLEANFILES += $(tsk_caseuco_jar)
@@ -770,10 +778,18 @@ endif # End of X_JNI check
770778
# Clean targets should be outside of the conditional
771779

772780
clean-tsk_jar:
781+
if ANT_DETECTED
773782
cd bindings/java ; $(ANT) clean
783+
else
784+
echo ANT not detected. bindings/java will not be cleaned
785+
endif
774786

775787
clean-tsk_caseuco_jar:
788+
if ANT_DETECTED
776789
cd case-uco/java ; $(ANT) clean
790+
else
791+
echo ANT not detected. case-uco/java will not be cleaned
792+
endif
777793

778794
clean_java = clean-tsk_jar clean-tsk_caseuco_jar
779795

bindings/java/jni/auto_db_java.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,10 @@ TskAutoDbJava::addFsInfo(const TSK_FS_INFO* fs_info, int64_t parObjId,
450450
* @param dataSourceObjId Object ID of the data source
451451
* @returns TSK_ERR on error, TSK_OK on success
452452
*/
453+
454+
#pragma GCC diagnostic push
455+
#pragma GCC diagnostic ignored "-Wunused-parameter"
456+
453457
TSK_RETVAL_ENUM
454458
TskAutoDbJava::addFsFile(TSK_FS_FILE* fs_file,
455459
const TSK_FS_ATTR* fs_attr, const char* path,
@@ -472,6 +476,7 @@ TskAutoDbJava::addFsFile(TSK_FS_FILE* fs_file,
472476
// Add the file to the database
473477
return addFile(fs_file, fs_attr, path, fsObjId, parObjId, dataSourceObjId);
474478
}
479+
#pragma GCC diagnostic pop
475480

476481
/**
477482
* Extract the extension from the given file name and store it in the supplied string.
@@ -673,15 +678,15 @@ TskAutoDbJava::addFile(TSK_FS_FILE* fs_file,
673678

674679
char *sid_str = NULL;
675680
jstring sidj = NULL; // return null across JNI if sid is not available
676-
681+
677682
if (tsk_fs_file_get_owner_sid(fs_file, &sid_str) == 0) {
678683
if (createJString(sid_str, sidj) != TSK_OK) {
679684
free(sid_str);
680685
return TSK_ERR;
681686
}
682-
free(sid_str);
687+
free(sid_str);
683688
}
684-
689+
685690
// Add the file to the database
686691
jlong ret_val = m_jniEnv->CallLongMethod(m_javaDbObj, m_addFileMethodID,
687692
parObjId, fsObjId,
@@ -713,9 +718,9 @@ TskAutoDbJava::addFile(TSK_FS_FILE* fs_file,
713718
&& (!(fs_file->meta->flags & TSK_FS_META_FLAG_COMP))
714719
&& (fs_attr->flags & TSK_FS_ATTR_NONRES)
715720
&& (fs_attr->nrd.allocsize > fs_attr->nrd.initsize)) {
716-
strncat(name, "-slack", 6);
721+
strcat(name, "-slack");
717722
if (strlen(extension) > 0) {
718-
strncat(extension, "-slack", 6);
723+
strcat(extension, "-slack");
719724
}
720725
jstring slackNamej;
721726
if (createJString(name, slackNamej) != TSK_OK) {
@@ -926,6 +931,10 @@ TskAutoDbJava::addUnusedBlockFile(const int64_t parentObjId, const int64_t fsObj
926931
* @param objId Object ID of the created virtual dir
927932
* @param dataSourceObjId Object ID of the data source
928933
*/
934+
#pragma GCC diagnostic push
935+
#pragma GCC diagnostic ignored "-Wunused-parameter"
936+
937+
929938
TSK_RETVAL_ENUM
930939
TskAutoDbJava::addUnallocFsBlockFilesParent(const int64_t fsObjId, int64_t& objId,
931940
int64_t dataSourceObjId) {
@@ -942,6 +951,8 @@ TskAutoDbJava::addUnallocFsBlockFilesParent(const int64_t fsObjId, int64_t& objI
942951
}
943952
return TSK_OK;
944953
}
954+
#pragma GCC diagnostic pop
955+
945956

946957
/**
947958
* Adds a new volume that will hold the unallocated blocks for the pool.

bindings/java/jni/auto_db_java.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ using std::string;
2828
#include "jni.h"
2929

3030

31+
#pragma GCC diagnostic push
32+
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
33+
3134
/** \internal
3235
* C++ class that implements TskAuto to load file metadata into a database.
3336
* This is used by the TskCaseDb class.
@@ -122,7 +125,7 @@ class TskAutoDbJava :public TskAuto {
122125
int64_t m_curFsId; ///< Object ID of file system currently being processed
123126
int64_t m_curFileId; ///< Object ID of file currently being processed
124127
TSK_INUM_T m_curDirAddr; ///< Meta address the directory currently being processed
125-
int64_t m_curUnallocDirId;
128+
int64_t m_curUnallocDirId;
126129
string m_curDirPath; //< Path of the current directory being processed
127130
tsk_lock_t m_curDirPathLock; //< protects concurrent access to m_curDirPath
128131
string m_curImgTZone;
@@ -182,7 +185,7 @@ class TskAutoDbJava :public TskAuto {
182185
TskAutoDbJava & tskAutoDbJava;
183186
const TSK_FS_INFO & fsInfo;
184187
const int64_t fsObjId;
185-
vector<TSK_DB_FILE_LAYOUT_RANGE> ranges;
188+
vector<TSK_DB_FILE_LAYOUT_RANGE> ranges;
186189
TSK_DADDR_T curRangeStart;
187190
int64_t size;
188191
const int64_t minChunkSize;
@@ -239,4 +242,7 @@ class TskAutoDbJava :public TskAuto {
239242
TSK_RETVAL_ENUM getVsByFsId(int64_t objId, TSK_DB_VS_INFO & vsDbInfo);
240243
};
241244

245+
#pragma GCC diagnostic pop
246+
247+
242248
#endif

configure.ac

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
33

44
AC_PREREQ([2.69])
55

6-
AC_INIT([sleuthkit], [4.13.0])
6+
AC_INIT([sleuthkit], [4.13.1])
77
AC_CONFIG_AUX_DIR([config])
88
AC_CONFIG_MACRO_DIR([m4])
99
AC_CONFIG_SRCDIR([tsk/base/tsk_base.h])
@@ -195,6 +195,10 @@ AM_COND_IF([CUSTOM_DEFAULT_JAR_LOCATION],
195195
)
196196

197197
dnl Test for the various Java things that we need for bindings
198+
dnl First, test is ant is available since we now use it for the build system
199+
dnl But don't make it required
200+
AC_PATH_PROG([ANT], [ant], [no])
201+
AM_CONDITIONAL([ANT_DETECTED], [test "x$ANT" != "xno"])
198202
AS_IF([test "x$enable_java" != "xno"], [
199203
dnl javac is needed to compile the JAR file
200204
AX_PROG_JAVAC
@@ -214,17 +218,14 @@ AS_IF([test "x$enable_java" != "xno"], [
214218
dnl we had one report of a system with javac and not java
215219
AX_PROG_JAVA
216220
221+
if test "x$ANT" = "xno"; then
222+
AC_MSG_ERROR([Apache Ant is required but was not found. Install Ant and try again.])
223+
fi
224+
AC_SUBST(ANT)
217225
]
218226
)
219227
]) dnl test enable_java
220228

221-
dnl Test is ant is available since we now use it for the build system
222-
dnl BC - TODO - Add this to the enable Java section and uncomment below
223-
AC_PATH_PROG([ANT], [ant], [no])
224-
dnl if test "x$ANT" = "xno"; then
225-
dnl AC_MSG_ERROR([Apache Ant is required but was not found. Install Ant and try again.])
226-
dnl fi
227-
AC_SUBST(ANT)
228229

229230

230231
dnl if we found everything we need, set ax_java_support for the
@@ -267,6 +268,29 @@ AC_CONFIG_COMMANDS([tsk/tsk_incs.h],
267268
ac_cv_header_sys_param_h=$ac_cv_header_sys_param_h
268269
ax_multithread=$ax_multithread])
269270

271+
dnl ################################################################
272+
dnl ## Set TSK_LIB as appropriate for the host
273+
dnl ##
274+
AC_CANONICAL_HOST
275+
276+
case "$host_os" in
277+
darwin*)
278+
TSK_LIB="libtsk.dylib"
279+
;;
280+
linux*)
281+
TSK_LIB="libtsk.so"
282+
;;
283+
*)
284+
TSK_LIB="libtsk.la" # Default for unknown platforms
285+
;;
286+
esac
287+
AC_SUBST(TSK_LIB)
288+
dnl ################
289+
290+
291+
dnl ################################################################
292+
dnl ## set per-host libtool flags
293+
270294
AC_MSG_CHECKING([if libtool needs -no-undefined flag to build shared libraries])
271295
case "$host" in
272296
*-*-mingw*)

docs/README_debian_package.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This document provides information on building the debing package.
2+
3+
4+
5+
6+
References
7+
==========
8+
We found these guides helpful in assembling this document:
9+
10+
* https://askubuntu.com/questions/1345/what-is-the-simplest-debian-packaging-guide
11+
* https://ubuntuforums.org/showthread.php?t=910717 (2006)
12+
* (https://www.debian.org/doc/manuals/maint-guide/)[Debian New Maintainer's Guide]
13+
* (https://www.debian.org/doc/manuals/debian-faq/pkg-basics.en.html)[Chatper 7. Basics of the Debian package management system]

tsk/auto/tsk_auto.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ typedef enum {
6161
* internal list. Those can be retrieved with getErrorList(). If you want to deal with errors
6262
* differently, you must implement handleError().
6363
*/
64+
65+
#pragma GCC diagnostic push
66+
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
67+
6468
class TskAuto {
6569
public:
6670
unsigned int m_tag;
@@ -113,7 +117,7 @@ class TskAuto {
113117
std::string getFileSystemPassword() const { return m_fileSystemPassword; }
114118

115119
/**
116-
* TskAuto calls this method before it processes the volume system that is found in an
120+
* TskAuto calls this method before it processes the volume system that is found in an
117121
* image. You can use this to learn about the volume system before it is processed
118122
* and you can force TskAuto to skip this volume system.
119123
* @param vs_info volume system details
@@ -317,6 +321,7 @@ class TskAuto {
317321
void setStopProcessing();
318322
};
319323

324+
#pragma GCC diagnostic pop
320325

321326
#endif
322327

tsk/fs/tsk_xfs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ typedef uint64_t XFS_AGNUM_T;
2727
typedef uint32_t xfs_dir2_data_aoff_t; /* argument form */
2828
typedef uint32_t xfs_dir2_dataptr_t;
2929

30-
#define _MSC_VER // Uncomment for MSVC, comment for GCC/Clang
3130
#ifdef _MSC_VER
3231
// For MSVC
3332
#define __round_mask(x, y) ((x) < (y) ? 0 : ((y) - 1))

0 commit comments

Comments
 (0)