From 9117ee91d14a4b12ff3323466d367fc13219e3cd Mon Sep 17 00:00:00 2001 From: Howard20181 <40033067+Howard20181@users.noreply.github.com> Date: Tue, 23 Aug 2022 13:04:16 +0800 Subject: [PATCH] close #28 --- scripts/extractWSA.py | 7 ++----- scripts/run.sh | 36 +++++++++++++++++++----------------- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/scripts/extractWSA.py b/scripts/extractWSA.py index 66b794b..82be3d9 100644 --- a/scripts/extractWSA.py +++ b/scripts/extractWSA.py @@ -25,10 +25,9 @@ with zipfile.ZipFile(Path.cwd().parent / "download/wsa.zip") as zip: if arch in f.filename.lower(): zip_name = f.filename output_name = zip_name[11:-5] - print(output_name) if not os.path.isfile(workdir / zip_name): zip_path = workdir / zip_name - #print(f"unzipping to {workdir}", flush=True) + print(f"unzipping to {workdir}", flush=True) zip.extract(f, workdir) ver_no = zip_name.split("_") long_ver = ver_no[1] @@ -55,7 +54,5 @@ with zipfile.ZipFile(Path.cwd().parent / "download/wsa.zip") as zip: l.extract(g, workdir / 'xml') with zipfile.ZipFile(zip_path) as zip: if not os.path.isdir(workdir / arch): - #print(f"unzipping from {zip_path}", flush=True) + print(f"unzipping from {zip_path}", flush=True) zip.extractall(workdir / arch) - -#print("done", flush=True) diff --git a/scripts/run.sh b/scripts/run.sh index 21210b7..0c95d48 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -147,7 +147,7 @@ else fi clear -echo -e "ARCH=$ARCH\nRELEASE_TYPE=$RELEASE_TYPE\nMAGISK_VER=$MAGISK_VER\nGAPPS_VARIANT=$GAPPS_VARIANT\nREMOVE_AMAZON=$REMOVE_AMAZON\nROOT_SOL=$ROOT_SOL\n" +echo -e "ARCH=$ARCH\nRELEASE_TYPE=$RELEASE_TYPE\nMAGISK_VER=$MAGISK_VER\nGAPPS_VARIANT=$GAPPS_VARIANT\nREMOVE_AMAZON=$REMOVE_AMAZON\nROOT_SOL=$ROOT_SOL\nCOMPRESS_OUTPUT=$COMPRESS_OUTPUT" echo "Download WSA" python3 downloadWSA.py "$ARCH" "$RELEASE_TYPE" || abort @@ -157,7 +157,7 @@ echo "Extract WSA" WSA_WORK_ENV="$WORK_DIR"/ENV if [ -f "$WSA_WORK_ENV" ]; then rm -f "$WSA_WORK_ENV"; fi export WSA_WORK_ENV -BASE_NAME=$(python3 extractWSA.py "$ARCH" "$WORK_DIR") || abort +python3 extractWSA.py "$ARCH" "$WORK_DIR" || abort echo -e "Extract done\n" echo "Download Magisk" @@ -185,37 +185,37 @@ fi echo "Expand images" e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/system_ext.img || abort -SYSTEM_EXT_SIZE=$(($(du -bsB512 "$WORK_DIR"/wsa/"$ARCH"/system_ext.img | cut -f1) + 20000)) +SYSTEM_EXT_SIZE=$(($(du --apparent-size -sB512 "$WORK_DIR"/wsa/"$ARCH"/system_ext.img | cut -f1) + 20000)) if [ -d "$WORK_DIR"/gapps/system_ext ]; then - SYSTEM_EXT_SIZE=$(( SYSTEM_EXT_SIZE + $(du -bsB512 "$WORK_DIR"/gapps/system_ext | cut -f1) )) + SYSTEM_EXT_SIZE=$(( SYSTEM_EXT_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/gapps/system_ext | cut -f1) )) fi resize2fs "$WORK_DIR"/wsa/"$ARCH"/system_ext.img "$SYSTEM_EXT_SIZE"s || abort e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/product.img || abort -PRODUCT_SIZE=$(($(du -bsB512 "$WORK_DIR"/wsa/"$ARCH"/product.img | cut -f1) + 20000)) +PRODUCT_SIZE=$(($(du --apparent-size -sB512 "$WORK_DIR"/wsa/"$ARCH"/product.img | cut -f1) + 20000)) if [ -d "$WORK_DIR"/gapps/product ]; then - PRODUCT_SIZE=$(( PRODUCT_SIZE + $(du -bsB512 "$WORK_DIR"/gapps/product | cut -f1) )) + PRODUCT_SIZE=$(( PRODUCT_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/gapps/product | cut -f1) )) fi resize2fs "$WORK_DIR"/wsa/"$ARCH"/product.img "$PRODUCT_SIZE"s || abort e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/system.img || abort -SYSTEM_SIZE=$(($(du -bsB512 "$WORK_DIR"/wsa/"$ARCH"/system.img | cut -f1) + 20000)) +SYSTEM_SIZE=$(($(du --apparent-size -sB512 "$WORK_DIR"/wsa/"$ARCH"/system.img | cut -f1) + 20000)) if [ -d "$WORK_DIR"/gapps ]; then - SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -bsB512 "$WORK_DIR"/gapps | cut -f1) - $(du -bsB512 "$WORK_DIR"/gapps/product | cut -f1) )) + SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/gapps | cut -f1) - $(du --apparent-size -sB512 "$WORK_DIR"/gapps/product | cut -f1) )) if [ -d "$WORK_DIR"/gapps/system_ext ]; then - SYSTEM_SIZE=$(( SYSTEM_SIZE - $(du -bsB512 "$WORK_DIR"/gapps/system_ext | cut -f1) )) + SYSTEM_SIZE=$(( SYSTEM_SIZE - $(du --apparent-size -sB512 "$WORK_DIR"/gapps/system_ext | cut -f1) )) fi fi if [ -d "$WORK_DIR"/magisk ]; then - SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -bsB512 "$WORK_DIR"/magisk/magisk | cut -f1) )) + SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$WORK_DIR"/magisk/magisk | cut -f1) )) fi if [ -f "$DOWNLOAD_DIR"/magisk.zip ]; then - SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du -bsB512 "$DOWNLOAD_DIR"/magisk.zip | cut -f1) )) + SYSTEM_SIZE=$(( SYSTEM_SIZE + $(du --apparent-size -sB512 "$DOWNLOAD_DIR"/magisk.zip | cut -f1) )) fi resize2fs "$WORK_DIR"/wsa/"$ARCH"/system.img "$SYSTEM_SIZE"s || abort e2fsck -yf "$WORK_DIR"/wsa/"$ARCH"/vendor.img || abort -VENDOR_SIZE=$(($(du -bsB512 "$WORK_DIR"/wsa/"$ARCH"/vendor.img | cut -f1) + 20000)) +VENDOR_SIZE=$(($(du --apparent-size -sB512 "$WORK_DIR"/wsa/"$ARCH"/vendor.img | cut -f1) + 20000)) resize2fs "$WORK_DIR"/wsa/"$ARCH"/vendor.img "$VENDOR_SIZE"s || abort echo -e "Expand images done\n" @@ -541,6 +541,7 @@ EOF echo -e "Remove signature and add scripts done\n" echo "Generate info" +source "$WORK_DIR/ENV" if [[ "$ROOT_SOL" = "none" ]]; then name1="" elif [[ "$ROOT_SOL" = "" ]]; then @@ -556,17 +557,18 @@ else fi name2="-GApps-${GAPPS_VARIANT}" fi -echo "WSA${name1}${name2}_${ARCH}" -cat "$WORK_DIR"/ENV - +artifact_name="WSA${name1}${name2}_${WSA_VER}_${ARCH}_${WSA_REL}" +echo "$artifact_name" echo -e "\nFinishing building...." if [ ! -d "$OUTPUT_DIR" ]; then mkdir "$OUTPUT_DIR" fi if [ "$COMPRESS_OUTPUT" = "yes" ]; then - zip -jrm "$OUTPUT_DIR"/"WSA-GApps-$GAPPS_VARIANT-$BASE_NAME.zip" "$WORK_DIR"/wsa/"$ARCH" || abort + rm -f "$OUTPUT_DIR"/"$artifact_name.7z" + 7z a "$OUTPUT_DIR"/"$artifact_name.7z" "$WORK_DIR/wsa/$ARCH/" || abort elif [ "$COMPRESS_OUTPUT" = "no" ]; then - cp -rf "$WORK_DIR"/wsa/"$ARCH"/* "$OUTPUT_DIR"/"WSA-GApps-$GAPPS_VARIANT-$BASE_NAME" || abort + rm -rf "'$OUTPUT_DIR'/'$artifact_name'" || abort + mv "$WORK_DIR"/wsa/"$ARCH" "$OUTPUT_DIR"/"$artifact_name" || abort fi echo -e "done\n"