# -*- coding: utf-8 -*-
from setuphelpers import *
import waptguihelper
import json
r"""
Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package()
Procedure:
1- Download Windows 10+ FoD/LoF ISO on Microsoft VLSC
2- Run the update_package()
3- Adapt package host capabilities then build-upload the package
"""
def update_package():
# Declaring local variables
capabilities_list = [
"ActiveDirectory",
"BitLocker",
"CertificateServices",
"DHCP",
"DNS",
"FailoverCluster",
"FileServices",
"GroupPolicy",
"IPAM",
"LLDP",
"NetworkController",
"NetworkLoadBalancing",
"RemoteAccess",
"RemoteDesktop",
"ServerManager",
"Shielded",
"StorageMigrationService",
"StorageReplica",
"SystemInsights",
"VolumeActivation",
"WSUS",
]
mandatory_files = ["FoDMetadata_", "Conditions", "Neutral"]
mandatory_capabilities_files = ["~~"]
# default_lang_list = ["fr-fr", "en-us"]
# Interacting differently with Luti
if params.get("running_as_luti"):
latest_bin = "rsat_windows11v24h2_fr-fr.zip"
download_url = "http://srvtemplates.ad.tranquil.it/binary_cache/" + latest_bin
sha256 = "4994f1ccd42243931b7aa0b36cdf1efcbbe71ee44E8fdfb7d8b502af26e90718"
wget(download_url, latest_bin, sha256=sha256)
return "OK"
# Asking for iso path
iso_path = waptguihelper.filename_dialog(
"Please provide the desired FoD iso file for the requested OS Version - %s" % control.package,
"",
"FoD_LoF.ISO",
"ISO Files|*.ISO",
) # os.getcwd()
# iso_path = r"C:\temp\SW_DVD9_Win_11_21H2_x64_MultiLang_LangPackAll_LIP_LoF_X22-62148.ISO"
# Asking for langs
lang_json = waptguihelper.grid_dialog(
"Please selected the desired language(s). You can duplicate lines with CTRL + C, CTRL + V",
json.dumps([{"lang": "en-us"}, {"lang": "fr-fr"}]),
waptguihelper.GRT_SELECTED,
)
lang_list = []
for l in lang_json:
lang_list.append(l["lang"])
if iso_path is None:
error("Please provide an ISO")
# Extract with conditions
conditionnal_include_list = mandatory_capabilities_files + lang_list
rsat_binaries_zip = "rsat_%s_%s.zip" % (basedir.split(os.path.sep)[-1], "_".join(i for i in lang_list))
rsat_binaries_dir = rsat_binaries_zip.split(".")[0]
for d in glob.glob("*rsat_*"):
if isdir(d):
remove_tree(d)
for f in glob.glob("*rsat_*.zip"):
if isfile(f):
remove_tree(f)
if Version(control.min_os_version) >= Version(WindowsVersions.Windows11):
for f in mandatory_files:
unzip_with_7zip(iso_path, rsat_binaries_dir, "**/*%s*.cab".lower() % f, recursive=True)
for f in lang_list:
unzip_with_7zip(iso_path, rsat_binaries_dir, "LanguagesAndOptionalFeatures/**/*%s*.cab".lower() % f, recursive=True)
for fc in conditionnal_include_list:
for cap in capabilities_list:
unzip_with_7zip(iso_path, rsat_binaries_dir, "**/*%s*%s*.cab".lower() % (cap, fc), recursive=True)
else:
for f in mandatory_files:
unzip_with_7zip(iso_path, rsat_binaries_dir, "*%s*.cab".lower() % f, recursive=True)
for f in lang_list:
unzip_with_7zip(iso_path, rsat_binaries_dir, "**/*%s*.cab".lower() % f, recursive=True)
for fc in conditionnal_include_list:
for cap in capabilities_list:
unzip_with_7zip(iso_path, rsat_binaries_dir, "*%s*%s*.cab".lower() % (cap, fc), recursive=True)
print("You may want to create manually a zip called: %s" % rsat_binaries_zip)