mirror of
https://github.com/keylase/nvidia-patch.git
synced 2025-08-09 20:14:01 +00:00
add installer downloader by version or url
This commit is contained in:
8
win/tools/autopatch/.gitignore
vendored
8
win/tools/autopatch/.gitignore
vendored
@@ -105,3 +105,11 @@ venv.bak/
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
|
||||
|
||||
# APP
|
||||
# dont commit 7zip files 7z.dll 7z.exe
|
||||
7z.*
|
||||
|
||||
temp
|
||||
!.gitempty
|
@@ -13,6 +13,14 @@ Note: when command line options with multiple possible arguments supplied (like
|
||||
|
||||
* Python 3.2+
|
||||
* 7zip CLI utility
|
||||
* 7z.exe and 7z.dll are required, next to autopatch.py or set path with parameter
|
||||
|
||||
## Examples
|
||||
```
|
||||
python.exe autopatch.py temp/512.95-desktop-win10-win11-64bit-international-dch-whql.exe
|
||||
python.exe autopatch.py https://international.download.nvidia.com/Windows/512.95/512.95-desktop-win10-win11-64bit-international-dch-whql.exe
|
||||
python.exe autopatch.py 512.95
|
||||
```
|
||||
|
||||
## Synopsys
|
||||
|
||||
|
@@ -9,6 +9,7 @@ from binascii import unhexlify
|
||||
import xml.etree.ElementTree as ET
|
||||
import itertools
|
||||
import functools
|
||||
import urllib.request
|
||||
|
||||
|
||||
CRLF = b"\x0d\x0a"
|
||||
@@ -193,6 +194,21 @@ def patch_flow(installer_file, search, replacement, target, target_name, patch_n
|
||||
replacement = unhexlify(replacement)
|
||||
assert len(search) == len(replacement), "len() of search and replacement"\
|
||||
" is not equal"
|
||||
|
||||
# check if installer file exists or try to download
|
||||
if not os.path.isfile(installer_file): #installer file does not exists, get url for download
|
||||
if not installer_file.startswith("http"): #installer_file is a version, parse to url
|
||||
filename = installer_file+"-desktop-win10-win11-64bit-international-dch-whql.exe"
|
||||
installer_file = "https://international.download.nvidia.com/Windows/"+installer_file+"/"+filename
|
||||
else: # installer_file is an url
|
||||
filename = os.path.basename(installer_file)
|
||||
# download installer and save in .temp
|
||||
print(f"Downloading... ( {installer_file} TO {os.path.join('temp', filename)} )")
|
||||
print("This may take a while (~800MB)")
|
||||
urllib.request.urlretrieve(installer_file, os.path.join('temp', filename))
|
||||
installer_file = os.path.join('temp', filename)
|
||||
|
||||
|
||||
patch = make_patch(installer_file,
|
||||
arch_tgt=target,
|
||||
search=search,
|
||||
|
Reference in New Issue
Block a user