diff --git a/scripts/build.sh b/scripts/build.sh index 17c185f..4a758c9 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -477,13 +477,13 @@ update_gapps_zip_name() { fi GAPPS_PATH=$DOWNLOAD_DIR/$GAPPS_ZIP_NAME } -WSA_MAIN_VER=0 +WSA_MAJOR_VER=0 update_ksu_zip_name() { KERNEL_VER="5.15.78.1" - if [ "$WSA_MAIN_VER" -lt "2303" ]; then + if [ "$WSA_MAJOR_VER" -lt "2303" ]; then abort "KernelSU is not supported on WSA version below 2303" fi - if [ "$WSA_MAIN_VER" -ge "2304" ]; then + if [ "$WSA_MAJOR_VER" -ge "2304" ]; then KERNEL_VER="5.15.94.4" fi KERNELSU_ZIP_NAME=kernelsu-$ARCH-$KERNEL_VER.zip @@ -498,9 +498,9 @@ if [ -z ${OFFLINE+x} ]; then # shellcheck disable=SC1090 source "$WSA_WORK_ENV" || abort else - WSA_MAIN_VER=$(python3 getWSAMainVersion.py "$ARCH" "$WSA_ZIP_PATH") + WSA_MAJOR_VER=$(python3 getWSAMainVersion.py "$ARCH" "$WSA_ZIP_PATH") fi - if [[ "$WSA_MAIN_VER" -lt 2211 ]]; then + if [[ "$WSA_MAJOR_VER" -lt 2211 ]]; then ANDROID_API=32 fi if [ "$ROOT_SOL" = "magisk" ] || [ "$GAPPS_BRAND" != "none" ]; then @@ -527,8 +527,8 @@ if [ -z ${OFFLINE+x} ]; then exit 1 fi else # Offline mode - WSA_MAIN_VER=$(python3 getWSAMainVersion.py "$ARCH" "$WSA_ZIP_PATH") - if [[ "$WSA_MAIN_VER" -lt 2211 ]]; then + WSA_MAJOR_VER=$(python3 getWSAMainVersion.py "$ARCH" "$WSA_ZIP_PATH") + if [[ "$WSA_MAJOR_VER" -lt 2211 ]]; then ANDROID_API=32 fi declare -A FILES_CHECK_LIST=([WSA_ZIP_PATH]="$WSA_ZIP_PATH" [xaml_PATH]="$xaml_PATH" [vclibs_PATH]="$vclibs_PATH" [UWPVCLibs_PATH]="$UWPVCLibs_PATH") @@ -639,7 +639,7 @@ if [ "$GAPPS_BRAND" != 'none' ]; then echo -e "Extract done\n" fi -if [[ "$WSA_MAIN_VER" -ge 2302 ]]; then +if [[ "$WSA_MAJOR_VER" -ge 2302 ]]; then echo "Convert vhdx to RAW image" vhdx_to_raw_img "$WORK_DIR/wsa/$ARCH/system_ext.vhdx" "$WORK_DIR/wsa/$ARCH/system_ext.img" || abort vhdx_to_raw_img "$WORK_DIR/wsa/$ARCH/product.vhdx" "$WORK_DIR/wsa/$ARCH/product.img" || abort @@ -648,7 +648,7 @@ if [[ "$WSA_MAIN_VER" -ge 2302 ]]; then echo -e "Convert vhdx to RAW image done\n" fi -if [[ "$WSA_MAIN_VER" -ge 2304 ]]; then +if [[ "$WSA_MAJOR_VER" -ge 2304 ]]; then echo "Mount images" sudo mkdir -p -m 755 "$ROOT_MNT_RO" || abort sudo chown "0:0" "$ROOT_MNT_RO" || abort @@ -664,7 +664,7 @@ if [[ "$WSA_MAIN_VER" -ge 2304 ]]; then mk_overlayfs product "$PRODUCT_MNT_RO" "$PRODUCT_MNT_RW" "$PRODUCT_MNT" || abort mk_overlayfs system_ext "$SYSTEM_EXT_MNT_RO" "$SYSTEM_EXT_MNT_RW" "$SYSTEM_EXT_MNT" || abort echo -e "Create overlayfs for EROFS done\n" -elif [[ "$WSA_MAIN_VER" -ge 2302 ]]; then +elif [[ "$WSA_MAJOR_VER" -ge 2302 ]]; then echo "Remove read-only flag for read-only EXT4 image" ro_ext4_img_to_rw "$WORK_DIR/wsa/$ARCH/system_ext.img" || abort ro_ext4_img_to_rw "$WORK_DIR/wsa/$ARCH/product.img" || abort @@ -672,7 +672,7 @@ elif [[ "$WSA_MAIN_VER" -ge 2302 ]]; then ro_ext4_img_to_rw "$WORK_DIR/wsa/$ARCH/vendor.img" || abort echo -e "Remove read-only flag for read-only EXT4 image done\n" fi -if [[ "$WSA_MAIN_VER" -lt 2304 ]]; then +if [[ "$WSA_MAJOR_VER" -lt 2304 ]]; then echo "Calculate the required space" EXTRA_SIZE=10240 @@ -906,7 +906,7 @@ if [ "$GAPPS_BRAND" != 'none' ]; then fi fi -if [[ "$WSA_MAIN_VER" -ge 2304 ]]; then +if [[ "$WSA_MAJOR_VER" -ge 2304 ]]; then echo "Create EROFS images" mk_erofs_umount "$VENDOR_MNT" "$WORK_DIR/wsa/$ARCH/vendor.img" "$VENDOR_MNT_RW" || abort mk_erofs_umount "$PRODUCT_MNT" "$WORK_DIR/wsa/$ARCH/product.img" "$PRODUCT_MNT_RW" || abort @@ -935,7 +935,7 @@ else echo -e "Shrink images done\n" fi -if [[ "$WSA_MAIN_VER" -ge 2302 ]]; then +if [[ "$WSA_MAJOR_VER" -ge 2302 ]]; then echo "Convert images to vhdx" qemu-img convert -q -f raw -o subformat=fixed -O vhdx "$WORK_DIR/wsa/$ARCH/system_ext.img" "$WORK_DIR/wsa/$ARCH/system_ext.vhdx" || abort qemu-img convert -q -f raw -o subformat=fixed -O vhdx "$WORK_DIR/wsa/$ARCH/product.img" "$WORK_DIR/wsa/$ARCH/product.vhdx" || abort diff --git a/scripts/extractWSA.py b/scripts/extractWSA.py index 2b09d2a..e933383 100644 --- a/scripts/extractWSA.py +++ b/scripts/extractWSA.py @@ -82,13 +82,13 @@ with zipfile.ZipFile(wsa_zip_path) as zip: ver_no = zip_name.split("_") long_ver = ver_no[1] ver = long_ver.split(".") - main_ver = ver[0] + major_ver = ver[0] rel = ver_no[3].split(".") rel_long = str(rel[0]) with open(env_file, 'r') as environ_file: env = Prop(environ_file.read()) env.WSA_VER = long_ver - env.WSA_MAIN_VER = main_ver + env.WSA_MAJOR_VER = major_ver env.WSA_REL = rel_long with open(env_file, 'w') as environ_file: environ_file.write(str(env)) diff --git a/scripts/generateWSALinks.py b/scripts/generateWSALinks.py index f4d059d..7c0fee9 100644 --- a/scripts/generateWSALinks.py +++ b/scripts/generateWSALinks.py @@ -30,6 +30,7 @@ from typing import Any, OrderedDict from xml.dom import minidom from requests import Session +from packaging import version class Prop(OrderedDict): @@ -124,9 +125,10 @@ if not download_dir.is_dir(): download_dir.mkdir() tmpdownlist = open(download_dir/tempScript, 'a') +download_files = {} -def send_req(i, v, out_file, out_file_name): +def send_req(i, v, out_file_name): out = session.post( 'https://fe3.delivery.mp.microsoft.com/ClientWebService/client.asmx/secured', data=FE3_file_content.format(user, i, v, release_type), @@ -136,13 +138,11 @@ def send_req(i, v, out_file, out_file_name): for l in doc.getElementsByTagName("FileLocation"): url = l.getElementsByTagName("Url")[0].firstChild.nodeValue if len(url) != 99: - print(f"download link: {url}\npath: {out_file}\n", flush=True) - tmpdownlist.writelines(url + '\n') - tmpdownlist.writelines(f' dir={download_dir}\n') - tmpdownlist.writelines(f' out={out_file_name}\n') + download_files[out_file_name] = url threads = [] +wsa_build_ver = 0 for filename, values in identities.items(): if re.match(f"Microsoft\.UI\.Xaml\..*_{arch}_.*\.appx", filename): out_file_name = f"{values[1]}_{arch}.appx" @@ -154,24 +154,39 @@ for filename, values in identities.items(): out_file_name = f"{values[1]}_{arch}.appx" out_file = download_dir / out_file_name elif re.match(f"MicrosoftCorporationII\.WindowsSubsystemForAndroid_.*\.msixbundle", filename): - wsa_long_ver = re.search(u'\d{4}.\d{5}.\d{1,}.\d{1,}', filename).group() - print(f'WSA Version={wsa_long_ver}\n', flush=True) - main_ver = wsa_long_ver.split(".")[0] + tmp_wsa_build_ver = re.search(u'\d{4}.\d{5}.\d{1,}.\d{1,}', filename).group() + if(wsa_build_ver == 0): + wsa_build_ver = tmp_wsa_build_ver + else: + if version.parse(wsa_build_ver) < version.parse(tmp_wsa_build_ver): + wsa_build_ver = tmp_wsa_build_ver + else: + continue + version_splited = wsa_build_ver.split(".") + major_ver = version_splited[0] + minor_ver = version_splited[1] + build_ver = version_splited[2] + revision_ver = version_splited[3] with open(os.environ['WSA_WORK_ENV'], 'r') as environ_file: env = Prop(environ_file.read()) - env.WSA_VER = wsa_long_ver - env.WSA_MAIN_VER = main_ver + env.WSA_VER = wsa_build_ver + env.WSA_MAJOR_VER = major_ver with open(os.environ['WSA_WORK_ENV'], 'w') as environ_file: environ_file.write(str(env)) out_file_name = f"wsa-{release_type}.zip" out_file = download_dir / out_file_name else: continue - th = Thread(target=send_req, args=(values[0][0], values[0][1], out_file, out_file_name)) + th = Thread(target=send_req, args=(values[0][0], values[0][1], out_file_name)) threads.append(th) th.daemon = True th.start() for th in threads: th.join() - +print(f'WSA Build Version={wsa_build_ver}\n', flush=True) +for key, value in download_files.items(): + print(f"download link: {value}\npath: {download_dir / key}\n", flush=True) + tmpdownlist.writelines(value + '\n') + tmpdownlist.writelines(f' dir={download_dir}\n') + tmpdownlist.writelines(f' out={key}\n') tmpdownlist.close() diff --git a/scripts/requirements.txt b/scripts/requirements.txt index f229360..64e6ca4 100644 --- a/scripts/requirements.txt +++ b/scripts/requirements.txt @@ -1 +1,2 @@ requests +packaging