Merge branch 'GetRidOfCUDA'
[hashcat.git] / tools / deps.sh
1 #!/bin/bash
2 # Author: Gabriele Gristina <matrix@hashcat.net>
3 # Revision: 1.02
4
5 ## global vars
6 DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip"
7 DOWNLOAD_DEPS="ADL_SDK8.zip R352-developer.zip NVIDIA-Linux-x86_64-352.21.run gdk_linux_amd64_352_55_release.run AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2"
8
9 ## enter the deps directory
10 cur_directory=$(dirname ${0})
11 script_directory=$(cd ${cur_directory} && pwd -P)
12 deps_dir=${script_directory}/../deps
13
14 mkdir -p ${deps_dir} # but it should already exist (is part of the repository)
15 cd ${deps_dir}
16
17 ## cleanup the directories under the 'deps' folder
18 rm -rf {adl-sdk,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
19 mkdir -p {tmp,adl-sdk,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
20 cd tmp/
21
22 if [ $? -ne 0 ]; then
23 echo "! Cannot create deps directories."
24 exit 1
25 fi
26
27 ## check dependencies
28 i=0
29 for d in ${DOWNLOAD_DEPS}; do
30 if [ ! -f "${d}" ]; then
31 echo "! ${d} not found."
32 ((i++))
33 fi
34 done
35
36 if [ ${i} -gt 0 ]; then
37 echo "! Please manually download all the above dependencies to the deps/tmp/ directory"
38 exit 1
39 fi
40
41 ## installing needed packages
42 for pkg in ${DEPS}; do
43
44 # check if the package is already installed
45 dpkg -s ${pkg} &>/dev/null
46 if [ $? -ne 0 ]; then
47 ## root check
48 if [ $(id -u) -ne 0 ]; then
49 echo "! Must be root to install the required package '${pkg}' with apt-get"
50 exit 1
51 fi
52
53 apt-get -y install ${pkg}
54 if [ $? -ne 0 ]; then
55 echo "! failed to install ${pkg}"
56 exit 1
57 fi
58 fi
59 done
60
61 ## extract ADL SDK
62 unzip ADL_SDK8.zip -d ${deps_dir}/adl-sdk-8
63 ret=$?
64
65 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
66 echo "! failed to extract ADL SDK"
67 exit 1
68 fi
69
70 rm -rf ${deps_dir}/adl-sdk && ln -s ${deps_dir}/adl-sdk-8 ${deps_dir}/adl-sdk
71
72 if [ $? -ne 0 ]; then
73 echo "! failed to setup ADL SDK link"
74 exit 1
75 fi
76
77 ## extract NVAPI
78 unzip R352-developer.zip -d ${deps_dir}
79 ret=$?
80
81 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
82 echo "! failed to extract NVAPI"
83 exit 1
84 fi
85
86 ## install NVIDIA Driver
87 chmod +x NVIDIA-Linux-x86_64-352.21.run && \
88 ./NVIDIA-Linux-x86_64-352.21.run -x && \
89 mv NVIDIA-Linux-x86_64-352.21 ${deps_dir}/ && \
90 cd ${deps_dir}/NVIDIA-Linux-x86_64-352.21 && \
91 ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
92 cd 32 && \
93 ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
94 cd ${deps_dir}/tmp
95
96 if [ $? -ne 0 ]; then
97 echo "! failed to install NVIDIA Driver"
98 exit 1
99 fi
100
101 ## install NVIDIA GPU Deployment Kit
102 chmod +x gdk_linux_amd64_352_55_release.run && \
103 ./gdk_linux_amd64_352_55_release.run --silent --installdir=${deps_dir}/nvidia-gdk
104
105 if [ $? -ne 0 ]; then
106 echo "! failed to install NVIDIA GPU Deployment Kit"
107 exit 1
108 fi
109
110 ## extract AMD APP SDK
111 tar xjf AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2 && \
112 ./AMD-APP-SDK-v3.0.130.135-GA-linux64.sh --noexec --target ${deps_dir}/amd-app-sdk-v3.0.130.135
113
114 if [ $? -ne 0 ]; then
115 echo "! failed to extract AMD APP SDK"
116 exit 1
117 fi
118
119 rm -rf ${deps_dir}/amd-app-sdk && ln -s ${deps_dir}/amd-app-sdk-v3.0.130.135 ${deps_dir}/amd-app-sdk
120
121 if [ $? -ne 0 ]; then
122 echo "! failed to setup ADL SDK link"
123 exit 1
124 fi
125
126 echo "> oclHashcat dependencies have been resolved."