Skip to content

Commit c028b5a

Browse files
authored
2 parents 68057a9 + 4d35c6e commit c028b5a

File tree

9 files changed

+108
-53
lines changed

9 files changed

+108
-53
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: Bug report
3+
about: Bug report
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
**DO NOT REPORT REVANCED BUGS IN THIS REPO**

.github/workflows/build.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ jobs:
1717
fetch-depth: 0
1818
submodules: true
1919

20+
- name: Get last tag
21+
id: last_tag
22+
uses: oprypin/find-latest-tag@v1
23+
continue-on-error: true
24+
with:
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
repository: ${{ github.repository }}
27+
releases-only: true
28+
2029
- name: Get next version code
2130
id: next_ver_code
2231
run: |
23-
TAG=$(git tag --sort=creatordate | tail -1)
32+
TAG="${{ steps.last_tag.outputs.tag }}"
2433
if [ -z "$TAG" ]; then TAG=0; fi
2534
echo "NEXT_VER_CODE=$((TAG + 1))" >> $GITHUB_OUTPUT
2635
@@ -61,12 +70,10 @@ jobs:
6170
file_glob: true
6271
overwrite: false
6372

64-
- name: Switch to update branch
65-
run: git checkout -f update || git switch --discard-changes --orphan update
66-
67-
- name: Update changelog and Magisk update jsons
73+
- name: Update changelog and Magisk update json
6874
id: update_config
6975
run: |
76+
git checkout -f update || git switch --discard-changes --orphan update
7077
cp -f build.tmp build.md
7178
get_update_json() {
7279
echo "{

.github/workflows/ci.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ jobs:
2121
toml_prep "$(cat config.toml)"
2222
2323
is_youtube_latest() {
24-
v=$(toml_get "$(toml_get_table "YouTube")" "version") || version=""
24+
t=$(toml_get_table YouTube)
25+
v=$(toml_get "$t" "version") || v=
2526
if [ "$v" = latest ]; then
26-
declare -r cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs)
27+
cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs)
2728
[ -z "$cur_yt" ] && return 1 # empty, fail=>dont build
28-
declare -r last_ver=$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube" | get_largest_ver)
29-
30-
echo "current yt version: $cur_yt"
31-
echo "latest yt version: $last_ver"
29+
aav=$(toml_get "$t" "allow-alpha-version") || aav=false
30+
last_ver=$(get_apkmirror_vers youtube "$aav" | get_largest_ver)
31+
[ -z "$last_ver" ] && return 1 # cant fetch, dont build
32+
echo "current yt version: '$cur_yt'"
33+
echo "latest yt version: '$last_ver'"
3234
[ "$cur_yt" != "$last_ver" ] # test success=>build, fail=>dont build
3335
else
3436
return 1 # not experimental, dont build
@@ -37,8 +39,8 @@ jobs:
3739
3840
is_patches_latest() {
3941
PATCHES_SRC=$(toml_get "$(toml_get_table "")" patches-source) || PATCHES_SRC="revanced/revanced-patches"
40-
declare -r last_patches_url=$(wget -nv --header="Authorization: token ${{ secrets.GITHUB_TOKEN }}" -O- https://api.github.com/repos/${PATCHES_SRC}/releases/latest | json_get 'browser_download_url' | grep 'jar')
41-
declare -r last_patches=${last_patches_url##*/}
42+
last_patches_url=$(wget -nv --header="Authorization: token ${{ secrets.GITHUB_TOKEN }}" -O- https://api.github.com/repos/${PATCHES_SRC}/releases/latest | json_get 'browser_download_url' | grep 'jar')
43+
last_patches=${last_patches_url##*/}
4244
cur_patches=$(sed -n 's/.*Patches: \(.*\)/\1/p' build.md | xargs)
4345
4446
echo "current patches version: $cur_patches"

CONFIG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ uptodown-dlurl = "https://app.en.uptodown.com/android"
1515
## If you'd like to get to know more about other options:
1616

1717
There exists an example below with all defaults shown and all the keys explicitly set.
18-
All keys are optional (except download urls) and are assigned to their default values if not set explicitly.
18+
**All keys are optional** (except download urls) and are assigned to their default values if not set explicitly.
1919

2020
```toml
21+
patches-source = "revanced/revanced-patches" # where to fetch patches bundle from. default: "revanced/revanced-patches"
22+
integrations-source = "revanced/revanced-integrations" # where to fetch integrations from. default: "revanced/revanced-integrations"
23+
rv-brand = "ReVanced Extended" # rebrand from 'ReVanced' to something different. default: "ReVanced"
24+
25+
patches-version = "v2.160.0" # locks the patches version. default: latest available
26+
integrations-version = "v0.95.0" # locks the integrations version. default: latest available
27+
2128
[Some-App]
2229
app-name = "SomeApp" # if set, app name becomes SomeApp instead of Some-App. default is same as table name, which is 'Some-App' here.
2330
# this affects the release name and stuff like that

build.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -euo pipefail
44

55
source utils.sh
6-
trap "rm -rf temp/tmp.*" INT
6+
trap "rm -rf temp/tmp.*; exit 1" INT
77

88
: >build.md
99

@@ -21,12 +21,16 @@ vtf() {
2121
}
2222

2323
toml_prep "$(cat 2>/dev/null "${1:-config.toml}")" || abort "could not find config file '${1}'"
24+
25+
# -- Main config --
2426
main_config_t=$(toml_get_table "")
2527
COMPRESSION_LEVEL=$(toml_get "$main_config_t" compression-level) || abort "ERROR: compression-level is missing"
2628
ENABLE_MAGISK_UPDATE=$(toml_get "$main_config_t" enable-magisk-update) || abort "ERROR: enable-magisk-update is missing"
2729
PARALLEL_JOBS=$(toml_get "$main_config_t" parallel-jobs) || abort "ERROR: parallel-jobs is missing"
2830
BUILD_MINDETACH_MODULE=$(toml_get "$main_config_t" build-mindetach-module) || abort "ERROR: build-mindetach-module is missing"
2931
LOGGING_F=$(toml_get "$main_config_t" logging-to-file) && vtf "$LOGGING_F" "logging-to-file" || LOGGING_F=false
32+
CONF_PATCHES_VER=$(toml_get "$main_config_t" patches-version) || CONF_PATCHES_VER=
33+
CONF_INTEGRATIONS_VER=$(toml_get "$main_config_t" integrations-version) || CONF_INTEGRATIONS_VER=
3034

3135
PATCHES_SRC=$(toml_get "$main_config_t" patches-source) || PATCHES_SRC="revanced/revanced-patches"
3236
INTEGRATIONS_SRC=$(toml_get "$main_config_t" integrations-source) || INTEGRATIONS_SRC="revanced/revanced-integrations"
@@ -35,13 +39,13 @@ RV_BRAND_F=${RV_BRAND,,}
3539
RV_BRAND_F=${RV_BRAND_F// /-}
3640
PREBUILTS_DIR="${TEMP_DIR}/tools-${RV_BRAND_F}"
3741
mkdir -p "$BUILD_DIR" "$PREBUILTS_DIR"
42+
# -- Main config --
3843

3944
if ((COMPRESSION_LEVEL > 9)) || ((COMPRESSION_LEVEL < 0)); then abort "compression-level must be from 0 to 9"; fi
4045
if [ "${DRYRUN:-}" = true ]; then set_prebuilts; else get_prebuilts || set_prebuilts; fi
4146
if [ "$BUILD_MINDETACH_MODULE" = true ]; then : >$PKGS_LIST; fi
4247
if [ "$LOGGING_F" = true ]; then mkdir -p logs; fi
4348
jq --version >/dev/null || abort "\`jq\` is not installed. install it with 'apt install jq' or equivalent"
44-
get_cmpr
4549

4650
log "**App Versions:**"
4751
idx=0
@@ -61,7 +65,7 @@ for table_name in $(toml_get_table_names); do
6165
app_args[allow_alpha_version]=$(toml_get "$t" allow-alpha-version) && vtf "${app_args[allow_alpha_version]}" "allow-alpha-version" || app_args[allow_alpha_version]=false
6266
app_args[build_mode]=$(toml_get "$t" build-mode) && {
6367
if ! isoneof "${app_args[build_mode]}" both apk module; then
64-
abort "ERROR: '${app_args[build_mode]}' is not a valid option for '${table_name}': only 'both', 'apk' or 'module' is allowed"
68+
abort "ERROR: build-mode '${app_args[build_mode]}' is not a valid option for '${table_name}': only 'both', 'apk' or 'module' is allowed"
6569
fi
6670
} || app_args[build_mode]=apk
6771
app_args[uptodown_dlurl]=$(toml_get "$t" uptodown-dlurl) && {
@@ -79,7 +83,7 @@ for table_name in $(toml_get_table_names); do
7983
fi
8084
app_args[arch]=$(toml_get "$t" arch) && {
8185
if ! isoneof "${app_args[arch]}" all arm64-v8a arm-v7a; then
82-
abort "ERROR: '${app_args[arch]}' is not a valid option for 'arch': only 'all', 'arm64-v8a', 'arm-v7a' is allowed"
86+
abort "ERROR: arch '${app_args[arch]}' is not a valid option for '${table_name}': only 'all', 'arm64-v8a', 'arm-v7a' is allowed"
8387
fi
8488
} || app_args[arch]="all"
8589
app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || {

scripts/customize.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22
ui_print ""
33

44
if [ $ARCH = "arm" ]; then
5-
alias cmpr='$MODPATH/bin/arm/cmpr'
5+
#arm
66
ARCH_LIB=armeabi-v7a
7-
elif [ $ARCH = "arm64" ] || [ $ARCH = "x64" ]; then
7+
alias cmpr='$MODPATH/bin/arm/cmpr'
8+
elif [ $ARCH = "arm64" ]; then
9+
#arm64
810
ARCH_LIB=arm64-v8a
911
alias cmpr='$MODPATH/bin/arm64/cmpr'
1012
else
1113
abort "ERROR: unsupported arch: ${ARCH}"
1214
fi
1315
set_perm_recursive $MODPATH/bin 0 0 0755 0777
1416

15-
grep __PKGNAME /proc/self/mountinfo | while read -r line; do
17+
grep __PKGNAME /proc/mounts | while read -r line; do
1618
ui_print "- Un-mount"
17-
mountpoint=$(echo "$line" | cut -d' ' -f5)
18-
umount -l "${mountpoint%%\\*}"
19+
mp=${line#* }
20+
mp=${mp%% *}
21+
umount -l ${mp%%\\*}
1922
done
2023
am force-stop __PKGNAME
2124

scripts/service.sh

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
MODDIR=${0%/*}
44
RVPATH=/data/adb/rvhc/__PKGNAME_rv.apk
55
until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
6-
timeout 15 logcat -T1 -m1 -e HOME ActivityManager:I
6+
until [ "$(getprop init.svc.bootanim)" = stopped ]; do sleep 1; done
7+
sleep 3
78

89
err() {
910
cp -n $MODDIR/module.prop $MODDIR/err
@@ -12,24 +13,28 @@ err() {
1213

1314
BASEPATH=$(pm path __PKGNAME | grep base)
1415
BASEPATH=${BASEPATH#*:}
15-
if [ $BASEPATH ] && [ -d ${BASEPATH%base.apk}lib ]; then
16-
VERSION=$(dumpsys package __PKGNAME | grep -m1 versionName)
17-
if [ ${VERSION#*=} = __PKGVER ]; then
18-
grep __PKGNAME /proc/mounts | while read -r line; do
19-
mp=${line#* }
20-
mp=${mp%% *}
21-
umount -l ${mp%%\\*}
22-
done
23-
if chcon u:object_r:apk_data_file:s0 $RVPATH; then
24-
mount -o bind $RVPATH $BASEPATH
25-
am force-stop __PKGNAME
26-
mv -f $MODDIR/err $MODDIR/module.prop 2>/dev/null
16+
if [ $BASEPATH ]; then
17+
if [ -d ${BASEPATH%base.apk}lib ]; then
18+
VERSION=$(dumpsys package __PKGNAME | grep -m1 versionName)
19+
if [ ${VERSION#*=} = __PKGVER ]; then
20+
grep __PKGNAME /proc/mounts | while read -r line; do
21+
mp=${line#* }
22+
mp=${mp%% *}
23+
umount -l ${mp%%\\*}
24+
done
25+
if chcon u:object_r:apk_data_file:s0 $RVPATH; then
26+
mount -o bind $RVPATH $BASEPATH
27+
am force-stop __PKGNAME
28+
[ -f $MODDIR/err ] && mv -f $MODDIR/err $MODDIR/module.prop
29+
else
30+
err "mount failed"
31+
fi
2732
else
28-
err "APK was not found"
33+
err "version mismatch (${VERSION#*=})"
2934
fi
3035
else
31-
err "Version mismatch (${VERSION#*=})"
36+
err "invalid installation"
3237
fi
3338
else
34-
err "Invalid installation"
39+
err "app not installed"
3540
fi

utils.sh

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,27 @@ pr() { echo -e "\033[0;32m[+] ${1}\033[0m"; }
3939

4040
get_prebuilts() {
4141
pr "Getting prebuilts"
42-
local rv_cli_url rv_integrations_url rv_patches rv_patches_changelog rv_patches_dl rv_patches_url
42+
local rv_cli_url rv_integrations_url rv_patches rv_patches_changelog rv_patches_dl rv_patches_url rv_integrations_rel rv_patches_rel
4343
rv_cli_url=$(gh_req "https://api.github.com/repos/j-hc/revanced-cli/releases/latest" - | json_get 'browser_download_url') || return 1
4444
RV_CLI_JAR="${PREBUILTS_DIR}/${rv_cli_url##*/}"
4545
log "CLI: ${rv_cli_url##*/}"
4646

47-
rv_integrations_url=$(gh_req "https://api.github.com/repos/${INTEGRATIONS_SRC}/releases/latest" - | json_get 'browser_download_url')
47+
if [ "$CONF_INTEGRATIONS_VER" ]; then
48+
rv_integrations_rel="https://api.github.com/repos/${INTEGRATIONS_SRC}/releases/tags/${CONF_INTEGRATIONS_VER}"
49+
else
50+
rv_integrations_rel="https://api.github.com/repos/${INTEGRATIONS_SRC}/releases/latest"
51+
fi
52+
if [ "$CONF_PATCHES_VER" ]; then
53+
rv_patches_rel="https://api.github.com/repos/${PATCHES_SRC}/releases/tags/${CONF_PATCHES_VER}"
54+
else
55+
rv_patches_rel="https://api.github.com/repos/${PATCHES_SRC}/releases/latest"
56+
fi
57+
58+
rv_integrations_url=$(gh_req "$rv_integrations_rel" - | json_get 'browser_download_url')
4859
RV_INTEGRATIONS_APK="${PREBUILTS_DIR}/${rv_integrations_url##*/}"
4960
log "Integrations: ${rv_integrations_url##*/}"
5061

51-
rv_patches=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" -)
62+
rv_patches=$(gh_req "$rv_patches_rel" -)
5263
rv_patches_changelog=$(echo "$rv_patches" | json_get 'body' | sed 's/\(\\n\)\+/\\n/g')
5364
rv_patches_dl=$(json_get 'browser_download_url' <<<"$rv_patches")
5465
RV_PATCHES_JSON="${PREBUILTS_DIR}/patches-$(json_get 'tag_name' <<<"$rv_patches").json"
@@ -68,9 +79,6 @@ get_prebuilts() {
6879
if [ "$(uname -m)" = aarch64 ]; then arch=arm64; else arch=arm; fi
6980
dl_if_dne ${TEMP_DIR}/aapt2 https://github.com/rendiix/termux-aapt/raw/main/prebuilt-binary/${arch}/aapt2
7081
fi
71-
}
72-
73-
get_cmpr() {
7482
mkdir -p ${MODULE_TEMPLATE_DIR}/bin/arm64 ${MODULE_TEMPLATE_DIR}/bin/arm
7583
dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/arm64/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-arm64-v8a"
7684
dl_if_dne "${MODULE_TEMPLATE_DIR}/bin/arm/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-armeabi-v7a"
@@ -156,13 +164,14 @@ dl_apkmirror() {
156164
}
157165
get_apkmirror_vers() {
158166
local apkmirror_category=$1 allow_alpha_version=$2
159-
local vers
167+
local vers apkm_resp
160168
apkm_resp=$(req "https://www.apkmirror.com/uploads/?appcategory=${apkmirror_category}" -)
161169
# apkm_name=$(echo "$apkm_resp" | sed -n 's;.*Latest \(.*\) Uploads.*;\1;p')
162170
vers=$(sed -n 's;.*Version:</span><span class="infoSlide-value">\(.*\) </span>.*;\1;p' <<<"$apkm_resp")
163171
if [ "$allow_alpha_version" = false ]; then
164172
local IFS=$'\n'
165173
vers=$(grep -iv "\(beta\|alpha\)" <<<"$vers")
174+
local v
166175
local r_vers=()
167176
for v in $vers; do
168177
grep -iq "${v} \(beta\|alpha\)" <<<"$apkm_resp" || r_vers+=("$v")
@@ -177,11 +186,12 @@ get_apkmirror_pkg_name() { req "$1" - | sed -n 's;.*id=\(.*\)" class="accent_col
177186

178187
# -------------------- uptodown --------------------
179188
get_uptodown_resp() { req "${1}/versions" -; }
180-
get_uptodown_vers() { sed -n 's;\(^.*\) <span>.*</span>.*;\1;p' <<<"$1"; }
189+
get_uptodown_vers() { sed -n 's;.*version>\(.*\)<\/span>$;\1;p' <<<"$1"; }
181190
dl_uptodown() {
182191
local uptwod_resp=$1 version=$2 output=$3
183-
url=$(echo "$uptwod_resp" | grep "${version} <span>" -B 1 | head -1 | sed -n 's;.*data-url="\(.*\)".*;\1;p')
184-
url=$(req "$url" - | sed -n 's;.*data-url="\(.*\)".*;\1;p')
192+
local url
193+
url=$(echo "$uptwod_resp" | grep "${version}<\/span>" -B 2 | head -1 | sed -n 's;.*data-url="\(.*\)".*;\1;p') || return 1
194+
url=$(req "$url" - | sed -n 's;.*data-url="\(.*\)".*;\1;p') || return 1
185195
req "$url" "$output"
186196
}
187197
get_uptodown_pkg_name() {
@@ -305,7 +315,7 @@ build_rv() {
305315
build_mode_arr=(apk module)
306316
fi
307317

308-
local patcher_args patched_apk
318+
local patcher_args patched_apk build_mode
309319
for build_mode in "${build_mode_arr[@]}"; do
310320
patcher_args=("${p_patcher_args[@]}")
311321
pr "Building '${app_name}' (${arch}) in '$build_mode' mode"
@@ -346,7 +356,7 @@ build_rv() {
346356

347357
uninstall_sh "$pkg_name" "$base_template"
348358
service_sh "$pkg_name" "$version" "$base_template"
349-
customize_sh "$pkg_name" "$version" "$base_template"
359+
customize_sh "$pkg_name" "$version" "$arch" "$base_template"
350360
module_prop \
351361
"${args[module_prop_name]}" \
352362
"${app_name} ${RV_BRAND}" \
@@ -371,7 +381,13 @@ join_args() {
371381
uninstall_sh() { echo "${UNINSTALL_SH//__PKGNAME/$1}" >"${2}/uninstall.sh"; }
372382
customize_sh() {
373383
local s="${CUSTOMIZE_SH//__PKGNAME/$1}"
374-
echo "${s//__PKGVER/$2}" >"${3}/customize.sh"
384+
# shellcheck disable=SC2016,SC2001
385+
if [ "$3" = "arm64-v8a" ]; then
386+
s=$(sed 's/#arm$/abort "ERROR: Wrong arch\nYour device: arm\nModule: arm64"/g' <<<"$s")
387+
elif [ "$3" = "arm-v7a" ]; then
388+
s=$(sed 's/#arm64$/abort "ERROR: Wrong arch\nYour device: arm64\nModule: arm"/g' <<<"$s")
389+
fi
390+
echo "${s//__PKGVER/$2}" >"${4}/customize.sh"
375391
}
376392
service_sh() {
377393
local s="${SERVICE_SH//__PKGNAME/$1}"

0 commit comments

Comments
 (0)