File: setupDevRepos.py

package info (click to toggle)
sleuthkit 4.6.5-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 39,152 kB
  • sloc: ansic: 171,812; cpp: 44,216; sh: 31,364; java: 17,674; makefile: 1,241; xml: 838; perl: 797; python: 707; sed: 16
file content (60 lines) | stat: -rw-r--r-- 2,172 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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()