Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
NoName-exe committed Feb 3, 2025
2 parents 63d445e + 36bc158 commit b760b0e
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 39 deletions.
19 changes: 9 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,30 @@ for table_name in $(toml_get_table_names); do
app_args[dpi]=$(toml_get "$t" apkmirror-dpi) || app_args[dpi]="nodpi"
table_name_f=${table_name,,}
table_name_f=${table_name_f// /-}
app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || {
app_args[module_prop_name]="${table_name_f}-jhc"
if [ "${app_args[arch]}" = "arm64-v8a" ]; then
app_args[module_prop_name]="${app_args[module_prop_name]}-arm64"
elif [ "${app_args[arch]}" = "arm-v7a" ]; then
app_args[module_prop_name]="${app_args[module_prop_name]}-arm"
fi
}
app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || app_args[module_prop_name]="${table_name_f}-jhc"

if [ "${app_args[arch]}" = both ]; then
app_args[table]="$table_name (arm64-v8a)"
app_args[arch]="arm64-v8a"
app_args[module_prop_name]="${app_args[module_prop_name]}-arm64"
module_prop_name_b=${app_args[module_prop_name]}
app_args[module_prop_name]="${module_prop_name_b}-arm64"
idx=$((idx + 1))
build_rv "$(declare -p app_args)" &
app_args[table]="$table_name (arm-v7a)"
app_args[arch]="arm-v7a"
app_args[module_prop_name]="${app_args[module_prop_name]}-arm"
app_args[module_prop_name]="${module_prop_name_b}-arm"
if ((idx >= PARALLEL_JOBS)); then
wait -n
idx=$((idx - 1))
fi
idx=$((idx + 1))
build_rv "$(declare -p app_args)" &
else
if [ "${app_args[arch]}" = "arm64-v8a" ]; then
app_args[module_prop_name]="${app_args[module_prop_name]}-arm64"
elif [ "${app_args[arch]}" = "arm-v7a" ]; then
app_args[module_prop_name]="${app_args[module_prop_name]}-arm"
fi
idx=$((idx + 1))
build_rv "$(declare -p app_args)" &
fi
Expand Down
20 changes: 20 additions & 0 deletions revanced-magisk/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/system/bin/sh

if type nsenter >/dev/null 2>/dev/null; then
ZPID=$(pidof zygote)
Z64PID=$(pidof zygote64)

mm() {
if [ "$ZPID" ]; then nsenter -t "$ZPID" -m -- "$@" || return $?; fi
if [ "$Z64PID" ]; then nsenter -t "$Z64PID" -m -- "$@" || return $?; fi
}
else
mm() { "$@"; }
fi

pmex() {
OP=$(pm "$@" 2>&1 </dev/null)
RET=$?
echo "$OP"
return $RET
}
12 changes: 1 addition & 11 deletions revanced-magisk/customize.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
. "$MODPATH/config"
. "$MODPATH/common.sh"

ui_print ""
if [ -n "$MODULE_ARCH" ] && [ "$MODULE_ARCH" != "$ARCH" ]; then
Expand All @@ -19,24 +20,13 @@ RVPATH=/data/adb/rvhc/${MODPATH##*/}.apk

set_perm_recursive "$MODPATH/bin" 0 0 0755 0777

if su -M -c true >/dev/null 2>/dev/null; then
alias mm='su -M -c'
else alias mm='nsenter -t1 -m'; fi

mm grep -F "$PKG_NAME" /proc/mounts | while read -r line; do
ui_print "- Un-mount"
mp=${line#* } mp=${mp%% *}
mm umount -l "${mp%%\\*}"
done
am force-stop "$PKG_NAME"

pmex() {
OP=$(pm "$@" 2>&1 </dev/null)
RET=$?
echo "$OP"
return $RET
}

if ! pmex path "$PKG_NAME" >&2; then
if pmex install-existing "$PKG_NAME" >&2; then
BASEPATH=$(pmex path "$PKG_NAME") || abort "ERROR: pm path failed $BASEPATH"
Expand Down
11 changes: 6 additions & 5 deletions revanced-magisk/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
MODDIR=${0%/*}
RVPATH=/data/adb/rvhc/${MODDIR##*/}.apk
. "$MODDIR/config"
. "$MODDIR/common.sh"

err() {
[ ! -f "$MODDIR/err" ] && cp "$MODDIR/module.prop" "$MODDIR/err"
Expand All @@ -11,7 +12,7 @@ err() {
until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
until [ -d "/sdcard/Android" ]; do sleep 1; done
while
BASEPATH=$(pm path "$PKG_NAME" 2>&1 </dev/null)
BASEPATH=$(pmex path "$PKG_NAME")
SVCL=$?
[ $SVCL = 20 ]
do sleep 2; done
Expand All @@ -24,7 +25,7 @@ run() {
sleep 4

BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*}
if [ ! -d "$BASEPATH/lib" ]; then # TODO: is this ok? idk
if [ ! -d "$BASEPATH/lib" ]; then
ls -Zla "$BASEPATH" >"$MODDIR/log.txt"
ls -Zla "$BASEPATH/lib" >>"$MODDIR/log.txt"
else rm "$MODDIR/log.txt" >/dev/null 2>&1; fi
Expand All @@ -33,15 +34,15 @@ run() {
err "version mismatch (installed:${VERSION}, module:$PKG_VER)"
return
fi
grep "$PKG_NAME" /proc/mounts | while read -r line; do
mm grep "$PKG_NAME" /proc/mounts | while read -r line; do
mp=${line#* } mp=${mp%% *}
umount -l "${mp%%\\*}"
mm umount -l "${mp%%\\*}"
done
if ! chcon u:object_r:apk_data_file:s0 "$RVPATH"; then
err "apk not found"
return
fi
mount -o bind "$RVPATH" "$BASEPATH/base.apk"
mm mount -o bind "$RVPATH" "$BASEPATH/base.apk"
am force-stop "$PKG_NAME"
[ -f "$MODDIR/err" ] && mv -f "$MODDIR/err" "$MODDIR/module.prop"
}
Expand Down
35 changes: 22 additions & 13 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ _req() {
local ip="$1" op="$2"
shift 2
if [ "$op" = - ]; then
curl -L -c "$TEMP_DIR/cookie.txt" -b "$TEMP_DIR/cookie.txt" --connect-timeout 5 --retry 0 --fail -s -S "$@" "$ip"
if ! curl -L -c "$TEMP_DIR/cookie.txt" -b "$TEMP_DIR/cookie.txt" --connect-timeout 5 --retry 0 --fail -s -S "$@" "$ip"; then
epr "Request failed: $ip"
return 1
fi
else
if [ -f "$op" ]; then return; fi
local dlp
Expand All @@ -196,7 +199,10 @@ _req() {
while [ -f "$dlp" ]; do sleep 1; done
return
fi
curl -L -c "$TEMP_DIR/cookie.txt" -b "$TEMP_DIR/cookie.txt" --connect-timeout 5 --retry 0 --fail -s -S "$@" "$ip" -o "$dlp" || return 1
if ! curl -L -c "$TEMP_DIR/cookie.txt" -b "$TEMP_DIR/cookie.txt" --connect-timeout 5 --retry 0 --fail -s -S "$@" "$ip" -o "$dlp"; then
epr "Request failed: $ip"
return 1
fi
mv -f "$dlp" "$op"
fi
}
Expand Down Expand Up @@ -261,17 +267,18 @@ isoneof() {
merge_splits() {
local bundle=$1 output=$2
pr "Merging splits"
gh_dl "$TEMP_DIR/apkeditor.jar" "https://github.com/REAndroid/APKEditor/releases/download/V1.3.9/APKEditor-1.3.9.jar" >/dev/null || return 1
gh_dl "$TEMP_DIR/apkeditor.jar" "https://github.com/REAndroid/APKEditor/releases/download/V1.4.2/APKEditor-1.4.2.jar" >/dev/null || return 1
if ! OP=$(java -jar "$TEMP_DIR/apkeditor.jar" merge -i "${bundle}" -o "${bundle}.mzip" -clean-meta -f 2>&1); then
epr "$OP"
epr "Apkeditor ERROR: $OP"
return 1
fi
# this is required because of apksig
mkdir "${bundle}-zip"
unzip -qo "${bundle}.mzip" -d "${bundle}-zip"
pushd "${bundle}-zip" || abort
zip -0rq "${CWD}/${bundle}.zip" .
popd || abort
(
cd "${bundle}-zip" || abort
zip -0rq "${CWD}/${bundle}.zip" .
)
# if building module, sign the merged apk properly
if isoneof "module" "${build_mode_arr[@]}"; then
patch_apk "${bundle}.zip" "${output}" "--exclusive" "${args[cli]}" "${args[ptjar]}"
Expand Down Expand Up @@ -310,8 +317,10 @@ dl_apkmirror() {
is_bundle=true
else
if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi
local resp node app_table dlurl=""
url="${url}/${url##*/}-${version//./-}-release/"
local resp node app_table uurl dlurl=""
uurl=$(grep -F "downloadLink" <<<"$__APKMIRROR_RESP__" | grep -F "${version//./-}-release/" |
sed -n 's;.*href="\(.*-release\).*;\1;p')
if [ -z "$uurl" ]; then url="${url}/${url##*/}-${version//./-}-release/"; else url=https://www.apkmirror.com$uurl; fi
resp=$(req "$url" -) || return 1
node=$($HTMLQ "div.table-row.headerFont:nth-last-child(1)" -r "span:nth-child(n+3)" <<<"$resp")
if [ "$node" ]; then
Expand All @@ -328,10 +337,10 @@ dl_apkmirror() {
fi

if [ "$is_bundle" = true ]; then
req "$url" "${output}.apkm"
req "$url" "${output}.apkm" || return 1
merge_splits "${output}.apkm" "${output}"
else
req "$url" "${output}"
req "$url" "${output}" || return 1
fi
}
get_apkmirror_vers() {
Expand Down Expand Up @@ -518,8 +527,8 @@ build_rv() {
done
if [ ! -f "$stock_apk" ]; then return 0; fi
fi
if ! check_sig "$stock_apk" "$pkg_name"; then
abort "apk signature mismatch '$stock_apk'"
if ! OP=$(check_sig "$stock_apk" "$pkg_name" 2>&1) && ! grep -qFx "ERROR: Missing META-INF/MANIFEST.MF" <<<"$OP"; then
abort "apk signature mismatch '$stock_apk': $OP"
fi
log "${table}: ${version}"

Expand Down

0 comments on commit b760b0e

Please sign in to comment.