Skip to content

Commit

Permalink
Always check files
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard20181 committed Feb 9, 2024
1 parent 4f7d3c1 commit f310b75
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 47 deletions.
85 changes: 39 additions & 46 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,27 @@ while [[ $# -gt 0 ]]; do
shift 2
;;
--magisk-custom)
CUSTOM_MAGISK=true
CUSTOM_MAGISK=1
shift
;;
--install-gapps)
HAS_GAPPS=true
HAS_GAPPS=1
shift
;;
--offline)
OFFLINE=true
OFFLINE=1
shift
;;
--skip-download-wsa)
DOWN_WSA="no"
SKIP_DOWN_WSA=1
shift
;;
--help)
usage
exit 0
;;
--debug)
DEBUG=true
DEBUG=1
shift
;;
--)
Expand Down Expand Up @@ -356,18 +356,17 @@ update_ksu_zip_name() {

if [ -z ${OFFLINE+x} ]; then
echo "Generating WSA Download Links"
if [ "$DOWN_WSA" != "no" ]; then
if [ -z ${SKIP_DOWN_WSA+x} ]; then
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort
echo "Downloading WSA"
else
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$DOWN_WSA" || abort
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$SKIP_DOWN_WSA" || abort
echo "Skip download WSA, downloading WSA depends"
fi
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 \
--async-dns=false --check-integrity=true --continue=true --allow-overwrite=true --conditional-get=true \
-d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME"; then
echo "We have encountered an error while downloading files."
exit 1
abort "We have encountered an error while downloading files."
fi
rm -f "${DOWNLOAD_DIR:?}/$DOWNLOAD_CONF_NAME"
fi
Expand All @@ -376,14 +375,13 @@ echo "Extracting WSA"
if [ -f "$WSA_ZIP_PATH" ]; then
if ! python3 extractWSA.py "$ARCH" "$WSA_ZIP_PATH" "$WORK_DIR" "$WSA_WORK_ENV"; then
CLEAN_DOWNLOAD_WSA=1
abort "Unzip WSA failed, is the download incomplete?"
abort "Unzip WSA failed"
fi
echo -e "done\n"
# shellcheck disable=SC1090
source "$WSA_WORK_ENV" || abort
else
echo "The WSA zip package does not exist, is the download incomplete?"
exit 1
abort "The WSA zip package does not exist"
fi
if [[ "$WSA_MAJOR_VER" -lt 2211 ]]; then
ANDROID_API=32
Expand All @@ -407,39 +405,36 @@ if [ -z ${OFFLINE+x} ]; then
update_gapps_file_name
python3 generateGappsLink.py "$ARCH" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$ANDROID_API" "$GAPPS_FILE_NAME" || abort
fi

echo "Downloading Artifacts"
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 \
--async-dns=false --check-integrity=true --continue=true --allow-overwrite=true --conditional-get=true \
-d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME"; then
echo "We have encountered an error while downloading files."
exit 1
fi
else # Offline mode
declare -A FILES_CHECK_LIST=([xaml_PATH]="$xaml_PATH" [vclibs_PATH]="$vclibs_PATH" [UWPVCLibs_PATH]="$UWPVCLibs_PATH")
if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
FILES_CHECK_LIST+=(["MAGISK_PATH"]="$MAGISK_PATH")
fi
if [ "$ROOT_SOL" = "kernelsu" ]; then
update_ksu_zip_name
FILES_CHECK_LIST+=(["KERNELSU_PATH"]="$KERNELSU_PATH")
fi
if [ "$HAS_GAPPS" ]; then
update_gapps_file_name
FILES_CHECK_LIST+=(["GAPPS_PATH"]="$GAPPS_PATH")
fi
for i in "${FILES_CHECK_LIST[@]}"; do
if [ ! -f "$i" ]; then
echo "Offline mode: missing [$i]"
OFFLINE_ERR="1"
if [ -f "$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME" ]; then
echo "Downloading Artifacts"
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 \
--async-dns=false --check-integrity=true --continue=true --allow-overwrite=true --conditional-get=true \
-d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME"; then
abort "We have encountered an error while downloading files."
fi
done
if [ "$OFFLINE_ERR" ]; then
echo "Offline mode: Some files are missing, please disable offline mode"
exit 1
fi
fi

declare -A FILES_CHECK_LIST=([xaml_PATH]="$xaml_PATH" [vclibs_PATH]="$vclibs_PATH" [UWPVCLibs_PATH]="$UWPVCLibs_PATH")
if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
FILES_CHECK_LIST+=(["MAGISK_PATH"]="$MAGISK_PATH")
fi
if [ "$ROOT_SOL" = "kernelsu" ]; then
update_ksu_zip_name
FILES_CHECK_LIST+=(["KERNELSU_PATH"]="$KERNELSU_PATH")
fi
if [ "$HAS_GAPPS" ]; then
update_gapps_file_name
FILES_CHECK_LIST+=(["GAPPS_PATH"]="$GAPPS_PATH")
fi
for i in "${FILES_CHECK_LIST[@]}"; do
if [ ! -f "$i" ]; then
echo "Offline mode: missing [$i]"
FILE_MISSING="1"
fi
done
if [ "$FILE_MISSING" ]; then
abort "Some files are missing"
fi
if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
echo "Extracting Magisk"
if [ -f "$MAGISK_PATH" ]; then
Expand All @@ -456,11 +451,9 @@ if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
fi
chmod +x "$WORK_DIR/magisk/magiskboot" || abort
elif [ -z "${CUSTOM_MAGISK+x}" ]; then
echo "The Magisk zip package does not exist, is the download incomplete?"
exit 1
abort "The Magisk zip package does not exist, is the download incomplete?"
else
echo "The Magisk zip package does not exist, rename it to magisk-debug.zip and put it in the download folder."
exit 1
abort "The Magisk zip package does not exist, rename it to magisk-debug.zip and put it in the download folder."
fi
echo -e "done\n"
fi
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateWSALinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __repr__(self):
"download" if sys.argv[3] == "" else Path(sys.argv[3])
ms_account_conf = download_dir/".ms_account"
tempScript = sys.argv[4]
skip_wsa_download = sys.argv[5] == "no" if len(sys.argv) >= 6 else False
skip_wsa_download = sys.argv[5] == "1" if len(sys.argv) >= 6 else False
cat_id = '858014f3-3934-4abe-8078-4aa193e74ca8'
user = ''
session = Session()
Expand Down

0 comments on commit f310b75

Please sign in to comment.