Fix build.sh

This commit is contained in:
MCDeltaT 2024-04-03 16:24:15 +01:00
parent 746c2a3ce5
commit 94cd48b086

View File

@ -18,15 +18,7 @@
# Copyright (C) 2024 LSPosed Contributors # Copyright (C) 2024 LSPosed Contributors
# #
if [ ! "$BASH_VERSION" ]; then # shellcheck disable=SC2034
echo "Please do not use sh to run this script, just execute it directly" 1>&2
exit 1
fi
HOST_ARCH=$(uname -m)
if [ "$HOST_ARCH" != "x86_64" ] && [ "$HOST_ARCH" != "aarch64" ]; then
echo "Unsupported architectures: $HOST_ARCH"
exit 1
fi
cd "$(dirname "$0")" || exit 1 cd "$(dirname "$0")" || exit 1
# export TMPDIR=$HOME/.cache/wsa # export TMPDIR=$HOME/.cache/wsa
if [ "$TMPDIR" ] && [ ! -d "$TMPDIR" ]; then if [ "$TMPDIR" ] && [ ! -d "$TMPDIR" ]; then
@ -35,73 +27,31 @@ fi
WORK_DIR=$(mktemp -d -t wsa-build-XXXXXXXXXX_) || exit 1 WORK_DIR=$(mktemp -d -t wsa-build-XXXXXXXXXX_) || exit 1
DOWNLOAD_DIR=../download DOWNLOAD_DIR=../download
DOWNLOAD_WSA_CONF_NAME=wsa.list
DOWNLOAD_CONF_NAME=download.list DOWNLOAD_CONF_NAME=download.list
PYTHON_VENV_DIR="$(dirname "$PWD")/python3-env" PYTHON_VENV_DIR="$(dirname "$PWD")/python3-env"
dir_clean() {
rm -rf "${WORK_DIR:?}"
if [ "$TMPDIR" ] && [ -d "$TMPDIR" ]; then
echo "Cleanup Temp Directory"
rm -rf "${TMPDIR:?}"
unset TMPDIR
fi
rm -f "${DOWNLOAD_DIR:?}/$DOWNLOAD_CONF_NAME"
if [ "$(python3 -c 'import sys ; print( 1 if sys.prefix != sys.base_prefix else 0 )')" = "1" ]; then
echo "deactivate python3 venv"
deactivate
fi
}
trap dir_clean EXIT
OUTPUT_DIR=../output OUTPUT_DIR=../output
WSA_WORK_ENV="${WORK_DIR:?}/ENV" WSA_WORK_ENV="${WORK_DIR:?}/ENV"
if [ -f "$WSA_WORK_ENV" ]; then rm -f "${WSA_WORK_ENV:?}"; fi
touch "$WSA_WORK_ENV" touch "$WSA_WORK_ENV"
export WSA_WORK_ENV export WSA_WORK_ENV
clean_download() {
if [ -d "$DOWNLOAD_DIR" ]; then
echo "Cleanup Download Directory"
if [ "$CLEAN_DOWNLOAD_WSA" ]; then
rm -f "${WSA_ZIP_PATH:?}"
fi
if [ "$CLEAN_DOWNLOAD_MAGISK" ]; then
rm -f "${MAGISK_PATH:?}"
fi
if [ "$CLEAN_DOWNLOAD_GAPPS" ]; then
rm -f "${GAPPS_IMAGE_PATH:?}"
rm -f "${GAPPS_RC_PATH:?}"
fi
if [ "$CLEAN_DOWNLOAD_KERNELSU" ]; then
rm -f "${KERNELSU_PATH:?}"
rm -f "${KERNELSU_INFO:?}"
fi
fi
}
abort() { abort() {
[ "$1" ] && echo -e "ERROR: $1" [ "$1" ] && echo -e "ERROR: $1"
echo "Build: an error has occurred, exit" echo "Build: an error has occurred, exit"
if [ -d "$WORK_DIR" ]; then
echo -e "\nCleanup Work Directory"
dir_clean
fi
clean_download
exit 1 exit 1
} }
trap abort INT TERM trap abort INT TERM
default() { default() {
ARCH=x64 ARCH=x64
# CUSTOM_MODEL=redfin
RELEASE_TYPE=retail RELEASE_TYPE=retail
MAGISK_BRANCH=topjohnwu
MAGISK_VER=stable MAGISK_VER=stable
ROOT_SOL=magisk ROOT_SOL=magisk
COMPRESS_FORMAT=none COMPRESS_FORMAT=none
} }
exit_with_message() {
echo "ERROR: $1"
usage
exit 1
}
ARCH_MAP=( ARCH_MAP=(
"x64" "x64"
"arm64" "arm64"
@ -112,6 +62,13 @@ RELEASE_TYPE_MAP=(
"RP" "RP"
"WIS" "WIS"
"WIF" "WIF"
"latest"
)
MAGISK_BRANCH_MAP=(
"topjohnwu"
"HuskyDG"
"vvb2060"
) )
MAGISK_VER_MAP=( MAGISK_VER_MAP=(
@ -120,8 +77,26 @@ MAGISK_VER_MAP=(
"canary" "canary"
"debug" "debug"
"release" "release"
"delta"
"alpha"
) )
# CUSTOM_MODEL_MAP=(
# "none"
# "sunfish"
# "bramble"
# "redfin"
# "barbet"
# "raven"
# "oriole"
# "bluejay"
# "panther"
# "cheetah"
# "lynx"
# "tangorpro"
# "felix"
# )
ROOT_SOL_MAP=( ROOT_SOL_MAP=(
"magisk" "magisk"
"kernelsu" "kernelsu"
@ -134,72 +109,15 @@ COMPRESS_FORMAT_MAP=(
"none" "none"
) )
ARR_TO_STR() {
local arr=("$@")
local joined
printf -v joined "%s, " "${arr[@]}"
echo "${joined%, }"
}
usage() {
default
echo -e "
Usage:
--arch Architecture of WSA.
Possible values: $(ARR_TO_STR "${ARCH_MAP[@]}")
Default: $ARCH
--release-type Release type of WSA.
RP means Release Preview, WIS means Insider Slow, WIF means Insider Fast.
Possible values: $(ARR_TO_STR "${RELEASE_TYPE_MAP[@]}")
Default: $RELEASE_TYPE
--magisk-ver Magisk version.
Possible values: $(ARR_TO_STR "${MAGISK_VER_MAP[@]}")
Default: $MAGISK_VER
--root-sol Root solution.
\"none\" means no root.
Possible values: $(ARR_TO_STR "${ROOT_SOL_MAP[@]}")
Default: $ROOT_SOL
--compress-format Compress format of output file.
Possible values: $(ARR_TO_STR "${COMPRESS_FORMAT_MAP[@]}")
Default: $COMPRESS_FORMAT
Additional Options:
--offline Build WSA offline
--magisk-custom Install custom Magisk
--skip-download-wsa Skip download WSA
--help Show this help message and exit
Example:
./build.sh --release-type RP --magisk-ver beta
./build.sh --arch arm64 --release-type WIF
./build.sh --release-type WIS
./build.sh --offline --magisk-custom
./build.sh --release-type WIF --magisk-custom --magisk-ver release
"
}
ARGUMENT_LIST=( ARGUMENT_LIST=(
"compress-format:" "compress-format:"
"arch:" "arch:"
"release-type:" "release-type:"
"root-sol:" "root-sol:"
"magisk-branch:"
"magisk-ver:" "magisk-ver:"
"magisk-custom"
"install-gapps" "install-gapps"
"remove-amazon" "remove-amazon"
"offline"
"skip-download-wsa"
"help"
"debug"
) )
default default
@ -210,7 +128,7 @@ opts=$(
--name "$(basename "$0")" \ --name "$(basename "$0")" \
--options "" \ --options "" \
-- "$@" -- "$@"
) || exit_with_message "Failed to parse options, please check your input" ) || abort "Failed to parse options, please check your input"
eval set --"$opts" eval set --"$opts"
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@ -231,14 +149,14 @@ while [[ $# -gt 0 ]]; do
ROOT_SOL="$2" ROOT_SOL="$2"
shift 2 shift 2
;; ;;
--magisk-branch)
MAGISK_BRANCH="$2"
shift 2
;;
--magisk-ver) --magisk-ver)
MAGISK_VER="$2" MAGISK_VER="$2"
shift 2 shift 2
;; ;;
--magisk-custom)
CUSTOM_MAGISK=1
shift
;;
--install-gapps) --install-gapps)
HAS_GAPPS=1 HAS_GAPPS=1
shift shift
@ -247,22 +165,6 @@ while [[ $# -gt 0 ]]; do
REMOVE_AMAZON=1 REMOVE_AMAZON=1
shift shift
;; ;;
--offline)
OFFLINE=1
shift
;;
--skip-download-wsa)
SKIP_DOWN_WSA=1
shift
;;
--help)
usage
exit 0
;;
--debug)
DEBUG=1
shift
;;
--) --)
shift shift
break break
@ -284,7 +186,7 @@ check_list() {
fi fi
((list_count--)) ((list_count--))
if (("$list_count" <= 0)); then if (("$list_count" <= 0)); then
exit_with_message "Invalid $name: $input" abort "Invalid $name: $input"
fi fi
done done
fi fi
@ -292,34 +194,18 @@ check_list() {
check_list "$ARCH" "Architecture" "${ARCH_MAP[@]}" check_list "$ARCH" "Architecture" "${ARCH_MAP[@]}"
check_list "$RELEASE_TYPE" "Release Type" "${RELEASE_TYPE_MAP[@]}" check_list "$RELEASE_TYPE" "Release Type" "${RELEASE_TYPE_MAP[@]}"
check_list "$MAGISK_BRANCH" "Magisk Branch" "${MAGISK_BRANCH_MAP[@]}"
check_list "$MAGISK_VER" "Magisk Version" "${MAGISK_VER_MAP[@]}" check_list "$MAGISK_VER" "Magisk Version" "${MAGISK_VER_MAP[@]}"
check_list "$ROOT_SOL" "Root Solution" "${ROOT_SOL_MAP[@]}" check_list "$ROOT_SOL" "Root Solution" "${ROOT_SOL_MAP[@]}"
# check_list "$CUSTOM_MODEL" "Custom Model" "${CUSTOM_MODEL_MAP[@]}"
check_list "$COMPRESS_FORMAT" "Compress Format" "${COMPRESS_FORMAT_MAP[@]}" check_list "$COMPRESS_FORMAT" "Compress Format" "${COMPRESS_FORMAT_MAP[@]}"
if [ "$DEBUG" ]; then
set -x
fi
if [ "$HAS_GAPPS" ]; then
case "$ROOT_SOL" in
"none")
ROOT_SOL="magisk"
echo "WARN: Force install Magisk since GApps needs it to mount the file"
;;
"kernelsu")
abort "Unsupported combination: Install GApps and KernelSU"
;;
*)
;;
esac
fi
# shellcheck disable=SC1091 # shellcheck disable=SC1091
[ -f "$PYTHON_VENV_DIR/bin/activate" ] && { [ -f "$PYTHON_VENV_DIR/bin/activate" ] && {
source "$PYTHON_VENV_DIR/bin/activate" || abort "Failed to activate virtual environment, please re-run install_deps.sh" source "$PYTHON_VENV_DIR/bin/activate" || abort "Failed to activate virtual environment"
} }
declare -A RELEASE_NAME_MAP=(["retail"]="Retail" ["RP"]="Release Preview" ["WIS"]="Insider Slow" ["WIF"]="Insider Fast") declare -A RELEASE_NAME_MAP=(["retail"]="Retail" ["latest"]="Insider Private" ["RP"]="Release Preview" ["WIS"]="Insider Slow" ["WIF"]="Insider Fast")
declare -A ANDROID_API_MAP=(["30"]="11.0" ["32"]="12.1" ["33"]="13.0") declare -A ANDROID_API_MAP=(["33"]="13.0" ["34"]="14.0")
declare -A ARCH_NAME_MAP=(["x64"]="x86_64" ["arm64"]="arm64") declare -A ARCH_NAME_MAP=(["x64"]="x86_64" ["arm64"]="arm64")
RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort
echo -e "INFO: Release Name: $RELEASE_NAME\n" echo -e "INFO: Release Name: $RELEASE_NAME\n"
@ -330,17 +216,6 @@ xaml_PATH="$DOWNLOAD_DIR/Microsoft.UI.Xaml.2.8_$ARCH.appx"
MAGISK_ZIP=magisk-$MAGISK_VER.zip MAGISK_ZIP=magisk-$MAGISK_VER.zip
MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP
CUST_PATH="$DOWNLOAD_DIR/cust.img" CUST_PATH="$DOWNLOAD_DIR/cust.img"
if [ "$CUSTOM_MAGISK" ]; then
if [ ! -f "$MAGISK_PATH" ]; then
echo "Custom Magisk $MAGISK_ZIP not found"
MAGISK_ZIP=app-$MAGISK_VER.apk
echo -e "Fallback to $MAGISK_ZIP\n"
MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP
if [ ! -f "$MAGISK_PATH" ]; then
abort "Custom Magisk $MAGISK_ZIP not found\nPlease put custom Magisk in $DOWNLOAD_DIR"
fi
fi
fi
ANDROID_API=33 ANDROID_API=33
update_gapps_files_name() { update_gapps_files_name() {
GAPPS_IMAGE_NAME=gapps-${ANDROID_API_MAP[$ANDROID_API]}-${ARCH_NAME_MAP[$ARCH]}.img GAPPS_IMAGE_NAME=gapps-${ANDROID_API_MAP[$ANDROID_API]}-${ARCH_NAME_MAP[$ARCH]}.img
@ -375,30 +250,33 @@ update_ksu_zip_name() {
fi fi
KERNELSU_ZIP_NAME=kernelsu-$ARCH-$KERNEL_VER.zip KERNELSU_ZIP_NAME=kernelsu-$ARCH-$KERNEL_VER.zip
KERNELSU_PATH=$DOWNLOAD_DIR/$KERNELSU_ZIP_NAME KERNELSU_PATH=$DOWNLOAD_DIR/$KERNELSU_ZIP_NAME
KERNELSU_APK_PATH=$DOWNLOAD_DIR/KernelSU.apk
KERNELSU_INFO="$KERNELSU_PATH.info" KERNELSU_INFO="$KERNELSU_PATH.info"
} }
if [ -z ${OFFLINE+x} ]; then echo "Generating WSA Download Links"
echo "Generating WSA Download Links" python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_WSA_CONF_NAME" || abort
if [ -z ${SKIP_DOWN_WSA+x} ]; then
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort if [ "$RELEASE_TYPE" == "latest" ]; then
echo "Downloading WSA" printf "%s\n" "$(curl -sL https://api.github.com/repos/bubbles-wow/WSA-Archive/releases/latest | jq -r '.assets[] | .browser_download_url')" >> "$DOWNLOAD_DIR/$DOWNLOAD_WSA_CONF_NAME" || abort
else printf " dir=%s\n" "$DOWNLOAD_DIR" >> "$DOWNLOAD_DIR/$DOWNLOAD_WSA_CONF_NAME" || abort
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$SKIP_DOWN_WSA" || abort printf " out=wsa-latest.zip\n" >> "$DOWNLOAD_DIR/$DOWNLOAD_WSA_CONF_NAME" || abort
echo "Skip download WSA, downloading WSA depends" WSA_VER=$(curl -sL https://api.github.com/repos/bubbles-wow/WSA-Archive/releases/latest | jq -r '.tag_name')
fi WSA_MAJOR_VER=${WSA_VER:0:4}
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 \ else
--async-dns=false --check-integrity=true --continue=true --allow-overwrite=true --conditional-get=true \ # shellcheck disable=SC1090
-d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME"; then source "$WSA_WORK_ENV" || abort
fi
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j7 -m0 \
--async-dns=false --check-integrity=true \
-d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_WSA_CONF_NAME"; then
abort "We have encountered an error while downloading files." abort "We have encountered an error while downloading files."
fi
rm -f "${DOWNLOAD_DIR:?}/$DOWNLOAD_CONF_NAME"
fi fi
echo "Extracting WSA" echo "Extracting WSA"
if [ -f "$WSA_ZIP_PATH" ]; then if [ -f "$WSA_ZIP_PATH" ]; then
if ! python3 extractWSA.py "$ARCH" "$WSA_ZIP_PATH" "$WORK_DIR" "$WSA_WORK_ENV"; then if ! python3 extractWSA.py "$ARCH" "$WSA_ZIP_PATH" "$WORK_DIR" "$WSA_WORK_ENV"; then
CLEAN_DOWNLOAD_WSA=1
abort "Unzip WSA failed" abort "Unzip WSA failed"
fi fi
echo -e "done\n" echo -e "done\n"
@ -407,39 +285,35 @@ if [ -f "$WSA_ZIP_PATH" ]; then
else else
abort "The WSA zip package does not exist" abort "The WSA zip package does not exist"
fi fi
if [[ "$WSA_MAJOR_VER" -lt 2211 ]]; then
ANDROID_API=32 echo "Generating Download Links"
if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
python3 generateMagiskLink.py "$MAGISK_BRANCH" "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort
fi fi
if [ -z ${OFFLINE+x} ]; then
echo "Generating Download Links" if [ "$ROOT_SOL" = "kernelsu" ]; then
if [ "$ROOT_SOL" = "magisk" ]; then
if [ -z ${CUSTOM_MAGISK+x} ]; then
python3 generateMagiskLink.py "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort
fi
fi
if [ "$ROOT_SOL" = "kernelsu" ]; then
update_ksu_zip_name update_ksu_zip_name
python3 generateKernelSULink.py "$ARCH" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$KERNEL_VER" "$KERNELSU_ZIP_NAME" || abort python3 generateKernelSULink.py "$ARCH" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$KERNEL_VER" "$KERNELSU_ZIP_NAME" || abort
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "$WSA_WORK_ENV" || abort source "$WSA_WORK_ENV" || abort
# shellcheck disable=SC2153 # shellcheck disable=SC2153
echo "KERNELSU_VER=$KERNELSU_VER" >"$KERNELSU_INFO" echo "KERNELSU_VER=$KERNELSU_VER" >"$KERNELSU_INFO"
fi fi
if [ "$HAS_GAPPS" ]; then if [ "$HAS_GAPPS" ]; then
update_gapps_files_name update_gapps_files_name
python3 generateGappsLink.py "$ARCH" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$ANDROID_API" "$GAPPS_IMAGE_NAME" || abort python3 generateGappsLink.py "$ARCH" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$ANDROID_API" "$GAPPS_IMAGE_NAME" || abort
fi fi
if [ -f "$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME" ]; then if [ -f "$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME" ]; then
echo "Downloading Artifacts" echo "Downloading Artifacts"
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j5 -c -R -m0 \ if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j7 -m0 \
--async-dns=false --check-integrity=true --continue=true --allow-overwrite=true --conditional-get=true \ --async-dns=false --check-integrity=true \
-d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME"; then -d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME"; then
abort "We have encountered an error while downloading files." abort "We have encountered an error while downloading files."
fi fi
fi
fi fi
declare -A FILES_CHECK_LIST=([xaml_PATH]="$xaml_PATH" [vclibs_PATH]="$vclibs_PATH" [UWPVCLibs_PATH]="$UWPVCLibs_PATH") declare -A FILES_CHECK_LIST=([xaml_PATH]="$xaml_PATH" [vclibs_PATH]="$vclibs_PATH" [UWPVCLibs_PATH]="$UWPVCLibs_PATH")
if [ "$ROOT_SOL" = "magisk" ]; then if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
FILES_CHECK_LIST+=(["MAGISK_PATH"]="$MAGISK_PATH" ["CUST_PATH"]="$CUST_PATH") FILES_CHECK_LIST+=(["MAGISK_PATH"]="$MAGISK_PATH" ["CUST_PATH"]="$CUST_PATH")
fi fi
if [ "$ROOT_SOL" = "kernelsu" ]; then if [ "$ROOT_SOL" = "kernelsu" ]; then
@ -459,30 +333,24 @@ done
if [ "$FILE_MISSING" ]; then if [ "$FILE_MISSING" ]; then
abort "Some files are missing" abort "Some files are missing"
fi fi
if [ "$ROOT_SOL" = "magisk" ]; then if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
echo "Extracting Magisk" echo "Extracting Magisk"
if [ -f "$MAGISK_PATH" ]; then if [ -f "$MAGISK_PATH" ]; then
MAGISK_VERSION_NAME="" MAGISK_VERSION_NAME=""
MAGISK_VERSION_CODE=0 MAGISK_VERSION_CODE=0
if ! python3 extractMagisk.py "$ARCH" "$MAGISK_PATH" "$WORK_DIR"; then if ! python3 extractMagisk.py "$ARCH" "$MAGISK_PATH" "$WORK_DIR"; then
CLEAN_DOWNLOAD_MAGISK=1
abort "Unzip Magisk failed, is the download incomplete?" abort "Unzip Magisk failed, is the download incomplete?"
fi fi
# shellcheck disable=SC1090 # shellcheck disable=SC1090
source "$WSA_WORK_ENV" || abort source "$WSA_WORK_ENV" || abort
if [ "$MAGISK_VERSION_CODE" -lt 26000 ] && [ "$MAGISK_VER" != "stable" ] && [ -z ${CUSTOM_MAGISK+x} ]; then
abort "Please install Magisk 26.0+"
fi
chmod +x "$WORK_DIR/magisk/magiskboot" || abort chmod +x "$WORK_DIR/magisk/magiskboot" || abort
elif [ -z "${CUSTOM_MAGISK+x}" ]; then
abort "The Magisk zip package does not exist, is the download incomplete?"
else else
abort "The Magisk zip package does not exist, rename it to magisk-debug.zip and put it in the download folder." abort "The Magisk zip package does not exist, rename it to magisk-debug.zip and put it in the download folder."
fi fi
echo -e "done\n" echo -e "done\n"
fi fi
if [ "$ROOT_SOL" = "magisk" ]; then if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
echo "Integrating Magisk" echo "Integrating Magisk"
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk64" "$WORK_DIR/magisk/magisk64.xz" "$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk64" "$WORK_DIR/magisk/magisk64.xz"
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk32" "$WORK_DIR/magisk/magisk32.xz" "$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk32" "$WORK_DIR/magisk/magisk32.xz"
@ -509,7 +377,6 @@ elif [ "$ROOT_SOL" = "kernelsu" ]; then
echo "WSA Kernel Version: $KERNEL_VER" echo "WSA Kernel Version: $KERNEL_VER"
echo "KernelSU Version: $KERNELSU_VER" echo "KernelSU Version: $KERNELSU_VER"
if ! unzip "$KERNELSU_PATH" -d "$WORK_DIR/kernelsu"; then if ! unzip "$KERNELSU_PATH" -d "$WORK_DIR/kernelsu"; then
CLEAN_DOWNLOAD_KERNELSU=1
abort "Unzip KernelSU failed, package is corrupted?" abort "Unzip KernelSU failed, package is corrupted?"
fi fi
if [ "$ARCH" = "x64" ]; then if [ "$ARCH" = "x64" ]; then
@ -545,12 +412,467 @@ echo "Removing signature and add scripts"
rm -rf "${WORK_DIR:?}"/wsa/"$ARCH"/\[Content_Types\].xml "$WORK_DIR/wsa/$ARCH/AppxBlockMap.xml" "$WORK_DIR/wsa/$ARCH/AppxSignature.p7x" "$WORK_DIR/wsa/$ARCH/AppxMetadata" || abort rm -rf "${WORK_DIR:?}"/wsa/"$ARCH"/\[Content_Types\].xml "$WORK_DIR/wsa/$ARCH/AppxBlockMap.xml" "$WORK_DIR/wsa/$ARCH/AppxSignature.p7x" "$WORK_DIR/wsa/$ARCH/AppxMetadata" || abort
cp "$vclibs_PATH" "$xaml_PATH" "$WORK_DIR/wsa/$ARCH" || abort cp "$vclibs_PATH" "$xaml_PATH" "$WORK_DIR/wsa/$ARCH" || abort
cp "$UWPVCLibs_PATH" "$xaml_PATH" "$WORK_DIR/wsa/$ARCH" || abort cp "$UWPVCLibs_PATH" "$xaml_PATH" "$WORK_DIR/wsa/$ARCH" || abort
cp "../bin/$ARCH/makepri.exe" "$WORK_DIR/wsa/$ARCH" || abort
cp "../xml/priconfig.xml" "$WORK_DIR/wsa/$ARCH/xml/" || abort cp "../xml/priconfig.xml" "$WORK_DIR/wsa/$ARCH/xml/" || abort
cp ../installer/MakePri.ps1 "$WORK_DIR/wsa/$ARCH" || abort cp "../installer/$ARCH/MakePri.ps1" "$WORK_DIR/wsa/$ARCH" || abort
cp ../installer/Install.ps1 "$WORK_DIR/wsa/$ARCH" || abort cp "../installer/$ARCH/Install.ps1" "$WORK_DIR/wsa/$ARCH" || abort
cp ../installer/Run.bat "$WORK_DIR/wsa/$ARCH" || abort cp "../installer/Run.bat" "$WORK_DIR/wsa/$ARCH" || abort
find "$WORK_DIR/wsa/$ARCH" -maxdepth 1 -mindepth 1 -printf "%P\n" >"$WORK_DIR/wsa/$ARCH/filelist.txt" || abort find "$WORK_DIR/wsa/$ARCH" -maxdepth 1 -mindepth 1 -printf "%P\n" >"$WORK_DIR/wsa/$ARCH/filelist.txt" || abort
find "$WORK_DIR/wsa/$ARCH/pri" -printf "%P\n" | sed -e 's/^/pri\\/' -e '/^$/d' > "$WORK_DIR/wsa/$ARCH/filelist-pri.txt" || abort
find "$WORK_DIR/wsa/$ARCH/xml" -printf "%P\n" | sed -e 's/^/xml\\/' -e '/^$/d' >> "$WORK_DIR/wsa/$ARCH/filelist-pri.txt" || abort
echo -e "done\n"
if [[ "$ROOT_SOL" = "none" ]]; then
name1=""
elif [ "$ROOT_SOL" = "magisk" ]; then
name1="-with-magisk-$MAGISK_VERSION_NAME($MAGISK_VERSION_CODE)-$MAGISK_VER"
elif [ "$ROOT_SOL" = "kernelsu" ]; then
name1="-with-$ROOT_SOL-$KERNELSU_VER"
fi
if [ -z "$HAS_GAPPS" ]; then
name2="-NoGApps"
else
name2=-GApps-${ANDROID_API_MAP[$ANDROID_API]}
fi
#if [[ "$MODEL_NAME" != "default" ]]; then
# name3="-as-$MODEL_NAME"
#fi
artifact_name=WSA_${WSA_VER}_${ARCH}_${WSA_REL}${name1}${name2}
#${name3}
short_artifact_name=WSA_${WSA_VER}_${ARCH}
[ "$REMOVE_AMAZON" ] && artifact_name+=-NoAmazon
if [ ! -d "$OUTPUT_DIR" ]; then
mkdir -p "$OUTPUT_DIR"
fi
OUTPUT_PATH="${OUTPUT_DIR:?}/$short_artifact_name"
mv "$WORK_DIR/wsa/$ARCH" "$OUTPUT_PATH"
{
echo "artifact_folder=${short_artifact_name}"
echo "artifact=${artifact_name}"
echo "arch=${ARCH}"
echo "built=$(date -u +%Y%m%d%H%M%S)"
echo "file_ext=${COMPRESS_FORMAT}"
} >> "$GITHUB_OUTPUT"#!/bin/bash
#
# This file is part of MagiskOnWSALocal.
#
# MagiskOnWSALocal is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# MagiskOnWSALocal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with MagiskOnWSALocal. If not, see <https://www.gnu.org/licenses/>.
#
# Copyright (C) 2024 LSPosed Contributors
#
# shellcheck disable=SC2034
cd "$(dirname "$0")" || exit 1
# export TMPDIR=$HOME/.cache/wsa
if [ "$TMPDIR" ] && [ ! -d "$TMPDIR" ]; then
mkdir -p "$TMPDIR"
fi
WORK_DIR=$(mktemp -d -t wsa-build-XXXXXXXXXX_) || exit 1
DOWNLOAD_DIR=../download
DOWNLOAD_WSA_CONF_NAME=wsa.list
DOWNLOAD_CONF_NAME=download.list
PYTHON_VENV_DIR="$(dirname "$PWD")/python3-env"
OUTPUT_DIR=../output
WSA_WORK_ENV="${WORK_DIR:?}/ENV"
touch "$WSA_WORK_ENV"
export WSA_WORK_ENV
abort() {
[ "$1" ] && echo -e "ERROR: $1"
echo "Build: an error has occurred, exit"
exit 1
}
trap abort INT TERM
default() {
ARCH=x64
# CUSTOM_MODEL=redfin
RELEASE_TYPE=retail
MAGISK_BRANCH=topjohnwu
MAGISK_VER=stable
ROOT_SOL=magisk
COMPRESS_FORMAT=none
}
ARCH_MAP=(
"x64"
"arm64"
)
RELEASE_TYPE_MAP=(
"retail"
"RP"
"WIS"
"WIF"
"latest"
)
MAGISK_BRANCH_MAP=(
"topjohnwu"
"HuskyDG"
"vvb2060"
)
MAGISK_VER_MAP=(
"stable"
"beta"
"canary"
"debug"
"release"
"delta"
"alpha"
)
# CUSTOM_MODEL_MAP=(
# "none"
# "sunfish"
# "bramble"
# "redfin"
# "barbet"
# "raven"
# "oriole"
# "bluejay"
# "panther"
# "cheetah"
# "lynx"
# "tangorpro"
# "felix"
# )
ROOT_SOL_MAP=(
"magisk"
"kernelsu"
"none"
)
COMPRESS_FORMAT_MAP=(
"7z"
"zip"
"none"
)
ARGUMENT_LIST=(
"compress-format:"
"arch:"
"release-type:"
"root-sol:"
"magisk-branch:"
"magisk-ver:"
"install-gapps"
"remove-amazon"
)
default
opts=$(
getopt \
--longoptions "$(printf "%s," "${ARGUMENT_LIST[@]}")" \
--name "$(basename "$0")" \
--options "" \
-- "$@"
) || abort "Failed to parse options, please check your input"
eval set --"$opts"
while [[ $# -gt 0 ]]; do
case "$1" in
--compress-format)
COMPRESS_FORMAT="$2"
shift 2
;;
--arch)
ARCH="$2"
shift 2
;;
--release-type)
RELEASE_TYPE="$2"
shift 2
;;
--root-sol)
ROOT_SOL="$2"
shift 2
;;
--magisk-branch)
MAGISK_BRANCH="$2"
shift 2
;;
--magisk-ver)
MAGISK_VER="$2"
shift 2
;;
--install-gapps)
HAS_GAPPS=1
shift
;;
--remove-amazon)
REMOVE_AMAZON=1
shift
;;
--)
shift
break
;;
esac
done
check_list() {
local input=$1
if [ -n "$input" ]; then
local name=$2
shift
local arr=("$@")
local list_count=${#arr[@]}
for i in "${arr[@]}"; do
if [ "$input" == "$i" ]; then
echo "INFO: $name: $input"
break
fi
((list_count--))
if (("$list_count" <= 0)); then
abort "Invalid $name: $input"
fi
done
fi
}
check_list "$ARCH" "Architecture" "${ARCH_MAP[@]}"
check_list "$RELEASE_TYPE" "Release Type" "${RELEASE_TYPE_MAP[@]}"
check_list "$MAGISK_BRANCH" "Magisk Branch" "${MAGISK_BRANCH_MAP[@]}"
check_list "$MAGISK_VER" "Magisk Version" "${MAGISK_VER_MAP[@]}"
check_list "$ROOT_SOL" "Root Solution" "${ROOT_SOL_MAP[@]}"
# check_list "$CUSTOM_MODEL" "Custom Model" "${CUSTOM_MODEL_MAP[@]}"
check_list "$COMPRESS_FORMAT" "Compress Format" "${COMPRESS_FORMAT_MAP[@]}"
# shellcheck disable=SC1091
[ -f "$PYTHON_VENV_DIR/bin/activate" ] && {
source "$PYTHON_VENV_DIR/bin/activate" || abort "Failed to activate virtual environment"
}
declare -A RELEASE_NAME_MAP=(["retail"]="Retail" ["latest"]="Insider Private" ["RP"]="Release Preview" ["WIS"]="Insider Slow" ["WIF"]="Insider Fast")
declare -A ANDROID_API_MAP=(["33"]="13.0" ["34"]="14.0")
declare -A ARCH_NAME_MAP=(["x64"]="x86_64" ["arm64"]="arm64")
RELEASE_NAME=${RELEASE_NAME_MAP[$RELEASE_TYPE]} || abort
echo -e "INFO: Release Name: $RELEASE_NAME\n"
WSA_ZIP_PATH=$DOWNLOAD_DIR/wsa-$RELEASE_TYPE.zip
vclibs_PATH="$DOWNLOAD_DIR/Microsoft.VCLibs.140.00_$ARCH.appx"
UWPVCLibs_PATH="$DOWNLOAD_DIR/Microsoft.VCLibs.140.00.UWPDesktop_$ARCH.appx"
xaml_PATH="$DOWNLOAD_DIR/Microsoft.UI.Xaml.2.8_$ARCH.appx"
MAGISK_ZIP=magisk-$MAGISK_VER.zip
MAGISK_PATH=$DOWNLOAD_DIR/$MAGISK_ZIP
CUST_PATH="$DOWNLOAD_DIR/cust.img"
ANDROID_API=33
update_gapps_files_name() {
GAPPS_IMAGE_NAME=gapps-${ANDROID_API_MAP[$ANDROID_API]}-${ARCH_NAME_MAP[$ARCH]}.img
GAPPS_RC_NAME=gapps-${ANDROID_API_MAP[$ANDROID_API]}.rc
GAPPS_IMAGE_PATH=$DOWNLOAD_DIR/$GAPPS_IMAGE_NAME
GAPPS_RC_PATH=$DOWNLOAD_DIR/$GAPPS_RC_NAME
}
WSA_MAJOR_VER=0
getKernelVersion() {
local bintype kernel_string kernel_version
bintype="$(file -b "$1")"
if [[ $bintype == *"version"* ]]; then
readarray -td '' kernel_string < <(awk '{ gsub(/, /,"\0"); print; }' <<<"$bintype, ")
unset 'kernel_string[-1]'
for i in "${kernel_string[@]}"; do
if [[ $i == *"version"* ]]; then
IFS=" " read -r -a kernel_string <<<"$i"
kernel_version="${kernel_string[1]}"
fi
done
else
IFS=" " read -r -a kernel_string <<<"$(strings "$1" | grep 'Linux version')"
kernel_version="${kernel_string[2]}"
fi
IFS=" " read -r -a arr <<<"${kernel_version//-/ }"
printf '%s' "${arr[0]}"
}
update_ksu_zip_name() {
KERNEL_VER=""
if [ -f "$WORK_DIR/wsa/$ARCH/Tools/kernel" ]; then
KERNEL_VER=$(getKernelVersion "$WORK_DIR/wsa/$ARCH/Tools/kernel")
fi
KERNELSU_ZIP_NAME=kernelsu-$ARCH-$KERNEL_VER.zip
KERNELSU_PATH=$DOWNLOAD_DIR/$KERNELSU_ZIP_NAME
KERNELSU_APK_PATH=$DOWNLOAD_DIR/KernelSU.apk
KERNELSU_INFO="$KERNELSU_PATH.info"
}
echo "Generating WSA Download Links"
python3 generateWSALinks.py "$ARCH" "$RELEASE_TYPE" "$DOWNLOAD_DIR" "$DOWNLOAD_WSA_CONF_NAME" || abort
if [ "$RELEASE_TYPE" == "latest" ]; then
printf "%s\n" "$(curl -sL https://api.github.com/repos/bubbles-wow/WSA-Archive/releases/latest | jq -r '.assets[] | .browser_download_url')" >> "$DOWNLOAD_DIR/$DOWNLOAD_WSA_CONF_NAME" || abort
printf " dir=%s\n" "$DOWNLOAD_DIR" >> "$DOWNLOAD_DIR/$DOWNLOAD_WSA_CONF_NAME" || abort
printf " out=wsa-latest.zip\n" >> "$DOWNLOAD_DIR/$DOWNLOAD_WSA_CONF_NAME" || abort
WSA_VER=$(curl -sL https://api.github.com/repos/bubbles-wow/WSA-Archive/releases/latest | jq -r '.tag_name')
WSA_MAJOR_VER=${WSA_VER:0:4}
else
# shellcheck disable=SC1090
source "$WSA_WORK_ENV" || abort
fi
if ! aria2c --no-conf --log-level=info --log="$DOWNLOAD_DIR/aria2_download.log" -x16 -s16 -j7 -m0 \
--async-dns=false --check-integrity=true \
-d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_WSA_CONF_NAME"; then
abort "We have encountered an error while downloading files."
fi
echo "Extracting WSA"
if [ -f "$WSA_ZIP_PATH" ]; then
if ! python3 extractWSA.py "$ARCH" "$WSA_ZIP_PATH" "$WORK_DIR" "$WSA_WORK_ENV"; then
abort "Unzip WSA failed"
fi
echo -e "done\n"
# shellcheck disable=SC1090
source "$WSA_WORK_ENV" || abort
else
abort "The WSA zip package does not exist"
fi
echo "Generating Download Links"
if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
python3 generateMagiskLink.py "$MAGISK_BRANCH" "$MAGISK_VER" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" || abort
fi
if [ "$ROOT_SOL" = "kernelsu" ]; then
update_ksu_zip_name
python3 generateKernelSULink.py "$ARCH" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$KERNEL_VER" "$KERNELSU_ZIP_NAME" || abort
# shellcheck disable=SC1090
source "$WSA_WORK_ENV" || abort
# shellcheck disable=SC2153
echo "KERNELSU_VER=$KERNELSU_VER" >"$KERNELSU_INFO"
fi
if [ "$HAS_GAPPS" ]; then
update_gapps_files_name
python3 generateGappsLink.py "$ARCH" "$DOWNLOAD_DIR" "$DOWNLOAD_CONF_NAME" "$ANDROID_API" "$GAPPS_IMAGE_NAME" || abort
fi
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 -j7 -m0 \
--async-dns=false --check-integrity=true \
-d"$DOWNLOAD_DIR" -i"$DOWNLOAD_DIR/$DOWNLOAD_CONF_NAME"; then
abort "We have encountered an error while downloading files."
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" ["CUST_PATH"]="$CUST_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_files_name
FILES_CHECK_LIST+=(["GAPPS_IMAGE_PATH"]="$GAPPS_IMAGE_PATH" ["GAPPS_RC_PATH"]="$GAPPS_RC_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
MAGISK_VERSION_NAME=""
MAGISK_VERSION_CODE=0
if ! python3 extractMagisk.py "$ARCH" "$MAGISK_PATH" "$WORK_DIR"; then
abort "Unzip Magisk failed, is the download incomplete?"
fi
# shellcheck disable=SC1090
source "$WSA_WORK_ENV" || abort
chmod +x "$WORK_DIR/magisk/magiskboot" || abort
else
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
if [ "$HAS_GAPPS" ] || [ "$ROOT_SOL" = "magisk" ]; then
echo "Integrating Magisk"
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk64" "$WORK_DIR/magisk/magisk64.xz"
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk32" "$WORK_DIR/magisk/magisk32.xz"
"$WORK_DIR/magisk/magiskboot" compress=xz "$MAGISK_PATH" "$WORK_DIR/magisk/stub.xz"
"$WORK_DIR/magisk/magiskboot" cpio "$WORK_DIR/wsa/$ARCH/Tools/initrd.img" \
"mv /init /wsainit" \
"add 0750 /lspinit ../bin/$ARCH/lspinit" \
"ln /lspinit /init" \
"add 0750 /magiskinit $WORK_DIR/magisk/magiskinit" \
"mkdir 0750 overlay.d" \
"mkdir 0750 overlay.d/sbin" \
"add 0644 overlay.d/sbin/magisk64.xz $WORK_DIR/magisk/magisk64.xz" \
"add 0644 overlay.d/sbin/magisk32.xz $WORK_DIR/magisk/magisk32.xz" \
"add 0644 overlay.d/sbin/stub.xz $WORK_DIR/magisk/stub.xz" \
"mkdir 000 .backup" \
"add 000 overlay.d/init.lsp.magisk.rc init.lsp.magisk.rc" \
"add 000 overlay.d/sbin/post-fs-data.sh post-fs-data.sh" \
"add 000 overlay.d/sbin/lsp_cust.img $CUST_PATH" \
|| abort "Unable to patch initrd"
elif [ "$ROOT_SOL" = "kernelsu" ]; then
echo "Extracting KernelSU"
# shellcheck disable=SC1090
source "${KERNELSU_INFO:?}" || abort
echo "WSA Kernel Version: $KERNEL_VER"
echo "KernelSU Version: $KERNELSU_VER"
if ! unzip "$KERNELSU_PATH" -d "$WORK_DIR/kernelsu"; then
abort "Unzip KernelSU failed, package is corrupted?"
fi
if [ "$ARCH" = "x64" ]; then
mv "$WORK_DIR/kernelsu/bzImage" "$WORK_DIR/kernelsu/kernel"
elif [ "$ARCH" = "arm64" ]; then
mv "$WORK_DIR/kernelsu/Image" "$WORK_DIR/kernelsu/kernel"
fi
echo "Integrate KernelSU"
mv "$WORK_DIR/wsa/$ARCH/Tools/kernel" "$WORK_DIR/wsa/$ARCH/Tools/kernel_origin"
cp "$WORK_DIR/kernelsu/kernel" "$WORK_DIR/wsa/$ARCH/Tools/kernel"
fi
echo -e "done\n"
if [ "$HAS_GAPPS" ]; then
update_gapps_files_name
if [ -f "$GAPPS_IMAGE_PATH" ] && [ -f "$GAPPS_RC_PATH" ]; then
echo "Integrating GApps"
"$WORK_DIR/magisk/magiskboot" cpio "$WORK_DIR/wsa/$ARCH/Tools/initrd.img" \
"add 000 /lspolicy.rule sepolicy.rule" \
"add 000 overlay.d/gapps.rc $GAPPS_RC_PATH" \
"add 000 overlay.d/sbin/lsp_gapps.img $GAPPS_IMAGE_PATH" \
|| abort "Unable to patch initrd"
echo -e "done\n"
else
abort "The GApps package does not exist."
fi
fi
if [ "$REMOVE_AMAZON" ]; then
rm -f "$WORK_DIR/wsa/$ARCH/apex/"mado*.apex || abort
fi
echo "Removing signature and add scripts"
rm -rf "${WORK_DIR:?}"/wsa/"$ARCH"/\[Content_Types\].xml "$WORK_DIR/wsa/$ARCH/AppxBlockMap.xml" "$WORK_DIR/wsa/$ARCH/AppxSignature.p7x" "$WORK_DIR/wsa/$ARCH/AppxMetadata" || abort
cp "$vclibs_PATH" "$xaml_PATH" "$WORK_DIR/wsa/$ARCH" || abort
cp "$UWPVCLibs_PATH" "$xaml_PATH" "$WORK_DIR/wsa/$ARCH" || abort
cp "../xml/priconfig.xml" "$WORK_DIR/wsa/$ARCH/xml/" || abort
cp "../installer/$ARCH/MakePri.ps1" "$WORK_DIR/wsa/$ARCH" || abort
cp "../installer/$ARCH/Install.ps1" "$WORK_DIR/wsa/$ARCH" || abort
cp "../installer/Run.bat" "$WORK_DIR/wsa/$ARCH" || abort
find "$WORK_DIR/wsa/$ARCH" -maxdepth 1 -mindepth 1 -printf "%P\n" >"$WORK_DIR/wsa/$ARCH/filelist.txt" || abort
find "$WORK_DIR/wsa/$ARCH/pri" -printf "%P\n" | sed -e 's/^/pri\\/' -e '/^$/d' > "$WORK_DIR/wsa/$ARCH/filelist-pri.txt" || abort
find "$WORK_DIR/wsa/$ARCH/xml" -printf "%P\n" | sed -e 's/^/xml\\/' -e '/^$/d' >> "$WORK_DIR/wsa/$ARCH/filelist-pri.txt" || abort
echo -e "done\n" echo -e "done\n"
if [[ "$ROOT_SOL" = "none" ]]; then if [[ "$ROOT_SOL" = "none" ]]; then