Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
nvidia-patch
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
nvidia-patch
Commits
98d853cc
Commit
98d853cc
authored
Nov 22, 2019
by
Vladislav Yarmak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autogen: migrate patches one-time script
parent
9a245d3e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
0 deletions
+75
-0
tools/readme-autogen/migrate_patches.py
tools/readme-autogen/migrate_patches.py
+75
-0
No files found.
tools/readme-autogen/migrate_patches.py
0 → 100755
View file @
98d853cc
#!/usr/bin/env python3
import
sys
import
argparse
import
json
import
os.path
import
posixpath
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
from
utils
import
find_driver
,
linux_driver_key
,
windows_driver_key
def
posixpath_components
(
path
):
result
=
[]
while
True
:
head
,
tail
=
posixpath
.
split
(
path
)
if
head
==
path
:
break
result
.
append
(
tail
)
path
=
head
result
.
reverse
()
if
result
and
not
result
[
-
1
]:
result
.
pop
()
return
result
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
)
if
not
os
.
path
.
exists
(
p64_filepath
):
raise
Exception
(
"File
%
s not found!"
%
p64_filepath
)
if
not
os
.
path
.
exists
(
p32_filepath
):
raise
Exception
(
"File
%
s not found!"
%
p32_filepath
)
if
os
.
path
.
getsize
(
p64_filepath
)
==
0
:
raise
Exception
(
"File
%
s empty!"
%
p64_filepath
)
if
os
.
path
.
exists
(
p32_filepath
)
==
0
:
raise
Exception
(
"File
%
s empty!"
%
p32_filepath
)
def
main
():
with
open
(
DATAFILE_PATH
)
as
data_file
:
data
=
json
.
load
(
data_file
)
drivers
=
data
[
OSKind
.
Windows
.
value
][
'x86_64'
][
'drivers'
]
for
d
in
drivers
:
base
,
sep
,
tail
=
d
[
'patch64_url'
]
.
rpartition
(
'/'
)
assert
sep
assert
tail
d
[
'patch64_url'
]
=
base
+
'/'
+
'nvencodeapi64.1337'
d
[
'patch32_url'
]
=
base
+
'/'
+
'nvencodeapi.1337'
d
[
'driver_url'
]
=
d
[
'driver_url'
]
validate_patch
(
d
[
'patch64_url'
],
d
[
'patch32_url'
])
with
open
(
DATAFILE_PATH
,
'w'
)
as
data_file
:
json
.
dump
(
data
,
data_file
,
indent
=
4
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment