autopatch: fix indent for local installer case

Signed-off-by: Jai Luthra <me@jailuthra.in>
This commit is contained in:
Jai Luthra 2023-10-26 15:39:42 +05:30 committed by Jai Luthra
parent bb1d5351d2
commit 9b5c28b29c

View File

@ -238,47 +238,47 @@ def patch_flow(installer_file, search, replacement, target, target_name, patch_n
print(f"Invalid installer file or version: {installer_file}") print(f"Invalid installer file or version: {installer_file}")
return return
# Rest of the code remains the same... # Rest of the code remains the same...
patch = make_patch(installer_file, patch = make_patch(installer_file,
arch_tgt=target, arch_tgt=target,
search=search, search=search,
replacement=replacement, replacement=replacement,
tmpdir=tempdir, tmpdir=tempdir,
sevenzip=sevenzip, sevenzip=sevenzip,
direct=direct) direct=direct)
patch_content = format_patch(patch, target_name) patch_content = format_patch(patch, target_name)
if stdout: if stdout:
sys.stdout.buffer.write(patch_content) sys.stdout.buffer.write(patch_content)
elif direct: elif direct:
with open(patch_name, mode='wb') as out: with open(patch_name, mode='wb') as out:
out.write(patch_content) out.write(patch_content)
else:
version, product_type = identify_driver(installer_file, sevenzip=sevenzip)
drv_prefix = {
"100": "quadro_",
"103": "quadro_",
"300": "",
"301": "nsd_",
"303": "", # DCH
"304": "nsd_",
}
installer_name = os.path.basename(installer_file).lower()
if 'winserv2008' in installer_name or 'winserv-2012' in installer_name:
os_prefix = 'ws2012_x64'
elif 'winserv-2016' in installer_name or 'win10' in installer_name:
os_prefix = 'win10_x64'
elif 'win7' in installer_name:
os_prefix = 'win7_x64'
else: else:
version, product_type = identify_driver(installer_file, sevenzip=sevenzip) raise UnknownPlatformException(f"Can't infer platform from filename {installer_name}")
drv_prefix = {
"100": "quadro_",
"103": "quadro_",
"300": "",
"301": "nsd_",
"303": "", # DCH
"304": "nsd_",
}
installer_name = os.path.basename(installer_file).lower()
if 'winserv2008' in installer_name or 'winserv-2012' in installer_name:
os_prefix = 'ws2012_x64'
elif 'winserv-2016' in installer_name or 'win10' in installer_name:
os_prefix = 'win10_x64'
elif 'win7' in installer_name:
os_prefix = 'win7_x64'
else:
raise UnknownPlatformException(f"Can't infer platform from filename {installer_name}")
driver_name = drv_prefix.get(product_type, "") + version driver_name = drv_prefix.get(product_type, "") + version
out_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', os_prefix, driver_name) out_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..', os_prefix, driver_name)
os.makedirs(out_dir, 0o755, exist_ok=True) os.makedirs(out_dir, 0o755, exist_ok=True)
out_filename = os.path.join(out_dir, patch_name) out_filename = os.path.join(out_dir, patch_name)
with open(out_filename, 'wb') as out: with open(out_filename, 'wb') as out:
out.write(patch_content) out.write(patch_content)
def main(): def main():