Drop dependencies on non-distributable ADL/NVML headers. The needed glue
[hashcat.git] / tools / deps.sh
index f93965a..41a8685 100755 (executable)
@@ -1,10 +1,12 @@
 #!/bin/bash
 # Author: Gabriele Gristina <matrix@hashcat.net>
-# Revision: 1.02
+# Revision: 1.03
 
 ## global vars
-DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip"
-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"
+DEPS="make gcc g++ gcc-multilib g++-multilib libc6-dev-i386 mingw-w64 build-essential unzip opencl-headers ocl-icd-libopencl1 dos2unix"
+DEPS_AMD_DEV="ocl-icd-opencl-dev"
+## Now suppressed: ADL_SDK9.zip gdk_linux_amd64_352_55_release.run
+DOWNLOAD_DEPS="R352-developer.zip"
 
 ## enter the deps directory
 cur_directory=$(dirname ${0})
@@ -15,8 +17,9 @@ mkdir -p ${deps_dir} # but it should already exist (is part of the repository)
 cd ${deps_dir}
 
 ## cleanup the directories under the 'deps' folder
-rm -rf {adl-sdk,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
-mkdir -p {tmp,adl-sdk,NVIDIA-Linux-x86_64-352.21,nvidia-gdk,amd-app-sdk} && \
+rm -rf {adl-sdk*,nvidia-gdk,R352-developer} && \
+#mkdir -p {tmp,adl-sdk,nvidia-gdk,R352-developer} && \
+mkdir -p {tmp,R352-developer} && \
 cd tmp/
 
 if [ $? -ne 0 ]; then
@@ -44,13 +47,7 @@ for pkg in ${DEPS}; do
   # check if the package is already installed
   dpkg -s ${pkg} &>/dev/null
   if [ $? -ne 0 ]; then
-    ## root check
-    if [ $(id -u) -ne 0 ]; then
-      echo "! Must be root to install the required package '${pkg}' with apt-get"
-      exit 1
-    fi
-
-    apt-get -y install ${pkg}
+    sudo apt-get -y install ${pkg}
     if [ $? -ne 0 ]; then
       echo "! failed to install ${pkg}"
       exit 1
@@ -59,20 +56,20 @@ for pkg in ${DEPS}; do
 done
 
 ## extract ADL SDK
-unzip ADL_SDK8.zip -d ${deps_dir}/adl-sdk-8
-ret=$?
-
-if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
-  echo "! failed to extract ADL SDK"
-  exit 1
-fi
-
-rm -rf ${deps_dir}/adl-sdk && ln -s ${deps_dir}/adl-sdk-8 ${deps_dir}/adl-sdk
-
-if [ $? -ne 0 ]; then
-  echo "! failed to setup ADL SDK link"
-  exit 1
-fi
+#unzip ADL_SDK9.zip -d ${deps_dir}/adl-sdk-9
+#ret=$?
+#
+#if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
+#  echo "! failed to extract ADL SDK"
+#  exit 1
+#fi
+#
+#rm -rf ${deps_dir}/adl-sdk && ln -s ${deps_dir}/adl-sdk-9 ${deps_dir}/adl-sdk
+#
+#if [ $? -ne 0 ]; then
+#  echo "! failed to setup ADL SDK link"
+#  exit 1
+#fi
 
 ## extract NVAPI
 unzip R352-developer.zip -d ${deps_dir}
@@ -83,44 +80,25 @@ if [[ ${ret} -ne 0 ]] && [[ ${ret} -ne 1 ]]; then
   exit 1
 fi
 
-## install NVIDIA Driver
-chmod +x NVIDIA-Linux-x86_64-352.21.run && \
-./NVIDIA-Linux-x86_64-352.21.run -x && \
-mv NVIDIA-Linux-x86_64-352.21 ${deps_dir}/ && \
-cd ${deps_dir}/NVIDIA-Linux-x86_64-352.21 && \
-ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
-cd 32 && \
-ln -s libnvidia-ml.so.352.21 libnvidia-ml.so && \
-cd ${deps_dir}/tmp
-
-if [ $? -ne 0 ]; then
-  echo "! failed to install NVIDIA Driver"
-  exit 1
-fi
-
 ## install NVIDIA GPU Deployment Kit
-chmod +x gdk_linux_amd64_352_55_release.run && \
-./gdk_linux_amd64_352_55_release.run --silent --installdir=${deps_dir}/nvidia-gdk
-
-if [ $? -ne 0 ]; then
-  echo "! failed to install NVIDIA GPU Deployment Kit"
-  exit 1
-fi
+#chmod +x gdk_linux_amd64_352_55_release.run && \
+#./gdk_linux_amd64_352_55_release.run --silent --installdir=${deps_dir}/nvidia-gdk
+#
+#if [ $? -ne 0 ]; then
+#  echo "! failed to install NVIDIA GPU Deployment Kit"
+#  exit 1
+#fi
 
-## extract AMD APP SDK
-tar xjf AMD-APP-SDKInstaller-v3.0.130.135-GA-linux64.tar.bz2 && \
-./AMD-APP-SDK-v3.0.130.135-GA-linux64.sh --noexec --target ${deps_dir}/amd-app-sdk-v3.0.130.135
+## check if libOpenCL.so is available (and if not install DEPS_AMD_DEV)
 
-if [ $? -ne 0 ]; then
-  echo "! failed to extract AMD APP SDK"
-  exit 1
-fi
-
-rm -rf ${deps_dir}/amd-app-sdk && ln -s ${deps_dir}/amd-app-sdk-v3.0.130.135 ${deps_dir}/amd-app-sdk
+ls /usr/lib/*/libOpenCL.so &> /dev/null
 
 if [ $? -ne 0 ]; then
-  echo "! failed to setup ADL SDK link"
-  exit 1
+  sudo apt-get -y install ${DEPS_AMD_DEV}
+  if [ $? -ne 0 ]; then
+    echo "! failed to install ${DEPS_AMD_DEV}"
+    exit 1
+  fi
 fi
 
 echo "> oclHashcat dependencies have been resolved."