mirror of
https://github.com/keylase/nvidia-patch.git
synced 2024-11-12 20:58:20 +00:00
linux: make patch invocation idempotent
This commit is contained in:
parent
a82e6112c9
commit
5c2471afb1
27
patch.sh
27
patch.sh
@ -28,14 +28,14 @@ DESCRIPTION
|
|||||||
opmode="patch"
|
opmode="patch"
|
||||||
|
|
||||||
while getopts 'rshc:l' flag; do
|
while getopts 'rshc:l' flag; do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
r) opmode="${opmode}rollback" ;;
|
r) opmode="${opmode}rollback" ;;
|
||||||
s) silent_flag='true' ;;
|
s) silent_flag='true' ;;
|
||||||
h) opmode="${opmode}help" ;;
|
h) opmode="${opmode}help" ;;
|
||||||
c) opmode="${opmode}checkversion" ; checked_version="$OPTARG" ;;
|
c) opmode="${opmode}checkversion" ; checked_version="$OPTARG" ;;
|
||||||
l) opmode="${opmode}listversions" ;;
|
l) opmode="${opmode}listversions" ;;
|
||||||
*) echo "Incorrect option specified in command line" ; exit 2 ;;
|
*) echo "Incorrect option specified in command line" ; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $silent_flag ]]; then
|
if [[ $silent_flag ]]; then
|
||||||
@ -181,8 +181,15 @@ rollback () {
|
|||||||
|
|
||||||
patch () {
|
patch () {
|
||||||
patch_common
|
patch_common
|
||||||
if [[ ! -f "$backup_path/$object.$driver_version" ]]; then
|
if [[ -f "$backup_path/$object.$driver_version" ]]; then
|
||||||
echo "Attention! Backup not found. Copy current $object to backup."
|
bkp_hash="$(sha1sum "$backup_path/$object.$driver_version" | cut -f1 -d\ )"
|
||||||
|
drv_hash="$(sha1sum "$driver_dir/$object.$driver_version" | cut -f1 -d\ )"
|
||||||
|
if [[ "$bkp_hash" != "$drv_hash" ]] ; then
|
||||||
|
echo "Backup exists and driver file differ from backup. Skipping patch."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Attention! Backup not found. Copying current $object to backup."
|
||||||
mkdir -p "$backup_path"
|
mkdir -p "$backup_path"
|
||||||
cp -p "$driver_dir/$object.$driver_version" \
|
cp -p "$driver_dir/$object.$driver_version" \
|
||||||
"$backup_path/$object.$driver_version"
|
"$backup_path/$object.$driver_version"
|
||||||
|
Loading…
Reference in New Issue
Block a user