mirror of
https://github.com/keylase/nvidia-patch.git
synced 2025-08-04 09:44:08 +00:00
ipfs: use relative paths in driver database; add customizable repo root to link generator
This commit is contained in:
@@ -9,7 +9,6 @@ from string import Template
|
||||
from itertools import groupby
|
||||
from functools import partial
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
|
||||
from constants import OSKind, Product, WinSeries, DATAFILE_PATH, \
|
||||
DRIVER_URL_TEMPLATE, DRIVER_DIR_PREFIX, BASE_PATH, REPO_BASE
|
||||
@@ -54,13 +53,11 @@ def parse_args():
|
||||
default=WinSeries.win10,
|
||||
help="Windows series")
|
||||
win_opts.add_argument("--patch32",
|
||||
default="https://raw.githubusercontent.com/keylase/"
|
||||
"nvidia-patch/master/win/${winseries}_x64/"
|
||||
default="win/${winseries}_x64/"
|
||||
"${drvprefix}${version}/nvencodeapi.1337",
|
||||
help="template for Windows 32bit patch URL")
|
||||
win_opts.add_argument("--patch64",
|
||||
default="https://raw.githubusercontent.com/keylase/"
|
||||
"nvidia-patch/master/win/${winseries}_x64/"
|
||||
default="win/${winseries}_x64/"
|
||||
"${drvprefix}${version}/nvencodeapi64.1337",
|
||||
help="template for Windows 64bit patch URL")
|
||||
win_opts.add_argument("--skip-patch-check",
|
||||
@@ -97,30 +94,16 @@ def validate_url(url):
|
||||
|
||||
def validate_patch(patch64, patch32):
|
||||
wc_base = os.path.abspath(os.path.join(BASE_PATH, "..", ".."))
|
||||
base_parse = urllib.parse.urlsplit(REPO_BASE, scheme='http')
|
||||
p64_parse = urllib.parse.urlsplit(patch64, scheme='http')
|
||||
p32_parse = urllib.parse.urlsplit(patch32, scheme='http')
|
||||
if not (p64_parse[0] == p32_parse[0] == base_parse[0]):
|
||||
raise Exception("URL scheme doesn't match repo base URL scheme")
|
||||
if not (p64_parse[1] == p32_parse[1] == base_parse[1]):
|
||||
raise Exception("URL network location doesn't match repo base URL network location")
|
||||
if posixpath.commonpath((base_parse[2], p64_parse[2], p32_parse[2])) != \
|
||||
posixpath.commonpath((base_parse[2],)):
|
||||
raise Exception("URL is not subpath of repo base path")
|
||||
p64_posix_relpath = posixpath.relpath(p64_parse[2], base_parse[2])
|
||||
p32_posix_relpath = posixpath.relpath(p32_parse[2], base_parse[2])
|
||||
p64_comp = posixpath_components(p64_posix_relpath)
|
||||
p32_comp = posixpath_components(p32_posix_relpath)
|
||||
p64_filepath = os.path.join(wc_base, *p64_comp)
|
||||
p32_filepath = os.path.join(wc_base, *p32_comp)
|
||||
p64_filepath = os.path.join(wc_base, patch64)
|
||||
p32_filepath = os.path.join(wc_base, patch32)
|
||||
if not os.path.exists(p64_filepath):
|
||||
raise Exception("File %s not found!" % p64_filepath)
|
||||
raise Exception("File %s not found!" % patch64_filepath)
|
||||
if not os.path.exists(p32_filepath):
|
||||
raise Exception("File %s not found!" % p32_filepath)
|
||||
raise Exception("File %s not found!" % patch32_filepath)
|
||||
if os.path.getsize(p64_filepath) == 0:
|
||||
raise Exception("File %s empty!" % p64_filepath)
|
||||
raise Exception("File %s empty!" % patch64_filepath)
|
||||
if os.path.exists(p32_filepath) == 0:
|
||||
raise Exception("File %s empty!" % p32_filepath)
|
||||
raise Exception("File %s empty!" % patch32_filepath)
|
||||
|
||||
def validate_unique(drivers, new_driver, kf):
|
||||
if find_driver(drivers, kf(new_driver), kf) is not None:
|
||||
|
Reference in New Issue
Block a user