From 0ea0e739a28d40f0b89a20df6f4ed2970ad349e2 Mon Sep 17 00:00:00 2001
From: rishwanth <rishwanthsenthilkumar@gmail.com>
Date: Fri, 2 Feb 2018 14:56:23 -0500
Subject: [PATCH] added enable offline functionality in configure

---
 bindings/java/Makefile.am     |  9 ++++++++-
 bindings/java/build.xml       | 25 ++++++++++---------------
 configure.ac                  | 14 +++++++++++++-
 debian/rules                  |  8 ++++++--
 debian/sleuthkit-java.install |  3 +--
 5 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/bindings/java/Makefile.am b/bindings/java/Makefile.am
index f075c9720..b7db5dadc 100644
--- a/bindings/java/Makefile.am
+++ b/bindings/java/Makefile.am
@@ -5,10 +5,17 @@ tsk_jar = $(top_builddir)/bindings/java/dist/sleuthkit-$(PACKAGE_VERSION).jar
 jardir = $(prefix)/share/java
 jar_DATA = $(tsk_jar)
 
+if OFFLINE
+ ant_command=ant dist -Doffline=true
+else
+ ant_command=ant dist
+endif
+
+
 $(tsk_jar):
 
 all-local:
-	ant dist -Donline=false
+	$(ant_command)
 
 CLEANFILES = $(tsk_jar)
 
diff --git a/bindings/java/build.xml b/bindings/java/build.xml
index dcc66c2ee..e87636101 100755
--- a/bindings/java/build.xml
+++ b/bindings/java/build.xml
@@ -11,6 +11,7 @@
 	<import file="build-${os.family}.xml"/>
 
 	<!-- set global properties for this build -->
+	<property name="default-jar-location" location="/usr/share/java"/>
 	<property name="src" location="src/org/sleuthkit/datamodel"/>
 	<property name="VERSION" value="4.6.0"/>
 	<property name="sample" location="src/org/sleuthkit/datamodel/Examples"/>
@@ -63,35 +64,29 @@
 	</target>
 
 	<!-- set classpath for dependencies-->
-	<condition property="online">
-		<http url="https://www.google.com/"/>
-	</condition>
 
 	<target name="set-library-path" description="sets the path of the libraries" depends="set-library-path-online,set-library-path-offline"></target>
 
-	<target name="set-library-path-online" description="set this library path when the user is online" if="online">
+	<target name="set-library-path-online" description="set this library path when the user is online" unless="offline">
 		<path id="libraries">
 			<fileset dir="${lib}">
 				<include name="*.jar"/>
 			</fileset>
 			<pathelement path="${build}"/>
 		</path>
+		<echo message="hey"/>
 	</target>
 
-	<target name="set-library-path-offline" description="set the library path when the user is offline" unless="online">
+	<target name="set-library-path-offline" description="set the library path when the user is offline" if="offline">
 		<path id="libraries">
-			<if>
-				<equals arg1="${os.family}" arg2="unix"/>
-				<then>
-					<pathelement path="${default-jar-location}"/>
-				</then>
-			</if>
+			<fileset dir="${default-jar-location}">
+				<include name="*.jar"/>
+			</fileset>
 			<fileset dir="${lib}">
 				<include name="*.jar"/>
 			</fileset>
 			<pathelement path="${build}"/>
 		</path>
-		<echo message="${online}"/>
 	</target>
 
 	<property name="ivy.install.version" value="2.3.0-rc2"/>
@@ -102,7 +97,7 @@
 	<property name="ivy.jar.dir" value="${ivy.home}/lib"/>
 	<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar"/>
 
-	<target name="download-ivy" if="online">
+	<target name="download-ivy" unless="offline">
 		<available file="${ivy.jar.file}" property="ivy.available"/>
 		<antcall target="-download-ivy"/>
 	</target>
@@ -112,14 +107,14 @@
 		<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar" dest="${ivy.jar.file}" usetimestamp="true"/>
 	</target>
 
-	<target name="init-ivy" depends="download-ivy" unless="ivy.lib.path" if="online">
+	<target name="init-ivy" depends="download-ivy" unless="ivy.lib.path">
 		<path id="ivy.lib.path">
 			<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
 		</path>
 		<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
 	</target>
 
-	<target name="retrieve-deps" description="retrieve dependencies using ivy" depends="init-ivy" if="online">
+	<target name="retrieve-deps" description="retrieve dependencies using ivy" depends="init-ivy" unless="offline">
 		<ivy:settings file="ivysettings.xml"/>
 		<ivy:resolve/>
 		<ivy:retrieve sync="true" pattern="lib/[artifact]-[revision](-[classifier]).[ext]"/>
diff --git a/configure.ac b/configure.ac
index 39e453c6d..51356e14f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,7 +33,6 @@ AC_PROG_LN_S
 AC_PROG_MAKE_SET
 AC_PATH_PROG(PERL, perl)
 
-
 dnl Checks for header files.
 AC_HEADER_STDC
 dnl AC_HEADER_MAJOR
@@ -209,6 +208,19 @@ AC_SUBST(Z_PATH, $Z_PATH)
 dnl needed for sqllite
 AC_CHECK_LIB(dl, dlopen)
 
+dnl check for user online input
+
+AC_ARG_ENABLE([offline],
+    [ AS_HELP_STRING([--enable-offline],[Turn on offline mode])],
+    [case "${enableval}" in
+	yes) offline=true ;;
+	no) offline=false ;;
+	*) AC_MSG_ERROR([bad value ${enableval} for --enable-online]) ;;
+     esac],[offline=false])
+
+AM_CONDITIONAL([OFFLINE], [test "x$offline" = xtrue])
+
+
 dnl Check if we should link libewf.
 AC_ARG_WITH([libewf],
     [AS_HELP_STRING([--without-libewf],[Do not use libewf even if it is installed])]
diff --git a/debian/rules b/debian/rules
index 702b390ce..cfd425ffe 100755
--- a/debian/rules
+++ b/debian/rules
@@ -22,8 +22,12 @@ export DEB_LDFLAGS_MAINT_APPEND = -lsqlite3 -lsupc++ -Wl,--as-needed
 # This is example for Cmake (See https://bugs.debian.org/641051 )
 #override_dh_auto_configure:
 #	dh_auto_configure -- #	-DCMAKE_LIBRARY_PATH=$(DEB_HOST_MULTIARCH)
-	
+
 
 override_dh_auto_install:
-	/bin/bash ./libtool   --mode=install /usr/bin/install -c   /home/rishwanth07/Documents/sleuthkit/tsk/libtsk.la '/home/rishwanth07/Documents/sleuthkit/bindings/java/'
+	cd tsk/
+	sudo make install
+	cd ..
+	cd bindings/java/
+	sudo make install
 	dh_install
diff --git a/debian/sleuthkit-java.install b/debian/sleuthkit-java.install
index 631e7a3fe..67b5aefc5 100644
--- a/debian/sleuthkit-java.install
+++ b/debian/sleuthkit-java.install
@@ -1,5 +1,4 @@
 bindings/java/thirdpartyjars/sqlite-jdbc-3.21.0.1.jar /usr/share/java
 bindings/java/dist/sleuthkit-4.6.0.jar /usr/share/java
-bindings/java/libtsk.so* /usr/lib/
-
+bindings/java/libtsk.so /usr/lib/
 
-- 
GitLab