From 6305298376b3ca28ac3cf6f0fcc14b29f7bef6af Mon Sep 17 00:00:00 2001
From: rishwanth1995 <rishwanthsenthilkumar@hotmail.com>
Date: Tue, 15 May 2018 13:05:04 -0400
Subject: [PATCH] added travis and appveyor files from develop

---
 .travis.yml      |  6 ++---
 appveyor.yml     | 42 +++++++++++++++++++++++++++++++++
 setupDevRepos.py | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
 travis_build.sh  | 27 ++++++++++++++++++++++
 4 files changed, 132 insertions(+), 3 deletions(-)
 create mode 100644 appveyor.yml
 create mode 100644 setupDevRepos.py
 create mode 100755 travis_build.sh

diff --git a/.travis.yml b/.travis.yml
index ff941b912..169af34a7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -16,11 +16,11 @@ matrix:
   - compiler: gcc
     os: osx
 
+python:
+  - "2.7"
 install:
-  - ./install-sleuthkit.sh
+  - ./travis_build.sh
 
 script:
   - make check
   - if test ${TRAVIS_OS_NAME} = "linux"; then cd release; ./release-unix.pl ci; fi
-
-# NOTE: OS X doesn't have ant, so CI fails
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 000000000..0a30f4d27
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,42 @@
+version: 4.6.0.{build}
+
+cache:
+  - C:\Users\appveyor\.ant
+  - C:\ProgramData\chocolatey\bin
+  - C:\ProgramData\chocolatey\lib
+  - C:\libvhdi_64bit
+  - C:\libvmdk_64bit
+  - C:\libewf_64bit
+  - C:\zlib
+branches:
+    only:
+      - develop
+
+image: Visual Studio 2015
+
+
+install:  
+  - ps: choco install ant --ignore-dependencies
+  - ps: $env:Path="C:\Program Files\Java\jdk1.8.0\bin;$($env:Path);C:\ProgramData\chocolatey\lib\ant"
+  - set PATH=C:\Python36-x64\';%PATH%
+environment:
+    global:
+      TSK_HOME: "%APPVEYOR_BUILD_FOLDER%"
+      LIBVHDI_HOME: "C:\\libvhdi_64bit"
+      LIBVMDK_HOME: "C:\\libvmdk_64bit\\libvmdk"
+      LIBEWF_HOME: "C:\\libewf_64bit"
+      POSTGRESQL_HOME_64: "C:\\Program Files\\PostgreSQL\\9.5"
+      PYTHON: "C:\\Python36-x64"
+      JDK_HOME: C:\Program Files\Java\jdk1.8.0
+services:
+      - postgresql95;
+
+build_script:
+      - python setupDevRepos.py
+      - python win32\updateAndBuildAll.py -m 
+      - ps: ant -version
+      - ps: pushd bindings/java
+      - cmd: ant -q dist-PostgreSQL
+      - ps: popd
+
+test: off
diff --git a/setupDevRepos.py b/setupDevRepos.py
new file mode 100644
index 000000000..74c20af70
--- /dev/null
+++ b/setupDevRepos.py
@@ -0,0 +1,60 @@
+# Copyright (c) 2017 Basis Technology.
+#
+# This software is distributed under the Common Public License 1.0
+#
+# This script makes the repositories needed to compile The Sleuth Kit and its dependencies.
+# To use it, first define the needed environment variables (such as LIBEWF_HOME).  This script
+# will then clone the git repositories into those locations.
+
+import os
+import subprocess
+import sys
+
+
+def setupLibrary(path):
+    ''' sets up the library path variable '''
+    git_repository_url = "https://github.com/sleuthkit/"
+    git_zlib_repository_url="https://github.com/madler/"
+    zlib_path = os.path.normpath(os.path.join(path["libewf_64bit"],"zlib"))
+    if not os.path.exists(zlib_path):
+        gitClone(git_zlib_repository_url,"zlib",path["libewf_64bit"])
+    for library,base_library_path in path.items():
+        library_path = os.path.normpath(os.path.join(base_library_path , library))
+        if not os.path.exists(library_path):
+            gitClone(git_repository_url, library, base_library_path)
+
+def gitClone(URL, repo, path):
+    # This method will clone the library if it does not exist
+    cmd = ["git", "clone", URL + repo + ".git" ]
+    ret = subprocess.call(cmd, stdout=sys.stdout, cwd=path)
+    if ret != 0:
+        sys.exit(1)
+
+
+def main():
+    #setting the base directory with the help of library env variables.
+    libewf_home = os.getenv("LIBEWF_HOME")
+    libvhdi_home = os.getenv("LIBVHDI_HOME")
+    libvmdk_home = os.getenv("LIBVMDK_HOME")
+    base_Library_path = {}
+    if(libewf_home != None):
+        base_Library_path["libewf_64bit"] = os.path.dirname(libewf_home)
+    else:
+        print('Please set the env variable LIBEWF_HOME')
+        sys.exit(1)
+
+    if(libvhdi_home != None):
+        base_Library_path["libvhdi_64bit"] = os.path.dirname(libvhdi_home)
+    else:
+        print('Please set the env variable LIBVHDI_HOME')
+        sys.exit(1)
+    if(libvmdk_home != None):
+        base_Library_path["libvmdk_64bit"] = os.path.dirname(os.path.dirname(libvmdk_home))
+    else:
+        print('Please set the env variable LIBVMDK_HOME')
+        sys.exit(1)
+
+    setupLibrary(base_Library_path);
+
+if __name__ == '__main__':
+    main()
diff --git a/travis_build.sh b/travis_build.sh
new file mode 100755
index 000000000..a4b7511b8
--- /dev/null
+++ b/travis_build.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+set -ex
+installLib() {
+	git clone https://github.com/libyal/$1
+	cd $1
+	./synclibs.sh
+	./autogen.sh
+	if test ${TRAVIS_OS_NAME} = "linux"; then
+		./configure -prefix=/usr > /dev/null
+	else
+		./configure > /dev/null
+	fi 
+	make > /dev/null && sudo make install > /dev/null
+	cd ..
+}
+
+if test ${TRAVIS_OS_NAME} = "linux"; then
+	sudo apt-get -qq update
+	sudo apt-get -y install libafflib-dev libewf-dev libpq-dev autopoint libsqlite3-dev ant libcppunit-dev
+elif test ${TRAVIS_OS_NAME} = "osx"; then
+	export PATH=${PATH}:/usr/local/opt/gettext/bin
+	brew install ant libewf gettext
+fi
+installLib libvhdi
+installLib libvmdk
+./bootstrap && ./configure --prefix=/usr && make > /dev/null
+cd bindings/java/ && ant -q dist-PostgreSQL
-- 
GitLab