diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..8f3f22a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,11 @@ +--- +name: Bug report +about: Bug report +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +**DO NOT REPORT REVANCED BUGS IN THIS REPO** diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f97949..40b9741 100755 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,10 +17,19 @@ jobs: fetch-depth: 0 submodules: true + - name: Get last tag + id: last_tag + uses: oprypin/find-latest-tag@v1 + continue-on-error: true + with: + token: ${{ secrets.GITHUB_TOKEN }} + repository: ${{ github.repository }} + releases-only: true + - name: Get next version code id: next_ver_code run: | - TAG=$(git tag --sort=creatordate | tail -1) + TAG="${{ steps.last_tag.outputs.tag }}" if [ -z "$TAG" ]; then TAG=0; fi echo "NEXT_VER_CODE=$((TAG + 1))" >> $GITHUB_OUTPUT @@ -61,12 +70,10 @@ jobs: file_glob: true overwrite: false - - name: Switch to update branch - run: git checkout -f update || git switch --discard-changes --orphan update - - - name: Update changelog and Magisk update jsons + - name: Update changelog and Magisk update json id: update_config run: | + git checkout -f update || git switch --discard-changes --orphan update cp -f build.tmp build.md get_update_json() { echo "{ diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cdfdfb..589888a 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,14 +21,16 @@ jobs: toml_prep "$(cat config.toml)" is_youtube_latest() { - v=$(toml_get "$(toml_get_table "YouTube")" "version") || version="" + t=$(toml_get_table YouTube) + v=$(toml_get "$t" "version") || v= if [ "$v" = latest ]; then - declare -r cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs) + cur_yt=$(sed -n 's/.*YouTube: \(.*\)/\1/p' build.md | xargs) [ -z "$cur_yt" ] && return 1 # empty, fail=>dont build - declare -r last_ver=$(get_apk_vers "https://www.apkmirror.com/uploads/?appcategory=youtube" | get_largest_ver) - - echo "current yt version: $cur_yt" - echo "latest yt version: $last_ver" + aav=$(toml_get "$t" "allow-alpha-version") || aav=false + last_ver=$(get_apkmirror_vers youtube "$aav" | get_largest_ver) + [ -z "$last_ver" ] && return 1 # cant fetch, dont build + echo "current yt version: '$cur_yt'" + echo "latest yt version: '$last_ver'" [ "$cur_yt" != "$last_ver" ] # test success=>build, fail=>dont build else return 1 # not experimental, dont build @@ -37,8 +39,8 @@ jobs: is_patches_latest() { PATCHES_SRC=$(toml_get "$(toml_get_table "")" patches-source) || PATCHES_SRC="revanced/revanced-patches" - 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') - declare -r last_patches=${last_patches_url##*/} + 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') + last_patches=${last_patches_url##*/} cur_patches=$(sed -n 's/.*Patches: \(.*\)/\1/p' build.md | xargs) echo "current patches version: $cur_patches" diff --git a/CONFIG.md b/CONFIG.md index b307b7f..c305a60 100755 --- a/CONFIG.md +++ b/CONFIG.md @@ -15,9 +15,16 @@ uptodown-dlurl = "https://app.en.uptodown.com/android" ## If you'd like to get to know more about other options: There exists an example below with all defaults shown and all the keys explicitly set. -All keys are optional (except download urls) and are assigned to their default values if not set explicitly. +**All keys are optional** (except download urls) and are assigned to their default values if not set explicitly. ```toml +patches-source = "revanced/revanced-patches" # where to fetch patches bundle from. default: "revanced/revanced-patches" +integrations-source = "revanced/revanced-integrations" # where to fetch integrations from. default: "revanced/revanced-integrations" +rv-brand = "ReVanced Extended" # rebrand from 'ReVanced' to something different. default: "ReVanced" + +patches-version = "v2.160.0" # locks the patches version. default: latest available +integrations-version = "v0.95.0" # locks the integrations version. default: latest available + [Some-App] app-name = "SomeApp" # if set, app name becomes SomeApp instead of Some-App. default is same as table name, which is 'Some-App' here. # this affects the release name and stuff like that diff --git a/build.sh b/build.sh index 73f4bce..0c7d22d 100755 --- a/build.sh +++ b/build.sh @@ -3,7 +3,7 @@ set -euo pipefail source utils.sh -trap "rm -rf temp/tmp.*" INT +trap "rm -rf temp/tmp.*; exit 1" INT : >build.md @@ -21,12 +21,16 @@ vtf() { } toml_prep "$(cat 2>/dev/null "${1:-config.toml}")" || abort "could not find config file '${1}'" + +# -- Main config -- main_config_t=$(toml_get_table "") COMPRESSION_LEVEL=$(toml_get "$main_config_t" compression-level) || abort "ERROR: compression-level is missing" ENABLE_MAGISK_UPDATE=$(toml_get "$main_config_t" enable-magisk-update) || abort "ERROR: enable-magisk-update is missing" PARALLEL_JOBS=$(toml_get "$main_config_t" parallel-jobs) || abort "ERROR: parallel-jobs is missing" BUILD_MINDETACH_MODULE=$(toml_get "$main_config_t" build-mindetach-module) || abort "ERROR: build-mindetach-module is missing" LOGGING_F=$(toml_get "$main_config_t" logging-to-file) && vtf "$LOGGING_F" "logging-to-file" || LOGGING_F=false +CONF_PATCHES_VER=$(toml_get "$main_config_t" patches-version) || CONF_PATCHES_VER= +CONF_INTEGRATIONS_VER=$(toml_get "$main_config_t" integrations-version) || CONF_INTEGRATIONS_VER= PATCHES_SRC=$(toml_get "$main_config_t" patches-source) || PATCHES_SRC="revanced/revanced-patches" INTEGRATIONS_SRC=$(toml_get "$main_config_t" integrations-source) || INTEGRATIONS_SRC="revanced/revanced-integrations" @@ -35,13 +39,13 @@ RV_BRAND_F=${RV_BRAND,,} RV_BRAND_F=${RV_BRAND_F// /-} PREBUILTS_DIR="${TEMP_DIR}/tools-${RV_BRAND_F}" mkdir -p "$BUILD_DIR" "$PREBUILTS_DIR" +# -- Main config -- if ((COMPRESSION_LEVEL > 9)) || ((COMPRESSION_LEVEL < 0)); then abort "compression-level must be from 0 to 9"; fi if [ "${DRYRUN:-}" = true ]; then set_prebuilts; else get_prebuilts || set_prebuilts; fi if [ "$BUILD_MINDETACH_MODULE" = true ]; then : >$PKGS_LIST; fi if [ "$LOGGING_F" = true ]; then mkdir -p logs; fi jq --version >/dev/null || abort "\`jq\` is not installed. install it with 'apt install jq' or equivalent" -get_cmpr log "**App Versions:**" idx=0 @@ -61,7 +65,7 @@ for table_name in $(toml_get_table_names); do 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 app_args[build_mode]=$(toml_get "$t" build-mode) && { if ! isoneof "${app_args[build_mode]}" both apk module; then - abort "ERROR: '${app_args[build_mode]}' is not a valid option for '${table_name}': only 'both', 'apk' or 'module' is allowed" + abort "ERROR: build-mode '${app_args[build_mode]}' is not a valid option for '${table_name}': only 'both', 'apk' or 'module' is allowed" fi } || app_args[build_mode]=apk app_args[uptodown_dlurl]=$(toml_get "$t" uptodown-dlurl) && { @@ -79,7 +83,7 @@ for table_name in $(toml_get_table_names); do fi app_args[arch]=$(toml_get "$t" arch) && { if ! isoneof "${app_args[arch]}" all arm64-v8a arm-v7a; then - abort "ERROR: '${app_args[arch]}' is not a valid option for 'arch': only 'all', 'arm64-v8a', 'arm-v7a' is allowed" + abort "ERROR: arch '${app_args[arch]}' is not a valid option for '${table_name}': only 'all', 'arm64-v8a', 'arm-v7a' is allowed" fi } || app_args[arch]="all" app_args[module_prop_name]=$(toml_get "$t" module-prop-name) || { diff --git a/mindetach-magisk b/mindetach-magisk index 8f8dfda..fa84f53 160000 --- a/mindetach-magisk +++ b/mindetach-magisk @@ -1 +1 @@ -Subproject commit 8f8dfdac5809a1b436e6c9549c9a527c73b95941 +Subproject commit fa84f538dc23de961e40bd0b737d898910977eaf diff --git a/scripts/customize.sh b/scripts/customize.sh index b144ea4..5719914 100755 --- a/scripts/customize.sh +++ b/scripts/customize.sh @@ -2,9 +2,11 @@ ui_print "" if [ $ARCH = "arm" ]; then - alias cmpr='$MODPATH/bin/arm/cmpr' + #arm ARCH_LIB=armeabi-v7a -elif [ $ARCH = "arm64" ] || [ $ARCH = "x64" ]; then + alias cmpr='$MODPATH/bin/arm/cmpr' +elif [ $ARCH = "arm64" ]; then + #arm64 ARCH_LIB=arm64-v8a alias cmpr='$MODPATH/bin/arm64/cmpr' else @@ -12,10 +14,11 @@ else fi set_perm_recursive $MODPATH/bin 0 0 0755 0777 -grep __PKGNAME /proc/self/mountinfo | while read -r line; do +grep __PKGNAME /proc/mounts | while read -r line; do ui_print "- Un-mount" - mountpoint=$(echo "$line" | cut -d' ' -f5) - umount -l "${mountpoint%%\\*}" + mp=${line#* } + mp=${mp%% *} + umount -l ${mp%%\\*} done am force-stop __PKGNAME diff --git a/scripts/service.sh b/scripts/service.sh index d4cd598..64ccc22 100755 --- a/scripts/service.sh +++ b/scripts/service.sh @@ -3,7 +3,8 @@ MODDIR=${0%/*} RVPATH=/data/adb/rvhc/__PKGNAME_rv.apk until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done -timeout 15 logcat -T1 -m1 -e HOME ActivityManager:I +until [ "$(getprop init.svc.bootanim)" = stopped ]; do sleep 1; done +sleep 3 err() { cp -n $MODDIR/module.prop $MODDIR/err @@ -12,24 +13,28 @@ err() { BASEPATH=$(pm path __PKGNAME | grep base) BASEPATH=${BASEPATH#*:} -if [ $BASEPATH ] && [ -d ${BASEPATH%base.apk}lib ]; then - VERSION=$(dumpsys package __PKGNAME | grep -m1 versionName) - if [ ${VERSION#*=} = __PKGVER ]; then - grep __PKGNAME /proc/mounts | while read -r line; do - mp=${line#* } - mp=${mp%% *} - umount -l ${mp%%\\*} - done - if chcon u:object_r:apk_data_file:s0 $RVPATH; then - mount -o bind $RVPATH $BASEPATH - am force-stop __PKGNAME - mv -f $MODDIR/err $MODDIR/module.prop 2>/dev/null +if [ $BASEPATH ]; then + if [ -d ${BASEPATH%base.apk}lib ]; then + VERSION=$(dumpsys package __PKGNAME | grep -m1 versionName) + if [ ${VERSION#*=} = __PKGVER ]; then + grep __PKGNAME /proc/mounts | while read -r line; do + mp=${line#* } + mp=${mp%% *} + umount -l ${mp%%\\*} + done + if chcon u:object_r:apk_data_file:s0 $RVPATH; then + mount -o bind $RVPATH $BASEPATH + am force-stop __PKGNAME + [ -f $MODDIR/err ] && mv -f $MODDIR/err $MODDIR/module.prop + else + err "mount failed" + fi else - err "APK was not found" + err "version mismatch (${VERSION#*=})" fi else - err "Version mismatch (${VERSION#*=})" + err "invalid installation" fi else - err "Invalid installation" + err "app not installed" fi diff --git a/utils.sh b/utils.sh index 2679289..d5ade31 100755 --- a/utils.sh +++ b/utils.sh @@ -39,16 +39,27 @@ pr() { echo -e "\033[0;32m[+] ${1}\033[0m"; } get_prebuilts() { pr "Getting prebuilts" - local rv_cli_url rv_integrations_url rv_patches rv_patches_changelog rv_patches_dl rv_patches_url + local rv_cli_url rv_integrations_url rv_patches rv_patches_changelog rv_patches_dl rv_patches_url rv_integrations_rel rv_patches_rel rv_cli_url=$(gh_req "https://api.github.com/repos/j-hc/revanced-cli/releases/latest" - | json_get 'browser_download_url') || return 1 RV_CLI_JAR="${PREBUILTS_DIR}/${rv_cli_url##*/}" log "CLI: ${rv_cli_url##*/}" - rv_integrations_url=$(gh_req "https://api.github.com/repos/${INTEGRATIONS_SRC}/releases/latest" - | json_get 'browser_download_url') + if [ "$CONF_INTEGRATIONS_VER" ]; then + rv_integrations_rel="https://api.github.com/repos/${INTEGRATIONS_SRC}/releases/tags/${CONF_INTEGRATIONS_VER}" + else + rv_integrations_rel="https://api.github.com/repos/${INTEGRATIONS_SRC}/releases/latest" + fi + if [ "$CONF_PATCHES_VER" ]; then + rv_patches_rel="https://api.github.com/repos/${PATCHES_SRC}/releases/tags/${CONF_PATCHES_VER}" + else + rv_patches_rel="https://api.github.com/repos/${PATCHES_SRC}/releases/latest" + fi + + rv_integrations_url=$(gh_req "$rv_integrations_rel" - | json_get 'browser_download_url') RV_INTEGRATIONS_APK="${PREBUILTS_DIR}/${rv_integrations_url##*/}" log "Integrations: ${rv_integrations_url##*/}" - rv_patches=$(gh_req "https://api.github.com/repos/${PATCHES_SRC}/releases/latest" -) + rv_patches=$(gh_req "$rv_patches_rel" -) rv_patches_changelog=$(echo "$rv_patches" | json_get 'body' | sed 's/\(\\n\)\+/\\n/g') rv_patches_dl=$(json_get 'browser_download_url' <<<"$rv_patches") RV_PATCHES_JSON="${PREBUILTS_DIR}/patches-$(json_get 'tag_name' <<<"$rv_patches").json" @@ -68,9 +79,6 @@ get_prebuilts() { if [ "$(uname -m)" = aarch64 ]; then arch=arm64; else arch=arm; fi dl_if_dne ${TEMP_DIR}/aapt2 https://github.com/rendiix/termux-aapt/raw/main/prebuilt-binary/${arch}/aapt2 fi -} - -get_cmpr() { 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/arm/cmpr" "https://github.com/j-hc/cmpr/releases/latest/download/cmpr-armeabi-v7a" @@ -156,13 +164,14 @@ dl_apkmirror() { } get_apkmirror_vers() { local apkmirror_category=$1 allow_alpha_version=$2 - local vers + local vers apkm_resp apkm_resp=$(req "https://www.apkmirror.com/uploads/?appcategory=${apkmirror_category}" -) # apkm_name=$(echo "$apkm_resp" | sed -n 's;.*Latest \(.*\) Uploads.*;\1;p') vers=$(sed -n 's;.*Version:\(.*\) .*;\1;p' <<<"$apkm_resp") if [ "$allow_alpha_version" = false ]; then local IFS=$'\n' vers=$(grep -iv "\(beta\|alpha\)" <<<"$vers") + local v local r_vers=() for v in $vers; do 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 # -------------------- uptodown -------------------- get_uptodown_resp() { req "${1}/versions" -; } -get_uptodown_vers() { sed -n 's;\(^.*\) .*.*;\1;p' <<<"$1"; } +get_uptodown_vers() { sed -n 's;.*version>\(.*\)<\/span>$;\1;p' <<<"$1"; } dl_uptodown() { local uptwod_resp=$1 version=$2 output=$3 - url=$(echo "$uptwod_resp" | grep "${version} " -B 1 | head -1 | sed -n 's;.*data-url="\(.*\)".*;\1;p') - url=$(req "$url" - | sed -n 's;.*data-url="\(.*\)".*;\1;p') + local url + url=$(echo "$uptwod_resp" | grep "${version}<\/span>" -B 2 | head -1 | sed -n 's;.*data-url="\(.*\)".*;\1;p') || return 1 + url=$(req "$url" - | sed -n 's;.*data-url="\(.*\)".*;\1;p') || return 1 req "$url" "$output" } get_uptodown_pkg_name() { @@ -305,7 +315,7 @@ build_rv() { build_mode_arr=(apk module) fi - local patcher_args patched_apk + local patcher_args patched_apk build_mode for build_mode in "${build_mode_arr[@]}"; do patcher_args=("${p_patcher_args[@]}") pr "Building '${app_name}' (${arch}) in '$build_mode' mode" @@ -346,7 +356,7 @@ build_rv() { uninstall_sh "$pkg_name" "$base_template" service_sh "$pkg_name" "$version" "$base_template" - customize_sh "$pkg_name" "$version" "$base_template" + customize_sh "$pkg_name" "$version" "$arch" "$base_template" module_prop \ "${args[module_prop_name]}" \ "${app_name} ${RV_BRAND}" \ @@ -371,7 +381,13 @@ join_args() { uninstall_sh() { echo "${UNINSTALL_SH//__PKGNAME/$1}" >"${2}/uninstall.sh"; } customize_sh() { local s="${CUSTOMIZE_SH//__PKGNAME/$1}" - echo "${s//__PKGVER/$2}" >"${3}/customize.sh" + # shellcheck disable=SC2016,SC2001 + if [ "$3" = "arm64-v8a" ]; then + s=$(sed 's/#arm$/abort "ERROR: Wrong arch\nYour device: arm\nModule: arm64"/g' <<<"$s") + elif [ "$3" = "arm-v7a" ]; then + s=$(sed 's/#arm64$/abort "ERROR: Wrong arch\nYour device: arm64\nModule: arm"/g' <<<"$s") + fi + echo "${s//__PKGVER/$2}" >"${4}/customize.sh" } service_sh() { local s="${SERVICE_SH//__PKGNAME/$1}"