Drop dependencies on non-distributable ADL/NVML headers. The needed glue
[hashcat.git] / tools / deps.sh
1 #!/bin/bash
2 # Author: Gabriele Gristina <matrix@hashcat.net>
3 # Revision: 1.03
4
5 ## global vars
6 DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip opencl-headers ocl-icd-libopencl1 dos2unix"
7 DEPS_AMD_DEV="ocl-icd-opencl-dev"
8 ## Now suppressed: ADL_SDK9.zip gdk_linux_amd64_352_55_release.run
9 DOWNLOAD_DEPS="R352-developer.zip"
10
11 ## enter the deps directory
12 cur_directory=$(dirname ${0})
13 script_directory=$(cd ${cur_directory} && pwd -P)
14 deps_dir=${script_directory}/../deps
15
16 mkdir -p ${deps_dir} # but it should already exist (is part of the repository)
17 cd ${deps_dir}
18
19 ## cleanup the directories under the 'deps' folder
20 rm -rf {adl-sdk*,nvidia-gdk,R352-developer} && \
21 #mkdir -p {tmp,adl-sdk,nvidia-gdk,R352-developer} && \
22 mkdir -p {tmp,R352-developer} && \
23 cd tmp/
24
25 if [ $? -ne 0 ]; then
26 echo "! Cannot create deps directories."
27 exit 1
28 fi
29
30 ## check dependencies
31 i=0
32 for d in ${DOWNLOAD_DEPS}; do
33 if [ ! -f "${d}" ]; then
34 echo "! ${d} not found."
35 ((i++))
36 fi
37 done
38
39 if [ ${i} -gt 0 ]; then
40 echo "! Please manually download all the above dependencies to the deps/tmp/ directory"
41 exit 1
42 fi
43
44 ## installing needed packages
45 for pkg in ${DEPS}; do
46
47 # check if the package is already installed
48 dpkg -s ${pkg} &>/dev/null
49 if [ $? -ne 0 ]; then
50 sudo apt-get -y install ${pkg}
51 if [ $? -ne 0 ]; then
52 echo "! failed to install ${pkg}"
53 exit 1
54 fi
55 fi
56 done
57
58 ## extract ADL SDK
59 #unzip ADL_SDK9.zip -d ${deps_dir}/adl-sdk-9
60 #ret=$?
61 #
62 #if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
63 # echo "! failed to extract ADL SDK"
64 # exit 1
65 #fi
66 #
67 #rm -rf ${deps_dir}/adl-sdk && ln -s ${deps_dir}/adl-sdk-9 ${deps_dir}/adl-sdk
68 #
69 #if [ $? -ne 0 ]; then
70 # echo "! failed to setup ADL SDK link"
71 # exit 1
72 #fi
73
74 ## extract NVAPI
75 unzip R352-developer.zip -d ${deps_dir}
76 ret=$?
77
78 if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
79 echo "! failed to extract NVAPI"
80 exit 1
81 fi
82
83 ## install NVIDIA GPU Deployment Kit
84 #chmod +x gdk_linux_amd64_352_55_release.run && \
85 #./gdk_linux_amd64_352_55_release.run --silent --installdir=${deps_dir}/nvidia-gdk
86 #
87 #if [ $? -ne 0 ]; then
88 # echo "! failed to install NVIDIA GPU Deployment Kit"
89 # exit 1
90 #fi
91
92 ## check if libOpenCL.so is available (and if not install DEPS_AMD_DEV)
93
94 ls /usr/lib/*/libOpenCL.so &> /dev/null
95
96 if [ $? -ne 0 ]; then
97 sudo apt-get -y install ${DEPS_AMD_DEV}
98 if [ $? -ne 0 ]; then
99 echo "! failed to install ${DEPS_AMD_DEV}"
100 exit 1
101 fi
102 fi
103
104 echo "> oclHashcat dependencies have been resolved."