Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NoName-exe authored Mar 6, 2024
2 parents 79da0a4 + 45ac4ff commit 70a7711
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 36 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ jobs:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: "zulu"
java-version: "17"

- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
find . -name "*-update.json" | grep . || : >dummy-update.json
- uses: stefanzweifel/git-auto-commit-action@v4
- uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: update
skip_checkout: true
Expand Down Expand Up @@ -152,9 +152,3 @@ jobs:
MSG=${MSG:0:9450}
POST="https://api.telegram.org/bot${TG_TOKEN}/sendMessage"
curl -X POST --data-urlencode "parse_mode=Markdown" --data-urlencode "disable_web_page_preview=true" --data-urlencode "text=${MSG}" --data-urlencode "chat_id=${TG_CHAT}" "$POST"
- uses: actions/upload-artifact@v3
with:
name: logs
path: logs
if-no-files-found: ignore
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down
1 change: 1 addition & 0 deletions CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ apkmonk-dlurl = "https://www.apkmonk.com/app/com.app.app/"
module-prop-name = "some-app-magisk" # magisk module prop name.
apkmirror-dpi = "360-480dpi" # used to select apk variant from apkmirror. default: nodpi
arch = "arm64-v8a" # 'arm64-v8a', 'arm-v7a', 'all', 'both'. 'both' downloads both arm64-v8a and arm-v7a. default: all
riplib = true # enables ripping x86 and x86_64 libs from apks with j-hc revanced cli. default: true
```
1 change: 1 addition & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ for table_name in $(toml_get_table_names); do
app_args[riplib]=false
fi
fi
if [ "${app_args[riplib]}" = "true" ] && [ "$(toml_get "$t" riplib)" = "false" ]; then app_args[riplib]=false; fi
app_args[rv_brand]=$(toml_get "$t" rv-brand) || app_args[rv_brand]="$DEF_RV_BRAND"

app_args[excluded_patches]=$(toml_get "$t" excluded-patches) || app_args[excluded_patches]=""
Expand Down
12 changes: 9 additions & 3 deletions scripts/customize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@ elif [ $ARCH = "arm64" ]; then
#arm64
ARCH_LIB=arm64-v8a
alias cmpr='$MODPATH/bin/arm64/cmpr'
elif [ $ARCH = "x86" ]; then
ARCH_LIB=x86
alias cmpr='$MODPATH/bin/x86/cmpr'
elif [ $ARCH = "x64" ]; then
ARCH_LIB=x86_64
alias cmpr='$MODPATH/bin/x64/cmpr'
else
abort "ERROR: unsupported arch: ${ARCH}"
fi
set_perm_recursive $MODPATH/bin 0 0 0755 0777

nsenter -t1 -m -- grep __PKGNAME /proc/mounts | while read -r line; do
su -M -c "grep __PKGNAME /proc/mounts" | while read -r line; do
ui_print "- Un-mount"
mp=${line#* }
mp=${mp%% *}
nsenter -t1 -m -- umount -l "${mp%%\\*}"
su -M -c "umount -l ${mp%%\\*}"
done
am force-stop __PKGNAME

Expand Down Expand Up @@ -97,7 +103,7 @@ mkdir -p $NVBASE/rvhc
RVPATH=$NVBASE/rvhc/${MODPATH##*/}.apk
mv -f $MODPATH/base.apk $RVPATH

if ! op=$(nsenter -t1 -m -- mount -o bind $RVPATH $BASEPATH/base.apk 2>&1); then
if ! op=$(su -M -c "mount -o bind $RVPATH $BASEPATH/base.apk" 2>&1); then
ui_print "ERROR: Mount failed!"
ui_print "$op"
fi
Expand Down
48 changes: 25 additions & 23 deletions utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ get_rv_prebuilts() {
local rv_cli_jar="${cli_dir}/${rv_cli_url##*/}"
echo "CLI: $(cut -d/ -f4 <<<"$rv_cli_url")/$(cut -d/ -f9 <<<"$rv_cli_url") " >"$patches_dir/changelog.md"

rv_integrations_url=$(gh_req "$rv_integrations_rel" - | json_get 'browser_download_url') || return 1
rv_integrations_url=$(gh_req "$rv_integrations_rel" - | json_get 'browser_download_url' | grep -E '\.apk$') || return 1
local rv_integrations_apk="${integrations_dir}/${rv_integrations_url##*/}"
echo "Integrations: $(cut -d/ -f4 <<<"$rv_integrations_url")/$(cut -d/ -f9 <<<"$rv_integrations_url") " >>"$patches_dir/changelog.md"

rv_patches=$(gh_req "$rv_patches_rel" -) || return 1
# rv_patches_changelog=$(json_get 'body' <<<"$rv_patches" | sed 's/\(\\n\)\+/\\n/g')
rv_patches_dl=$(json_get 'browser_download_url' <<<"$rv_patches")
rv_patches_json="${patches_dir}/patches-$(json_get 'tag_name' <<<"$rv_patches").json"
rv_patches_url=$(grep 'jar' <<<"$rv_patches_dl")
rv_patches_url=$(grep -E '\.jar$' <<<"$rv_patches_dl")
local rv_patches_jar="${patches_dir}/${rv_patches_url##*/}"
[ -f "$rv_patches_jar" ] || REBUILD=true
local nm
Expand All @@ -97,9 +97,11 @@ get_prebuilts() {
dl_if_dne ${TEMP_DIR}/aapt2 https://github.com/rendiix/termux-aapt/raw/d7d4b4a344cc52b94bcdab3500be244151261d8e/prebuilt-binary/${arch}/aapt2
chmod +x "${TEMP_DIR}/aapt2"
fi
mkdir -p ${MODULE_TEMPLATE_DIR}/bin/arm64 ${MODULE_TEMPLATE_DIR}/bin/arm
mkdir -p ${MODULE_TEMPLATE_DIR}/bin/arm64 ${MODULE_TEMPLATE_DIR}/bin/arm ${MODULE_TEMPLATE_DIR}/bin/x86 ${MODULE_TEMPLATE_DIR}/bin/x64
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/x86/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-x86"
dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/x64/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-x86_64"

HTMLQ="${TEMP_DIR}/htmlq"
if [ ! -f "$HTMLQ" ]; then
Expand Down Expand Up @@ -135,10 +137,13 @@ config_update() {
if [ "$enabled" = false ]; then continue; fi
PATCHES_SRC=$(toml_get "$t" patches-source) || PATCHES_SRC=$DEF_PATCHES_SRC
if [[ -v sources[$PATCHES_SRC] ]]; then
if [ "${sources[$PATCHES_SRC]}" = 1 ]; then echo "$t"; fi
if [ "${sources[$PATCHES_SRC]}" = 1 ]; then
conf+="$t"
conf+=$'\n'
fi
else
sources[$PATCHES_SRC]=0
if ! last_patches_url=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" - 2>&1 | json_get 'browser_download_url' | grep 'jar'); then
if ! last_patches_url=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" - 2>&1 | json_get 'browser_download_url' | grep -E '\.jar$'); then
abort oops
fi
last_patches=${last_patches_url##*/}
Expand Down Expand Up @@ -284,9 +289,7 @@ get_uptodown_vers() { $HTMLQ --text ".version" <<<"$__UPTODOWN_RESP__"; }
dl_uptodown() {
local uptodown_dlurl=$1 version=$2 output=$3
local url
if [ -n "$version" ]; then
url=$(grep -F "${version}</span>" -B 2 <<<"$__UPTODOWN_RESP__" | head -1 | sed -n 's;.*data-url=".*download\/\(.*\)".*;\1;p') || return 1
else url=""; fi
url=$(grep -F "${version}</span>" -B 2 <<<"$__UPTODOWN_RESP__" | head -1 | sed -n 's;.*data-url=".*download\/\(.*\)".*;\1;p') || return 1
url="https://dw.uptodown.com/dwn/$(req "${uptodown_dlurl}/post-download/${url}" - | sed -n 's;.*class="post-download" data-url="\(.*\)".*;\1;p')" || return 1
req "$url" "$output"
}
Expand Down Expand Up @@ -325,8 +328,7 @@ get_archive_pkg_name() { echo "$__ARCHIVE_PKG_NAME__"; }

patch_apk() {
local stock_input=$1 patched_apk=$2 patcher_args=$3 rv_cli_jar=$4 rv_patches_jar=$5
declare -r tdir=$(mktemp -d -p $TEMP_DIR)
local cmd="java -jar $rv_cli_jar patch $stock_input -r $tdir -p -o $patched_apk -b $rv_patches_jar \
local cmd="java -jar $rv_cli_jar patch $stock_input -p -o $patched_apk -b $rv_patches_jar \
--keystore=ks.keystore --keystore-entry-password=123456789 --keystore-password=123456789 --signer=jhc --alias=jhc $patcher_args --options=options.json"
if [ "$OS" = Android ]; then cmd+=" --custom-aapt2-binary=${TEMP_DIR}/aapt2"; fi
pr "$cmd"
Expand Down Expand Up @@ -398,8 +400,7 @@ build_rv() {
for dl_p in archive apkmirror uptodown apkmonk; do
if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi
pr "Downloading '${table}' from ${dl_p}"
if [ "$get_latest_ver" = true ] && [ $dl_p = uptodown ]; then local vver=""; else local vver=$version; fi
if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$vver" "$stock_apk" "$arch" "${args[dpi]}"; then
if ! dl_${dl_p} "${args[${dl_p}_dlurl]}" "$version" "$stock_apk" "$arch" "${args[dpi]}"; then
epr "ERROR: Could not download '${table}' from ${dl_p} with version '${version}', arch '${arch}', dpi '${args[dpi]}'"
continue
fi
Expand Down Expand Up @@ -436,15 +437,6 @@ build_rv() {
# fi
# fi
# fi

if [ "${args[riplib]}" = true ]; then
p_patcher_args+=("--rip-lib x86_64 --rip-lib x86")
if [ "$arch" = "arm64-v8a" ]; then
p_patcher_args+=("--rip-lib armeabi-v7a")
elif [ "$arch" = "arm-v7a" ]; then
p_patcher_args+=("--rip-lib arm64-v8a")
fi
fi
if [ "$mode_arg" = module ]; then
build_mode_arr=(module)
elif [ "$mode_arg" = apk ]; then
Expand All @@ -468,8 +460,18 @@ build_rv() {
else
patched_apk="${TEMP_DIR}/${app_name_l}-${rv_brand_f}-${version_f}-${arch_f}.apk"
fi
if [ "$build_mode" = module ] && [ "${args[riplib]}" = true ]; then
patcher_args+=("--unsigned --rip-lib arm64-v8a --rip-lib armeabi-v7a")
if [ "${args[riplib]}" = true ]; then
patcher_args+=("--rip-lib x86_64 --rip-lib x86")
if [ "$build_mode" = module ]; then
patcher_args+=("--rip-lib arm64-v8a --rip-lib armeabi-v7a --unsigned")
else
if [ "$arch" = "arm64-v8a" ]; then
patcher_args+=("--rip-lib armeabi-v7a")
elif [ "$arch" = "arm-v7a" ]; then
patcher_args+=("--rip-lib arm64-v8a")
fi

fi
fi
if [ ! -f "$patched_apk" ] || [ "$REBUILD" = true ]; then
if ! patch_apk "$stock_apk" "$patched_apk" "${patcher_args[*]}" "${args[cli]}" "${args[ptjar]}"; then
Expand Down

0 comments on commit 70a7711

Please sign in to comment.