Simplification script verifying the driver version on Linux

Change-Id: Ie736c18087ca46fe07b0af4d20d53710af8eb35a
Signed-off-by: Andrzej Koska <andrzej.koska@intel.com>
Related-To: NEO-3732
This commit is contained in:
Andrzej Koska
2019-09-18 14:55:15 +02:00
committed by sys_ocldev
parent efbea1e542
commit 1448f6a312

36
scripts/driver-version.sh Normal file
View File

@ -0,0 +1,36 @@
#!/bin/bash
#
# Copyright (C) 2019 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
DriverVer=$(dpkg -l 'intel-opencl' | awk '/ii intel-opencl / { print $3 }')
if [ -z $DriverVer ]; then
echo No driver detected in the system
exit 1
fi
if [ $# -eq 0 ]; then
echo $DriverVer
exit 1
fi
if [ $# -ne 1 ] || [ $1 == "-h" ] || [ $1 == "--help" ]; then
echo $0 called with no parameters, prints the version of the installed OpenCL driver
echo $0 called with a single parameter containing expected version number,
echo returns success \(0\) if installed the specified driver version or newer
echo returns failure \(1\) if no driver or older than specified
exit 1
fi
DriverStatus=$(! dpkg --compare-versions "$DriverVer" "lt" "$1" ; echo $? )
if [ $DriverStatus -eq 1 ]; then
echo Driver $DriverVer is older than referenced version passed from command line $1
else
echo Driver $DriverVer is newer than or equal to referenced version passed from command line $1
fi
exit $DriverStatus