mirror of
https://github.com/keylase/nvidia-patch.git
synced 2024-11-09 11:38:21 +00:00
add autopatch for linux drivers
Signed-off-by: Jai Luthra <me@jailuthra.in>
This commit is contained in:
parent
f8461fd699
commit
28798e7f84
30
tools/autopatch/autopatch.sh
Executable file
30
tools/autopatch/autopatch.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
(( $# == 2 )) || {
|
||||
>&2 echo "Usage: $0 <patch-file.sh> <new-version>"
|
||||
exit 2
|
||||
}
|
||||
|
||||
patch_file=$1
|
||||
new_version=$2
|
||||
|
||||
if [[ ! -e $patch_file ]]; then
|
||||
>&2 echo "Patch file $patch_file not found"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# Find the latest patch line
|
||||
latest=$(grep -n "\s.*\[\".*\"\]='.*/g\?'" $patch_file | tail -1)
|
||||
|
||||
# Find the line number to insert at
|
||||
line=$(cut -d : -f 1 <<<"$latest")
|
||||
line=$((line + 1))
|
||||
|
||||
# Use the same bytecode, and escape it
|
||||
bytecode=$(cut -d = -f 2 <<<"$latest")
|
||||
bytecode=$(printf '%s\n' "$bytecode" | sed -e 's/[]\/$*.^[]/\\&/g');
|
||||
|
||||
# Insert bytecode
|
||||
sed -i "${line} i \ \ \ \ [\"${new_version}\"]=${bytecode}" $patch_file
|
Loading…
Reference in New Issue
Block a user