mirror of
https://github.com/j-hc/revanced-magisk-module.git
synced 2025-05-19 07:47:07 +02:00
more refactoring
This commit is contained in:
parent
4b2e213c23
commit
ad70b12e4e
9
build.sh
9
build.sh
@ -80,10 +80,17 @@ for table_name in $(toml_get_table_names); do
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
app_args[patcher_args]="$(join_args "${excluded_patches}" -e) $(join_args "${included_patches}" -i)"
|
app_args[patcher_args]="$(join_args "${excluded_patches}" -e) $(join_args "${included_patches}" -i)"
|
||||||
[ "$exclusive_patches" = true ] && app_args[patcher_args]="${app_args[patcher_args]} --exclusive"
|
[ "$exclusive_patches" = true ] && app_args[patcher_args]+=" --exclusive"
|
||||||
if [ "${app_args[microg_patch]}" ] && [[ "${app_args[patcher_args]}" = *"${app_args[microg_patch]}"* ]]; then
|
if [ "${app_args[microg_patch]}" ] && [[ "${app_args[patcher_args]}" = *"${app_args[microg_patch]}"* ]]; then
|
||||||
abort "ERROR: Do not include microg in included or excluded patches list"
|
abort "ERROR: Do not include microg in included or excluded patches list"
|
||||||
fi
|
fi
|
||||||
|
if [ "$LOGGING_F" = true ]; then
|
||||||
|
logf=logs/"${table_name,,}.log"
|
||||||
|
: >"$logf"
|
||||||
|
(build_rv 2>&1 app_args | tee "$logf") &
|
||||||
|
else
|
||||||
|
build_rv app_args &
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
wait
|
wait
|
||||||
|
|
||||||
|
93
utils.sh
93
utils.sh
@ -6,11 +6,7 @@ TEMP_DIR="temp"
|
|||||||
BUILD_DIR="build"
|
BUILD_DIR="build"
|
||||||
PKGS_LIST="${TEMP_DIR}/module-pkgs"
|
PKGS_LIST="${TEMP_DIR}/module-pkgs"
|
||||||
|
|
||||||
if [ "${GITHUB_TOKEN+x}" ]; then
|
if [ "${GITHUB_TOKEN:-}" ]; then GH_HEADER="Authorization: token ${GITHUB_TOKEN}"; else GH_HEADER=; fi
|
||||||
GH_AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"
|
|
||||||
else
|
|
||||||
GH_AUTH_HEADER=""
|
|
||||||
fi
|
|
||||||
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-"j-hc/revanced-magisk-module"}
|
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-"j-hc/revanced-magisk-module"}
|
||||||
NEXT_VER_CODE=${NEXT_VER_CODE:-$(date +'%Y%m%d')}
|
NEXT_VER_CODE=${NEXT_VER_CODE:-$(date +'%Y%m%d')}
|
||||||
WGET_HEADER="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"
|
WGET_HEADER="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"
|
||||||
@ -66,7 +62,7 @@ get_prebuilts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_cmpr() {
|
get_cmpr() {
|
||||||
mkdir -p revanced-magisk/bin/arm64 revanced-magisk/bin/arm
|
mkdir -p ${MODULE_TEMPLATE_DIR}/bin/arm64 ${MODULE_TEMPLATE_DIR}/bin/arm
|
||||||
dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/arm64/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-arm64-v8a"
|
dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/arm64/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-arm64-v8a"
|
||||||
dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/arm/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-armeabi-v7a"
|
dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/arm/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-armeabi-v7a"
|
||||||
}
|
}
|
||||||
@ -89,7 +85,7 @@ set_prebuilts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
req() { wget -nv -O "$2" --header="$WGET_HEADER" "$1"; }
|
req() { wget -nv -O "$2" --header="$WGET_HEADER" "$1"; }
|
||||||
gh_req() { wget -nv -O "$2" --header="$GH_AUTH_HEADER" "$1"; }
|
gh_req() { wget -nv -O "$2" --header="$GH_HEADER" "$1"; }
|
||||||
log() { echo -e "$1 " >>build.md; }
|
log() { echo -e "$1 " >>build.md; }
|
||||||
get_largest_ver() {
|
get_largest_ver() {
|
||||||
read -r max
|
read -r max
|
||||||
@ -195,6 +191,7 @@ patch_apk() {
|
|||||||
else
|
else
|
||||||
eval "$cmd"
|
eval "$cmd"
|
||||||
fi
|
fi
|
||||||
|
[ -f "$patched_apk" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
zip_module() {
|
zip_module() {
|
||||||
@ -214,28 +211,8 @@ build_rv() {
|
|||||||
local app_name_l=${app_name,,}
|
local app_name_l=${app_name,,}
|
||||||
local dl_from=${args[dl_from]}
|
local dl_from=${args[dl_from]}
|
||||||
local arch=${args[arch]}
|
local arch=${args[arch]}
|
||||||
|
local p_patcher_args=${args[patcher_args]}
|
||||||
|
|
||||||
if [ "$mode_arg" = module ]; then
|
|
||||||
build_mode_arr=(module)
|
|
||||||
elif [ "$mode_arg" = apk ]; then
|
|
||||||
build_mode_arr=(apk)
|
|
||||||
elif [ "$mode_arg" = both ]; then
|
|
||||||
build_mode_arr=(apk module)
|
|
||||||
fi
|
|
||||||
|
|
||||||
for build_mode in "${build_mode_arr[@]}"; do
|
|
||||||
patcher_args="${args[patcher_args]}"
|
|
||||||
echo -n "Building '${app_name}' (${arch}) in "
|
|
||||||
if [ "$build_mode" = module ]; then
|
|
||||||
echo "'module' mode"
|
|
||||||
if [ "${args[microg_patch]}" ]; then
|
|
||||||
patcher_args="$patcher_args -e ${args[microg_patch]} --unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a"
|
|
||||||
else
|
|
||||||
patcher_args="$patcher_args --unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "'APK' mode"
|
|
||||||
fi
|
|
||||||
if [ "$dl_from" = apkmirror ]; then
|
if [ "$dl_from" = apkmirror ]; then
|
||||||
pkg_name=$(get_apkmirror_pkg_name "${args[apkmirror_dlurl]}")
|
pkg_name=$(get_apkmirror_pkg_name "${args[apkmirror_dlurl]}")
|
||||||
elif [ "$dl_from" = uptodown ]; then
|
elif [ "$dl_from" = uptodown ]; then
|
||||||
@ -249,10 +226,10 @@ build_rv() {
|
|||||||
if [ -z "$version" ]; then get_latest_ver=true; fi
|
if [ -z "$version" ]; then get_latest_ver=true; fi
|
||||||
elif [ "$version_mode" = latest ]; then
|
elif [ "$version_mode" = latest ]; then
|
||||||
get_latest_ver=true
|
get_latest_ver=true
|
||||||
patcher_args="$patcher_args --experimental"
|
p_patcher_args+=" --experimental"
|
||||||
else
|
else
|
||||||
version=$version_mode
|
version=$version_mode
|
||||||
patcher_args="$patcher_args --experimental"
|
p_patcher_args+=" --experimental"
|
||||||
fi
|
fi
|
||||||
if [ $get_latest_ver = true ]; then
|
if [ $get_latest_ver = true ]; then
|
||||||
local apkmvers uptwodvers
|
local apkmvers uptwodvers
|
||||||
@ -273,12 +250,6 @@ build_rv() {
|
|||||||
echo "Choosing version '${version}' (${app_name})"
|
echo "Choosing version '${version}' (${app_name})"
|
||||||
|
|
||||||
local stock_apk="${TEMP_DIR}/${pkg_name}-stock-${version// /}-${arch}.apk"
|
local stock_apk="${TEMP_DIR}/${pkg_name}-stock-${version// /}-${arch}.apk"
|
||||||
local apk_output="${BUILD_DIR}/${app_name_l}-revanced-v${version}-${arch}.apk"
|
|
||||||
if [ "${args[microg_patch]}" ]; then
|
|
||||||
local patched_apk="${TEMP_DIR}/${app_name_l}-revanced-${version}-${arch}-${build_mode}.apk"
|
|
||||||
else
|
|
||||||
local patched_apk="${TEMP_DIR}/${app_name_l}-revanced-${version}-${arch}.apk"
|
|
||||||
fi
|
|
||||||
if [ ! -f "$stock_apk" ]; then
|
if [ ! -f "$stock_apk" ]; then
|
||||||
if [ "$dl_from" = apkmirror ]; then
|
if [ "$dl_from" = apkmirror ]; then
|
||||||
echo "Downloading '${app_name}' from APKMirror"
|
echo "Downloading '${app_name}' from APKMirror"
|
||||||
@ -301,48 +272,72 @@ build_rv() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${arch}" = "all" ]; then
|
if [ "${arch}" = "all" ]; then
|
||||||
grep -q "${app_name}:" build.md || log "${app_name}: ${version}"
|
grep -q "${app_name}:" build.md || log "${app_name}: ${version}"
|
||||||
else
|
else
|
||||||
grep -q "${app_name} (${arch}):" build.md || log "${app_name} (${arch}): ${version}"
|
grep -q "${app_name} (${arch}):" build.md || log "${app_name} (${arch}): ${version}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if jq -r ".[] | select(.compatiblePackages[].name==\"${pkg_name}\") | .dependencies[]" "$RV_PATCHES_JSON" | grep -qFx integrations; then
|
if jq -r ".[] | select(.compatiblePackages[].name==\"${pkg_name}\") | .dependencies[]" "$RV_PATCHES_JSON" | grep -qFx integrations; then
|
||||||
patcher_args="$patcher_args -m ${RV_INTEGRATIONS_APK}"
|
p_patcher_args+=" -m ${RV_INTEGRATIONS_APK}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$mode_arg" = module ]; then
|
||||||
|
build_mode_arr=(module)
|
||||||
|
elif [ "$mode_arg" = apk ]; then
|
||||||
|
build_mode_arr=(apk)
|
||||||
|
elif [ "$mode_arg" = both ]; then
|
||||||
|
build_mode_arr=(apk module)
|
||||||
|
fi
|
||||||
|
for build_mode in "${build_mode_arr[@]}"; do
|
||||||
|
patcher_args=$p_patcher_args
|
||||||
|
echo "Building '${app_name}' (${arch}) in '$build_mode' mode"
|
||||||
|
if [ "${args[microg_patch]}" ]; then
|
||||||
|
local patched_apk="${TEMP_DIR}/${app_name_l}-revanced-${version}-${arch}-${build_mode}.apk"
|
||||||
|
if [ "$build_mode" = apk ]; then
|
||||||
|
patcher_args+=" -i ${args[microg_patch]}"
|
||||||
|
elif [ "$build_mode" = module ]; then
|
||||||
|
patcher_args+=" -e ${args[microg_patch]}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
local patched_apk="${TEMP_DIR}/${app_name_l}-revanced-${version}-${arch}.apk"
|
||||||
|
fi
|
||||||
|
if [ "$build_mode" = module ]; then
|
||||||
|
patcher_args+=" --unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a"
|
||||||
fi
|
fi
|
||||||
if [ ! -f "$patched_apk" ]; then patch_apk "$stock_apk" "$patched_apk" "$patcher_args"; fi
|
|
||||||
if [ ! -f "$patched_apk" ]; then
|
if [ ! -f "$patched_apk" ]; then
|
||||||
|
if ! patch_apk "$stock_apk" "$patched_apk" "$patcher_args"; then
|
||||||
echo "BUILDING '${app_name}' FAILED"
|
echo "BUILDING '${app_name}' FAILED"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
if [ "$build_mode" = apk ]; then
|
if [ "$build_mode" = apk ]; then
|
||||||
|
local apk_output="${BUILD_DIR}/${app_name_l}-revanced-v${version}-${arch}.apk"
|
||||||
cp -f "$patched_apk" "$apk_output"
|
cp -f "$patched_apk" "$apk_output"
|
||||||
echo "Built ${app_name} (${arch}) (non-root): '${apk_output}'"
|
echo "Built ${app_name} (${arch}) (non-root): '${apk_output}'"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
if [ "$BUILD_MINDETACH_MODULE" = true ] && ! grep -q "$pkg_name" $PKGS_LIST; then echo "$pkg_name" >>$PKGS_LIST; fi
|
local base_template upj module_prop_name
|
||||||
|
base_template=$(mktemp -d -p $TEMP_DIR)
|
||||||
declare -r base_template=$(mktemp -d -p $TEMP_DIR)
|
|
||||||
cp -a $MODULE_TEMPLATE_DIR/. "$base_template"
|
cp -a $MODULE_TEMPLATE_DIR/. "$base_template"
|
||||||
|
if [ "$BUILD_MINDETACH_MODULE" = true ] && ! grep -q "$pkg_name" $PKGS_LIST; then echo "$pkg_name" >>$PKGS_LIST; fi
|
||||||
|
|
||||||
uninstall_sh "$pkg_name" "$base_template"
|
uninstall_sh "$pkg_name" "$base_template"
|
||||||
service_sh "$pkg_name" "$version" "$base_template"
|
service_sh "$pkg_name" "$version" "$base_template"
|
||||||
customize_sh "$pkg_name" "$version" "$base_template"
|
customize_sh "$pkg_name" "$version" "$base_template"
|
||||||
|
|
||||||
if [ "$arch" = "all" ]; then
|
if [ "$arch" = "all" ]; then
|
||||||
local upj="${app_name_l}-update.json"
|
upj="${app_name_l}-update.json"
|
||||||
else
|
else
|
||||||
local upj="${app_name_l}-${arch}-update.json"
|
upj="${app_name_l}-${arch}-update.json"
|
||||||
fi
|
fi
|
||||||
if [ "${args[module_prop_name]}" ]; then
|
if [ -z "${args[module_prop_name]}" ]; then
|
||||||
if [ "$arch" = "all" ]; then
|
if [ "$arch" = "all" ]; then
|
||||||
local module_prop_name="${app_name_l}-rv-jhc-magisk"
|
module_prop_name="${app_name_l}-rv-jhc-magisk"
|
||||||
else
|
else
|
||||||
local module_prop_name="${app_name_l}-${arch}-rv-jhc-magisk"
|
module_prop_name="${app_name_l}-${arch}-rv-jhc-magisk"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
local module_prop_name=${args[module_prop_name]}
|
module_prop_name=${args[module_prop_name]}
|
||||||
fi
|
fi
|
||||||
module_prop \
|
module_prop \
|
||||||
"$module_prop_name" \
|
"$module_prop_name" \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user