diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000000000000000000000000000000000000..019aa5c73e2828eb363d5c4a308b9b074aab84e4 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,39 @@ +version: 4.6.0.{build} + +cache: + - C:\Users\appveyor\.ant -> appveyor.yml + - C:\Users\appveyor\.ivy2 -> appveyor.yml + - C:\ProgramData\chocolatey\bin -> appveyor.yml + - C:\ProgramData\chocolatey\lib -> appveyor.yml + +branches: + only: + - develop + +image: Visual Studio 2015 + + +init: + - 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" +services: + - postgresql95; + +build_script: + - python setupLibs.py + - python %TSK_HOME%\win32\updateBuildLibs.py -m + - ps: ant -version + - ps: pushd bindings/java + - cmd: ant dist-PostgreSQL + - ps: popd + +test: off diff --git a/setupLibs.py b/setupLibs.py new file mode 100644 index 0000000000000000000000000000000000000000..e11adf3464909e747f5d74e5b1c93315aa701c62 --- /dev/null +++ b/setupLibs.py @@ -0,0 +1,57 @@ +# 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/" + 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): + + 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') + + if(libvhdi_home != None): + base_Library_path["libvhdi_64bit"] = os.path.dirname(libvhdi_home) + else: + print('Please set the env variable LIBVHDI_HOME') + + 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') + + + setupLibrary(base_Library_path); + +if __name__ == '__main__': + main() diff --git a/win32/updateBuildLibs.py b/win32/updateBuildLibs.py index 7fdd5f6fb3b0eb2effa44ee132ca243665783f85..442d7163dd206c3082c47a77155ed1d990b42cfd 100644 --- a/win32/updateBuildLibs.py +++ b/win32/updateBuildLibs.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Basis Technology. +# Copyright (c) 2017 Basis Technology. # # This software is distributed under the Common Public License 1.0 @@ -10,6 +10,7 @@ import shutil import subprocess import sys +import getopt from sys import platform as _platform import time @@ -19,7 +20,8 @@ CURRENT_PATH = os.getcwd() # save the build log in the output directory LOG_PATH = os.path.join(CURRENT_PATH, 'output', time.strftime("%Y.%m.%d-%H.%M.%S")) - +APPVEYOR = os.getenv("APPVEYOR",False) +MINIMAL = False def pullAndBuildAllDependencies(branch): ''' Compile libewf, libvhdi, libvmdk. @@ -34,8 +36,7 @@ def pullAndBuildAllDependencies(branch): # get the LIBEWF_HOME, LIBVHDI_HOME, LIBVMDH_HOME ewfHome = os.getenv("LIBEWF_HOME", "C:\\libewf_64bit") vhdiHome = os.getenv("LIBVHDI_HOME", "C:\\libvhdi_64bit") - vmdkHome = os.getenv("LIBVMDK_HOME", "C:\\libvmdk_64bit") - + vmdkHome = os.getenv("LIBVMDK_HOME", "C:\\libvmdk_64bit\\libvmdk") # check if ewfHome, vhdiHome or vmdhHome exits checkPathExist(ewfHome) checkPathExist(vhdiHome) @@ -48,36 +49,40 @@ def pullAndBuildAllDependencies(branch): if(passed): gitPull(vmdkHome, "libvmdk_64bit", branch) - # build 32-bit of libewf, libvhdi, libvmdk and TSK - if(passed): - buildDependentLibs(ewfHome, 32, "libewf") - if(passed): - buildDependentLibs(vhdiHome, 32, "libvhdi") - if(passed): - buildDependentLibs(vmdkHome, 32, "libvmdk") + if not MINIMAL: + # build 32-bit of libewf, libvhdi, libvmdk and TSK + if(passed): + buildDependentLibs(ewfHome, 32, "libewf") + if(passed): + buildDependentLibs(vhdiHome, 32, "libvhdi") + if(passed): + buildDependentLibs(vmdkHome, 32, "libvmdk") - # build 64-bit of libewf, libvhdi, libvmdk and TSK - if(passed): + # build 64-bit of libewf, libvhdi, libvmdk and TSK + if(passed): buildDependentLibs(ewfHome, 64, "libewf") - if(passed): + if(passed): buildDependentLibs(vhdiHome, 64, "libvhdi") - if(passed): + if(passed): buildDependentLibs(vmdkHome, 64, "libvmdk") def buildTSKAll(): - if(passed): - buildTSK(32, "Release") - if(passed): - buildTSK(32, "Release_NoLibs") - if(passed): - buildTSK(32, "Release_PostgreSQL") - if(passed): - buildTSK(64, "Release") - if(passed): - buildTSK(64, "Release_NoLibs") + if not MINIMAL: + if(passed): + buildTSK(32, "Release") + if(passed): + buildTSK(32, "Release_NoLibs") + if(passed): + buildTSK(32, "Release_PostgreSQL") + + if(passed): + buildTSK(64, "Release") + if(passed): + buildTSK(64, "Release_NoLibs") + if(passed): buildTSK(64, "Release_PostgreSQL") @@ -143,7 +148,7 @@ def buildDependentLibs(libHome, wPlatform, targetDll): ''' global passed passed = True - + print("Building " + str(wPlatform) + "-bit " + targetDll) sys.stdout.flush() @@ -151,8 +156,8 @@ def buildDependentLibs(libHome, wPlatform, targetDll): if wPlatform == 64: dllFile = os.path.join(libHome, "msvscpp", "x64", target, targetDll +".dll") - elif wPlatform == 32: - dllFile = os.path.join(libHome, "msvscpp", target, targetDll +".dll") + elif wPlatform == 32: + dllFile = os.path.join(libHome,"msvscpp",target,targetDll + ".dll") else: print("Invalid platform") sys.stdout.flush() @@ -161,8 +166,7 @@ def buildDependentLibs(libHome, wPlatform, targetDll): if (os.path.isfile(dllFile)): os.remove(dllFile) - - os.chdir(os.path.join(libHome, "msvscpp")) + os.chdir(os.path.join(libHome,"msvscpp")) vs = [] vs.append(MSBUILD_PATH) @@ -172,12 +176,13 @@ def buildDependentLibs(libHome, wPlatform, targetDll): vs.append("/p:platform=x64") elif wPlatform == 32: vs.append("/p:platform=Win32") + vs.append("/v:quiet") vs.append("/t:clean") vs.append("/t:build") outputFile = os.path.join(LOG_PATH, targetDll + "Output.txt") VSout = open(outputFile, 'w') - ret = subprocess.call(vs, stdout=VSout) + ret = subprocess.call(vs, stdout=sys.stdout) errorCode = ret VSout.close() if ret > 0: @@ -187,16 +192,16 @@ def buildDependentLibs(libHome, wPlatform, targetDll): errorCode = 0 if errorCode != 0 or not os.path.exists(dllFile) or os.path.getctime(dllFile) < (time.time() - 2 * 60): # the new dll should not be 2 mins old print(targetDll + " " + str(wPlatform) + "-bit C++ failed to build.\n") - print("return code: " + str(ret) + "\tdll file: " + dllFile + "\tcreated time: " + str(os.path.getctime(dllFile))) + print("return code: " + str(ret) + "\tdll file: " + dllFile + "\tcreated time: " + str(os.path.getctime(dllFile))) sys.stdout.flush() passed = False os.chdir(CURRENT_PATH) return else: print("Build " + str(wPlatform) + "-bit " + targetDll + " successfully") - + os.chdir(CURRENT_PATH) - + def buildTSK(wPlatform, target): ''' Build C++ sleuthkit library @@ -205,6 +210,8 @@ def buildTSK(wPlatform, target): print ("Building TSK " + str(wPlatform) + "-bit " + target + " build.") sys.stdout.flush() + if(APPVEYOR): + os.chdir(os.path.join(os.getenv("TSK_HOME"),"win32")) vs = [] vs.append(MSBUILD_PATH) @@ -219,12 +226,13 @@ def buildTSK(wPlatform, target): sys.stdout.flush() passed = False return + vs.append("/v:quiet") vs.append("/t:clean") vs.append("/t:build") outputFile = os.path.join(LOG_PATH, "TSKOutput.txt") VSout = open(outputFile, 'w') - ret = subprocess.call(vs, stdout=VSout) + ret = subprocess.call(vs, stdout=sys.stdout) VSout.close() if ret != 0: print("ret = " + str(ret)) @@ -239,25 +247,38 @@ def usage(): ''' Print out how to use this script. ''' - print('Usage: python3 updataBuildlibs.py [branch]') + print('Usage: python3 updataBuildlibs.py [[-h | --help, -b <branch> | --branch=<branch>, -m | --minimal]') print('branch is which branch to build and is optional. Currently only works for master') + print('-m,--minimal use this option for postgres build') sys.stdout.flush() sys.exit(1) def main(): #by default we use master branch to update the source branch = 'master' - - if len(sys.argv) == 2: #keep this parameter here for the future we may let user use different branch to update source - branch = sys.argv[1] - elif len(sys.argv) > 2: - print('Wrong arguments.') + global MINIMAL + try: + opts, args = getopt.getopt(sys.argv[1:],"mhb:",['help','minimal','branch=']) + except getopt.GetoptError as err: + print(err) usage() + sys.exit(2) + + for o,a in opts: + if o in ("-m","--minimal"): + MINIMAL = True + elif o in ("-b","--branch"): + branch = a + elif o in ("-h","--help"): + usage() + system.exit(2) print('Updating source by %s branch.' % branch) if not os.path.exists(LOG_PATH): os.makedirs(LOG_PATH) - + if not os.path.exists(MSBUILD_PATH): + print("MS_BUILD Does not exist") + sys.stdout.flush() pullAndBuildAllDependencies(branch) buildTSKAll()