diff --git a/CONFIG.md b/CONFIG.md index 81ee3b1..7c53514 100755 --- a/CONFIG.md +++ b/CONFIG.md @@ -12,8 +12,13 @@ apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" ## More about other options: +<<<<<<< HEAD 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. +======= +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. +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 ```toml parallel-jobs = 1 # amount of cores to use for parallel patching, if not set $(nproc) is used @@ -52,7 +57,11 @@ excluded-patches = """\ """ included-patches = "'Some Patch'" # whitespace seperated list of non-default patches to include. default: "" +<<<<<<< HEAD include-stock = true # includes stock apk in the module. default: true +======= +include-stock = "merged" # 'merged', 'split' or 'disable'. default: merged +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 exclusive-patches = false # exclude all patches by default. default: false apkmirror-dlurl = "https://www.apkmirror.com/apk/inc/app" diff --git a/build.sh b/build.sh index b5c8c57..6c92891 100755 --- a/build.sh +++ b/build.sh @@ -33,7 +33,10 @@ DEF_CLI_VER=$(toml_get "$main_config_t" cli-version) || DEF_CLI_VER="latest" DEF_PATCHES_SRC=$(toml_get "$main_config_t" patches-source) || DEF_PATCHES_SRC="ReVanced/revanced-patches" DEF_CLI_SRC=$(toml_get "$main_config_t" cli-source) || DEF_CLI_SRC="ReVanced/revanced-cli" DEF_RV_BRAND=$(toml_get "$main_config_t" rv-brand) || DEF_RV_BRAND="ReVanced" +<<<<<<< HEAD DEF_DPI_LIST=$(toml_get "$main_config_t" dpi) || DEF_DPI_LIST="nodpi anydpi" +======= +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 mkdir -p "$TEMP_DIR" "$BUILD_DIR" if [ "${2-}" = "--config-update" ]; then @@ -41,10 +44,13 @@ if [ "${2-}" = "--config-update" ]; then exit 0 fi +<<<<<<< HEAD # Save old build-state.md for diff-based changelog (full state from previous build) if [ -f build-state.md ] && [ -s build-state.md ]; then cp build-state.md "$TEMP_DIR/old_build_state.md" fi +======= +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 : >build.md ENABLE_MODULE_UPDATE=$(toml_get "$main_config_t" enable-module-update) || ENABLE_MODULE_UPDATE=true if [ "$ENABLE_MODULE_UPDATE" = true ] && [ -z "${GITHUB_REPOSITORY-}" ]; then @@ -105,6 +111,14 @@ for table_name in $(toml_get_table_names); do 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 +<<<<<<< HEAD +======= + app_args[include_stock]=$(toml_get "$t" include-stock) && { + if ! isoneof "${app_args[include_stock]}" disable merged split; then + abort "ERROR: include-stock '${app_args[include_stock]}' is not a valid option for '${table_name}': only 'disable', 'merged' or 'split' is allowed" + fi + } || app_args[include_stock]=merged +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 for dl_from in "${DL_SRCS[@]}"; do if app_args[${dl_from}_dlurl]=$(toml_get "$t" "${dl_from}-dlurl"); then @@ -122,8 +136,13 @@ for table_name in $(toml_get_table_names); do abort "wrong arch '${app_args[arch]}' for '$table_name'" fi +<<<<<<< HEAD app_args[include_stock]=$(toml_get "$t" include-stock) || app_args[include_stock]=true && vtf "${app_args[include_stock]}" "include-stock" app_args[dpi]=$(toml_get "$t" dpi) || app_args[dpi]="$DEF_DPI_LIST" +======= + app_args[pkg_name]=$(toml_get "$t" pkg-name) || app_args[pkg_name]="" + app_args[dpi]=$(toml_get "$t" dpi) || app_args[dpi]="" +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 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" @@ -158,6 +177,7 @@ wait rm -rf temp/tmp.* if [ -z "$(ls -A1 "${BUILD_DIR}")" ]; then abort "All builds failed."; fi +<<<<<<< HEAD # Initial changelog logic # log "\nInstall [MicroG-RE](https://github.com/MorpheApp/MicroG-RE/releases) for non-root YouTube and YT Music APKs" # log "Use [zygisk-detach](https://github.com/j-hc/zygisk-detach) to detach root ReVanced YouTube and YT Music from Play Store" @@ -191,6 +211,12 @@ if [ -f "$TEMP_DIR/old_build_state.md" ]; then fi done <<<"$_full_build" fi +======= +log "\nInstall [Microg](https://github.com/ReVanced/GmsCore/releases) for non-root YouTube and YT Music APKs" +log "Use [zygisk-detach](https://github.com/j-hc/zygisk-detach) to detach YouTube and YT Music modules from Play Store" +log "\n[revanced-magisk-module](https://github.com/j-hc/revanced-magisk-module)\n" +log "$(cat "$TEMP_DIR"/*/changelog.md)" +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 SKIPPED=$(cat "$TEMP_DIR"/skipped 2>/dev/null || :) if [ -n "$SKIPPED" ]; then @@ -198,6 +224,7 @@ if [ -n "$SKIPPED" ]; then log "$SKIPPED" fi +<<<<<<< HEAD # New skipped changelog logic with links (@ev3rlin changes) # SKIPPED=$(cat "$TEMP_DIR"/skipped 2>/dev/null || :) @@ -214,4 +241,6 @@ fi # log "$(cat "$TEMP_DIR"/*-rv/changelog.md)" # fi +======= +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 pr "Done" diff --git a/config.toml b/config.toml index 318766e..800d9ad 100755 --- a/config.toml +++ b/config.toml @@ -6,6 +6,7 @@ parallel-jobs = 1 # you can use rvmm-config-gen to generate a config +<<<<<<< HEAD patches-source = "anddea/revanced-patches" patches-version = "latest" @@ -37,3 +38,71 @@ archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.a excluded-patches = "'Custom header for YouTube Music'" included-patches = "'Visual preferences icons for YouTube Music' 'Return YouTube Username' 'Disable music video in album'" patcher-args = "-e 'Custom branding name for YouTube Music' -OappName='YT Music RVX' -e 'Custom branding icon for YouTube Music' -OappIcon='vanced_black'" +======= +[YouTube] +build-mode = "both" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube" +uptodown-dlurl = "https://youtube.en.uptodown.com/android" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube" + +[YouTube-Morphe] +app-name = "YouTube" +patches-source = "MorpheApp/morphe-patches" +cli-source = "MorpheApp/morphe-cli" +rv-brand = "Morphe" +build-mode = "both" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube" +uptodown-dlurl = "https://youtube.en.uptodown.com/android" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.youtube" + +[Music] +build-mode = "both" +arch = "both" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music" +uptodown-dlurl = "https://youtube-music.en.uptodown.com/android" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" + +[Music-Morphe] +app-name = "Music" +patches-source = "MorpheApp/morphe-patches" +cli-source = "MorpheApp/morphe-cli" +rv-brand = "Morphe" +build-mode = "both" +arch = "both" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/youtube-music" +uptodown-dlurl = "https://youtube-music.en.uptodown.com/android" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.youtube.music" + +[Reddit-Morphe] +app-name = "Reddit" +rv-brand = "Morphe" +build-mode = "both" +patches-source = "MorpheApp/morphe-patches" +cli-source = "MorpheApp/morphe-cli" +apkmirror-dlurl = "https://www.apkmirror.com/apk/redditinc/reddit/" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.reddit.frontpage" +uptodown-dlurl = "https://reddit-official-app.en.uptodown.com/android" +dpi = "120-640dpi" + +[Twitter] +patches-source = "crimera/piko" +cli-source = "MorpheApp/morphe-cli" +rv-brand = "Piko" +apkmirror-dlurl = "https://www.apkmirror.com/apk/x-corp/twitter/" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.twitter.android" +build-mode = "module" +version = "11.81.0-release.0" +include-stock = "split" + +[GooglePhotos] +build-mode = "both" +arch = "both" +apkmirror-dlurl = "https://www.apkmirror.com/apk/google-inc/photos/" +uptodown-dlurl = "https://google-photos.en.uptodown.com/android" +archive-dlurl = "https://archive.org/download/jhc-apks/apks/com.google.android.apps.photos" + +[Twitch] +enabled = false +apkmirror-dlurl = "https://www.apkmirror.com/apk/twitch-interactive-inc/twitch/" +uptodown-dlurl = "https://twitch.en.uptodown.com/android" +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 diff --git a/module/customize.sh b/module/customize.sh index 6ce2220..49278fe 100755 --- a/module/customize.sh +++ b/module/customize.sh @@ -37,6 +37,7 @@ pmex() { return $RET } +<<<<<<< HEAD if ! pmex path "$PKG_NAME" >&2; then if pmex install-existing "$PKG_NAME" >&2; then pmex uninstall-system-updates "$PKG_NAME" @@ -44,11 +45,24 @@ if ! pmex path "$PKG_NAME" >&2; then fi IS_SYS=false +======= +if OP=$(dumpsys package "$PKG_NAME") && [ "$OP" ]; then + if echo "$OP" | grep -m1 pkgFlags | grep -Fq UPDATED_SYSTEM_APP; then + pmex uninstall-system-updates "$PKG_NAME" >/dev/null 2>&1 + fi +else + if pmex install-existing "$PKG_NAME" >/dev/null 2>&1; then + pmex uninstall-system-updates "$PKG_NAME" >/dev/null 2>&1 + fi +fi + +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 INS=true if BASEPATH=$(pmex path "$PKG_NAME"); then echo >&2 "'$BASEPATH'" BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*} if [ "${BASEPATH:1:4}" != data ]; then +<<<<<<< HEAD ui_print "* $PKG_NAME is a system app." IS_SYS=true elif [ ! -f "$MODPATH/$PKG_NAME.apk" ]; then @@ -74,19 +88,63 @@ install() { abort "ERROR: Stock $PKG_NAME apk was not found" fi ui_print "* Updating $PKG_NAME to $PKG_VER" +======= + ui_print "* Detected $PKG_NAME as a system app" + SCNM="/data/adb/post-fs-data.d/$PKG_NAME-uninstall.sh" + mkdir -p /data/adb/post-fs-data.d + echo "mount -t tmpfs none $BASEPATH" >"$SCNM" + chmod +x "$SCNM" + ui_print "* Created the uninstall script." + ui_print "" + ui_print "* Reboot and reflash the module!" + abort + fi + + VERSION=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 versionName=) VERSION="${VERSION#*=}" + if [ "$VERSION" ] && [ "$VERSION" = "$PKG_VER" ]; then + ui_print "* $PKG_NAME is up-to-date ($VERSION)" + INS=false + elif [ ! -f "$MODPATH/stock/base.apk" ]; then + ui_print "ERROR: Version mismatch + installed: '$VERSION' + module: '$PKG_VER'" + abort + fi + + # TODO: + # elif "${MODPATH:?}/bin/$ARCH/cmpr" "$BASEPATH/base.apk" "$MODPATH/$PKG_NAME.apk"; then + # ui_print "* $PKG_NAME is up-to-date" + # INS=false + # fi +fi + +install() { + if [ ! -f "$MODPATH/stock/base.apk" ]; then + abort "ERROR: Stock $PKG_NAME apk was not found" + fi +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 install_err="" VERIF1=$(settings get global verifier_verify_adb_installs) VERIF2=$(settings get global package_verifier_enable) settings put global verifier_verify_adb_installs 0 settings put global package_verifier_enable 0 +<<<<<<< HEAD SZ=$(stat -c "%s" "$MODPATH/$PKG_NAME.apk") for IT in 1 2; do if ! SES=$(pmex install-create --user 0 -i com.android.vending -r -d -S "$SZ"); then +======= + + SZ=$(stat -c "%s" "$MODPATH"/stock/*.apk | awk '{sum += $0} END {print sum}') + for IT in 1 2; do + ui_print "* Updating $PKG_NAME to $PKG_VER" + if ! SES=$(pmex install-create --user 0 -i com.android.vending -r -S "$SZ"); then +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 ui_print "ERROR: install-create failed" install_err="$SES" break fi SES=${SES#*[} SES=${SES%]*} +<<<<<<< HEAD set_perm "$MODPATH/$PKG_NAME.apk" 1000 1000 644 u:object_r:apk_data_file:s0 if ! op=$(pmex install-write -S "$SZ" "$SES" "$PKG_NAME.apk" "$MODPATH/$PKG_NAME.apk"); then ui_print "ERROR: install-write failed" @@ -129,6 +187,31 @@ install() { fi continue fi +======= + + for apki in "$MODPATH/stock"/*.apk; do + set_perm "${apki}" 1000 1000 644 u:object_r:apk_data_file:s0 + if ! op=$(pmex install-write -S "$SZ" "$SES" "$(basename "${apki}")" "${apki}"); then + ui_print "ERROR: install-write failed" + install_err="$op" + break + fi + done + if [ "$install_err" ]; then break; fi + + if ! op=$(pmex install-commit "$SES"); then + ui_print "$op" + if echo "$op" | grep -q -e INSTALL_FAILED_VERSION_DOWNGRADE -e INSTALL_FAILED_UPDATE_INCOMPATIBLE; then + ui_print "* Uninstalling..." + if ! op=$(pmex uninstall "$PKG_NAME"); then + ui_print "$op" + if [ $IT = 2 ]; then + install_err="ERROR: pm uninstall failed." + break + fi + fi + continue +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 fi ui_print "ERROR: install-commit failed" install_err="$op" @@ -145,8 +228,12 @@ install() { settings put global verifier_verify_adb_installs "$VERIF1" settings put global package_verifier_enable "$VERIF2" if [ "$install_err" ]; then +<<<<<<< HEAD ui_print "$install_err" abort "ERROR: disable the module, reboot, install $PKG_NAME manually and reflash again" +======= + abort "$install_err" +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 fi } if [ $INS = true ] && ! install; then abort; fi @@ -154,11 +241,19 @@ BASEPATHLIB=${BASEPATH}/lib/${ARCH} if [ $INS = true ] || [ -z "$(ls -A1 "$BASEPATHLIB")" ]; then ui_print "* Extracting native libs" if [ ! -d "$BASEPATHLIB" ]; then mkdir -p "$BASEPATHLIB"; else rm -f "$BASEPATHLIB"/* >/dev/null 2>&1 || :; fi +<<<<<<< HEAD if ! op=$(unzip -o -j "$MODPATH/$PKG_NAME.apk" "lib/${ARCH_LIB}/*" -d "$BASEPATHLIB" 2>&1); then ui_print "ERROR: extracting native libs failed" abort "$op" fi set_perm_recursive "${BASEPATH}/lib" 1000 1000 755 755 u:object_r:apk_data_file:s0 +======= + if op=$(unzip -o -j "$MODPATH/stock/base.apk" "lib/${ARCH_LIB}/*" -d "$BASEPATHLIB" 2>&1); then + set_perm_recursive "${BASEPATH}/lib" 1000 1000 755 755 u:object_r:apk_data_file:s0 + else + echo >&2 "ERROR: extracting native libs failed: '$op'" + fi +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 fi ui_print "* Setting Permissions" @@ -176,6 +271,7 @@ fi am force-stop "$PKG_NAME" ui_print "* Optimizing $PKG_NAME" +<<<<<<< HEAD cmd package compile -m speed-profile -f "$PKG_NAME" # nohup cmd package compile -m speed-profile -f "$PKG_NAME" >/dev/null 2>&1 @@ -184,6 +280,16 @@ if [ "$KSU" ]; then UID=${UID#*=} UID=${UID%% *} if [ -z "$UID" ]; then UID=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 userId) +======= +cmd package compile -m speed-profile -f "$PKG_NAME" >/dev/null 2>&1 +# nohup cmd package compile -m speed-profile -f "$PKG_NAME" >/dev/null 2>&1 + +if [ "$KSU" ]; then + UID=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 uid=) + UID=${UID#*=} UID=${UID%% *} + if [ -z "$UID" ]; then + UID=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 userId=) +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 UID=${UID#*=} UID=${UID%% *} fi if [ "$UID" ]; then @@ -191,6 +297,7 @@ if [ "$KSU" ]; then ui_print " $OP" ui_print "* Because you are using a fork of KernelSU, " ui_print " you need to go to your root manager app and" +<<<<<<< HEAD ui_print " disable 'Unmount modules' option for $PKG_NAME" fi else @@ -200,6 +307,16 @@ if [ "$KSU" ]; then fi rm -rf "${MODPATH:?}/bin" "$MODPATH/$PKG_NAME.apk" +======= + ui_print " disable 'Unmount modules' for $PKG_NAME" + fi + else + ui_print "ERROR: UID could not be found for $PKG_NAME" + fi +fi + +rm -rf "${MODPATH:?}/bin" "$MODPATH/stock/" +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 ui_print "* Done" ui_print " by j-hc (github.com/j-hc)" diff --git a/module/service.sh b/module/service.sh index bd83d9e..122de53 100755 --- a/module/service.sh +++ b/module/service.sh @@ -25,7 +25,11 @@ run() { BASEPATH=${BASEPATH##*:} BASEPATH=${BASEPATH%/*} if [ ! -d "$BASEPATH/lib" ]; then +<<<<<<< HEAD err "mount failed (ROM issue). Dont report this, consider using rvmm-zygisk-mount." +======= + err "mount failed. Dont report this, consider using rvmm-zygisk-mount" +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 return fi VERSION=$(dumpsys package "$PKG_NAME" 2>&1 | grep -m1 versionName) VERSION="${VERSION#*=}" diff --git a/module/uninstall.sh b/module/uninstall.sh index 7854a99..862eaf3 100755 --- a/module/uninstall.sh +++ b/module/uninstall.sh @@ -1,4 +1,5 @@ #!/system/bin/sh +<<<<<<< HEAD { until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done @@ -11,3 +12,13 @@ rmdir "/data/adb/rvhc" rm "/data/adb/post-fs-data.d/$PKG_NAME-uninstall.sh" } & +======= + +MODDIR=${0%/*} +. "$MODDIR/config" + +rm -f "/data/adb/rvhc/${MODDIR##*/}.apk" +rmdir "/data/adb/rvhc" + +rm -f "/data/adb/post-fs-data.d/$PKG_NAME-uninstall.sh" +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 diff --git a/sig.txt b/sig.txt index e2f24c1..544a1b4 100644 --- a/sig.txt +++ b/sig.txt @@ -1,5 +1,8 @@ a2a1ad7ba7f41dfca4514e2afeb90691719af6d0fdbed4b09bbf0ed897701ceb com.google.android.apps.youtube.music 3d7a1223019aa39d9ea0e3436ab7c0896bfb4fb679f4de5fe7c23f326c8f994a com.google.android.youtube 970b91143813b4c9d5f3634f672c9fcaa5621b4efaaedafd6c235cbbb869736f com.reddit.frontpage +<<<<<<< HEAD 9041803e91bcb814b4b4399fb5c85a91640b755e5e8ba76813814bf4cf2ab5ba com.zhiliaoapp.musically +======= +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 1338f9b049893cc70b78432a177582f90bd4bc6296ea4ed35bcc7df59687ac53 tv.twitch.android.app diff --git a/utils.sh b/utils.sh index ab4c542..d73361d 100755 --- a/utils.sh +++ b/utils.sh @@ -126,6 +126,7 @@ get_prebuilts() { fi if [ "$tag" = "Patches" ]; then +<<<<<<< HEAD # Initial changelog structure if [ "$grab_cl" = true ]; then echo -e "[Patches Changelog](https://github.com/${src}/releases/tag/${tag_name})\n" >>"${cl_dir}/changelog.md"; fi @@ -135,6 +136,9 @@ get_prebuilts() { # echo -e "$changelog_body\n" >>"${cl_dir}/changelog.md" # fi +======= + if [ "$grab_cl" = true ]; then echo -e "[Changelog](https://github.com/${src}/releases/tag/${tag_name})\n" >>"${cl_dir}/changelog.md"; fi +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 if [ "$REMOVE_RV_INTEGRATIONS_CHECKS" = true ]; then local extensions_ext extensions_ext=$(unzip -l "${file}" "extensions/shared.*" | grep -o "shared\..*") extensions_ext="${extensions_ext#*.}" @@ -167,6 +171,7 @@ set_prebuilts() { TOML="${BIN_DIR}/toml/tq-${arch}" } +<<<<<<< HEAD # (@ev3rlin changes) get_latest_app_version() { local src=$1 app=$2 @@ -216,6 +221,8 @@ auto_update_app_versions() { [ "$updated" = true ] } +======= +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 config_update() { if [ ! -f build.md ]; then abort "build.md not available"; fi declare -A sources @@ -328,7 +335,11 @@ get_patch_last_supported_ver() { fi fi op=$(patches_list_versions "$cli_jar" "$patches_jar" "$pkg_name") || return 1 +<<<<<<< HEAD op=$(sed -n '/(.* patch.*/,$p' <<<"$op" | awk '{$1=$1}1') +======= + op=$(sed -n '/Most common compatible versions:/,$p' <<<"$op" | sed '1d' | awk '{$1=$1}1') +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 if [ "$op" = "Any" ]; then return; fi pcount=$(head -1 <<<"$op") pcount=${pcount#*(} pcount=${pcount% *} if [ -z "$pcount" ]; then @@ -338,6 +349,7 @@ get_patch_last_supported_ver() { } patches_list_versions() { +<<<<<<< HEAD local cli_jar=$1 patches_jar=$2 pkg_name=$3 op if ! op=$(java -jar "$cli_jar" list-versions -p "$patches_jar" -f "$pkg_name" -b 2>&1); then if ! op=$(java -jar "$cli_jar" list-versions "$patches_jar" -f "$pkg_name" 2>&1); then @@ -346,6 +358,30 @@ patches_list_versions() { fi fi echo "$op" +======= + local cli_jar=$1 patches_jar=$2 pkg_name=$3 op cmd + local cmd_base="java -jar '$cli_jar' list-versions" + + # TODO: remove this later + local cli_name + cli_name=$(basename "$cli_jar") + if [ "${cli_name::8}" = revanced ]; then cmd_base+=" -b"; fi + + cmd="${cmd_base} --patches='$patches_jar' -f '$pkg_name'" + if op=$(eval "$cmd" 2>&1); then + echo "$op" + return + fi + + cmd="${cmd_base} '$patches_jar' -f '$pkg_name'" + if op=$(eval "$cmd" 2>&1); then + echo "$op" + return + fi + + epr "Could not list versions $cli_jar: '$op'" + return 1 +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 } patches_list() { local cli_jar=$1 patches_jar=$2 pkg_name=$3 op @@ -387,20 +423,43 @@ merge_splits() { # -------------------- apkmirror -------------------- apkmirror_search() { local resp="$1" dpi="$2" arch="$3" apk_bundle="$4" +<<<<<<< HEAD local apparch dlurl="" node app_table emptyCheck if [ "$arch" = all ]; then apparch=(universal noarch 'arm64-v8a + armeabi-v7a') else apparch=("$arch" universal noarch 'arm64-v8a + armeabi-v7a'); fi +======= + local dlurl="" node app_table emptyCheck + + local apparch=('universal' 'noarch' 'arm64-v8a + armeabi-v7a') + if [ "$arch" != all ]; then + apparch+=("$arch") + fi + + local appdpi=("nodpi" "anydpi") + if [ "$dpi" ]; then + appdpi+=($dpi) + fi + +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 for ((n = 1; n < 40; n++)); do node=$($HTMLQ "div.table-row.headerFont:nth-last-child($n)" -r "span:nth-child(n+3)" <<<"$resp") if [ -z "$node" ]; then break; fi emptyCheck=$($HTMLQ -t -w "div.table-cell:nth-child(1) > a:nth-child(1)" <<<"$node" | xargs) +<<<<<<< HEAD if [ "$emptyCheck" ]; then dlurl=$($HTMLQ --base https://www.apkmirror.com --attribute href "div:nth-child(1) > a:nth-child(1)" <<<"$node") else break; fi app_table=$($HTMLQ --text --ignore-whitespace <<<"$node") if [ "$(sed -n 3p <<<"$app_table")" = "$apk_bundle" ] && [ "$(sed -n 6p <<<"$app_table")" = "$dpi" ] && +======= + if [ -z "$emptyCheck" ]; then break; fi + app_table=$($HTMLQ --text --ignore-whitespace <<<"$node") + if [ "$(sed -n 3p <<<"$app_table")" != "$apk_bundle" ]; then continue; fi + dlurl=$($HTMLQ --base https://www.apkmirror.com --attribute href "div:nth-child(1) > a:nth-child(1)" <<<"$node") + if isoneof "$(sed -n 6p <<<"$app_table")" "${appdpi[@]}" && +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 isoneof "$(sed -n 4p <<<"$app_table")" "${apparch[@]}"; then echo "$dlurl" return 0 @@ -415,6 +474,7 @@ apkmirror_search() { } dl_apkmirror() { local url=$1 version=${2// /-} output=$3 arch=$4 dpi=$5 is_bundle=false +<<<<<<< HEAD if [ -f "${output}.apkm" ]; then is_bundle=true else @@ -441,6 +501,36 @@ dl_apkmirror() { url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]") || return 1 fi +======= + + if [ -f "${output}.apkm" ]; then + merge_splits "${output}.apkm" "${output}" + return 0 + fi + + if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi + local resp node app_table apkmname dlurl="" + apkmname=$($HTMLQ "h1.marginZero" --text <<<"$__APKMIRROR_RESP__") + apkmname="${apkmname,,}" apkmname="${apkmname// /-}" apkmname="${apkmname//[^a-z0-9-]/}" + url="${url}/${apkmname}-${version//./-}-release/" + 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 + for type in APK BUNDLE; do + if dlurl=$(apkmirror_search "$resp" "$dpi" "$arch" "$type"); then + if [ "$type" = "BUNDLE" ]; then + is_bundle=true + else is_bundle=false; fi + break 2 + fi + done + if [ -z "$dlurl" ]; then return 1; fi + resp=$(req "$dlurl" -) + fi + url=$(echo "$resp" | $HTMLQ --base https://www.apkmirror.com --attribute href "a.btn") || return 1 + url=$(req "$url" - | $HTMLQ --base https://www.apkmirror.com --attribute href "span > a[rel = nofollow]") || return 1 + +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 if [ "$is_bundle" = true ]; then req "$url" "${output}.apkm" || return 1 merge_splits "${output}.apkm" "${output}" @@ -478,11 +568,20 @@ get_uptodown_resp() { get_uptodown_vers() { $HTMLQ --text ".version" <<<"$__UPTODOWN_RESP__"; } dl_uptodown() { local uptodown_dlurl=$1 version=$2 output=$3 arch=$4 _dpi=$5 +<<<<<<< HEAD local apparch if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi if [ "$arch" = all ]; then apparch=('arm64-v8a, armeabi-v7a, x86_64' 'arm64-v8a, armeabi-v7a, x86, x86_64' 'arm64-v8a, armeabi-v7a') else apparch=("$arch" 'arm64-v8a, armeabi-v7a, x86_64' 'arm64-v8a, armeabi-v7a, x86, x86_64' 'arm64-v8a, armeabi-v7a'); fi +======= + if [ "$arch" = "arm-v7a" ]; then arch="armeabi-v7a"; fi + + local apparch=('arm64-v8a, armeabi-v7a, x86_64' 'arm64-v8a, armeabi-v7a, x86, x86_64' 'arm64-v8a, armeabi-v7a') + if [ "$arch" != all ]; then + apparch+=("$arch") + fi +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 local op resp data_code data_code=$($HTMLQ "#detail-app-name" --attribute data-code <<<"$__UPTODOWN_RESP__") @@ -535,9 +634,29 @@ get_uptodown_pkg_name() { $HTMLQ --text "tr.full:nth-child(1) > td:nth-child(3)" # -------------------- archive -------------------- dl_archive() { local url=$1 version=$2 output=$3 arch=$4 +<<<<<<< HEAD local path version=${version// /} path=$(grep "${version_f#v}-${arch// /}" <<<"$__ARCHIVE_RESP__") || return 1 req "${url}/${path}" "$output" +======= + local path output_m version=${version// /} + + if [ -f "${output}.apkm" ]; then + merge_splits "${output}.apkm" "$output" + return 0 + fi + + path=$(grep -m1 "${version_f#v}-${arch// /}" <<<"$__ARCHIVE_RESP__") || return 1 + if [ "${path##*.}" = "apkm" ]; then + output_m="${output}.apkm" + else + output_m=$output + fi + req "${url}/${path}" "$output_m" || return 1 + if [ "${path##*.}" = "apkm" ]; then + merge_splits "$output_m" "$output" + fi +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 } get_archive_resp() { local r @@ -550,7 +669,11 @@ get_archive_pkg_name() { echo "$__ARCHIVE_PKG_NAME__"; } # -------------------- direct -------------------- dl_direct() { +<<<<<<< HEAD local url=$1 version=${2// /-} output=$3 arch=$4 dpi=$5 +======= + local url=$1 version=${2// /-} output=$3 arch=$4 _dpi=$5 +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 req "$url" "${output}" || return 1 } get_direct_vers() { cut -d- -f2 <<<"$__DIRECT_APKNAME__"; } @@ -604,6 +727,7 @@ build_rv() { [ "${args[exclusive_patches]}" = true ] && p_patcher_args+=("--exclusive") local tried_dl=() +<<<<<<< HEAD for dl_p in "${DL_SRCS[@]}"; do if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi if ! get_${dl_p}_resp "${args[${dl_p}_dlurl]}" || ! pkg_name=$(get_"${dl_p}"_pkg_name); then @@ -615,6 +739,24 @@ build_rv() { dl_from=$dl_p break done +======= + if [ "${args[pkg_name]}" ]; then + pkg_name="${args[pkg_name]}" + else + for dl_p in "${DL_SRCS[@]}"; do + if [ -z "${args[${dl_p}_dlurl]}" ]; then continue; fi + if ! get_${dl_p}_resp "${args[${dl_p}_dlurl]}" || ! pkg_name=$(get_"${dl_p}"_pkg_name); then + args[${dl_p}_dlurl]="" + epr "ERROR: Could not find ${table} in ${dl_p}" + continue + fi + tried_dl+=("$dl_p") + dl_from=$dl_p + break + done + fi + +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 if [ -z "$pkg_name" ]; then epr "empty pkg name, not building ${table}." return 0 @@ -679,9 +821,29 @@ build_rv() { return 0 fi fi +<<<<<<< HEAD if [ ! -f "${stock_apk}.apkm" ] && ! OP=$(check_sig "$stock_apk" "$pkg_name" 2>&1) && ! grep -qFx "ERROR: Missing META-INF/MANIFEST.MF" <<<"$OP"; then epr "Not building $table, apk signature mismatch '$stock_apk': $OP" return 0 +======= + + local sig_op + if [ -f "${stock_apk}.apkm" ]; then + rm -rf "${stock_apk}-zip" || : + unzip -j "${stock_apk}.apkm" -d "${stock_apk}-zip" >/dev/null + for a in "${stock_apk}"-zip/*.apk; do + if ! sig_op=$(check_sig "$a" "$pkg_name" 2>&1); then + epr "Not building $table, apk signature mismatch '$a': $sig_op" + return 0 + fi + done + rm -rf "${stock_apk}-zip" || : + else + if ! sig_op=$(check_sig "$stock_apk" "$pkg_name" 2>&1); then + epr "Not building $table, apk signature mismatch '$stock_apk': $sig_op" + return 0 + fi +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 fi log "${table}: ${version}" @@ -729,7 +891,13 @@ build_rv() { zip -d "$stock_apk_to_patch" "lib/x86_64/*" "lib/x86/*" >/dev/null 2>&1 || : fi fi +<<<<<<< HEAD if [ "${NORB:-}" != true ] || [ ! -f "$patched_apk" ]; then +======= + + local apk_output="${BUILD_DIR}/${app_name_l}-${rv_brand_f}-v${version_f}-${arch_f}.apk" + if [ "${NORB:-}" = false ] || { [ ! -f "$patched_apk" ] && [ ! -f "$apk_output" ]; }; then +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 if ! patch_apk "$stock_apk_to_patch" "$patched_apk" "${patcher_args[*]}" "${args[cli]}" "${args[ptjar]}"; then epr "Building '${table}' failed!" return 0 @@ -737,8 +905,14 @@ build_rv() { fi rm "$stock_apk_to_patch" if [ "$build_mode" = apk ]; then +<<<<<<< HEAD local apk_output="${BUILD_DIR}/${app_name_l}-${rv_brand_f}-v${version_f}-${arch_f}.apk" mv -f "$patched_apk" "$apk_output" +======= + if [ "${NORB:-}" = false ] || { [ ! -f "$patched_apk" ] && [ ! -f "$apk_output" ]; }; then + mv -f "$patched_apk" "$apk_output" + fi +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 pr "Built ${table} (non-root): '${apk_output}'" continue fi @@ -761,7 +935,34 @@ build_rv() { local module_output="${app_name_l}-${rv_brand_f}-module-v${version_f}-${arch_f}.zip" pr "Packing module ${table}" cp -f "$patched_apk" "${base_template}/base.apk" +<<<<<<< HEAD if [ "${args[include_stock]}" = true ]; then cp -f "$stock_apk" "${base_template}/${pkg_name}.apk"; fi +======= + + if [ "${args[include_stock]}" != "disable" ]; then + mkdir -p "${base_template}/stock/" + if [ "${args[include_stock]}" = "merged" ]; then + cp -f "$stock_apk" "${base_template}/stock/base.apk" + elif [ "${args[include_stock]}" = "split" ]; then + if [ ! -f "${stock_apk}.apkm" ]; then + epr "Cannot include as 'split' because stock apk of $table_name is not a bundle" + return 0 + fi + if [ "$arch" = "arm64-v8a" ]; then + unzip -j "${stock_apk}.apkm" '*.apk' -x '*x86_64.apk' -x '*x86.apk' -x '*armeabi_v7a.apk' -d "${base_template}/stock/" >/dev/null 2>&1 + elif [ "$arch" = "arm-v7a" ]; then + unzip -j "${stock_apk}.apkm" '*.apk' -x '*x86_64.apk' -x '*x86.apk' -x '*arm64_v8a.apk' -d "${base_template}/stock/" >/dev/null 2>&1 + elif [ "$arch" = "x86" ]; then + unzip -j "${stock_apk}.apkm" '*.apk' -x '*x86_64.apk' -x '*arm64_v8a.apk' -x '*armeabi_v7a.apk' -d "${base_template}/stock/" >/dev/null 2>&1 + elif [ "$arch" = "x86_64" ]; then + unzip -j "${stock_apk}.apkm" '*.apk' -x '*x86.apk' -x '*arm64_v8a.apk' -x '*armeabi_v7a.apk' -d "${base_template}/stock/" >/dev/null 2>&1 + else + unzip -j "${stock_apk}.apkm" '*.apk' -x '*x86_64.apk' -x '*x86.apk' -d "${base_template}/stock/" >/dev/null 2>&1 + fi + fi + fi + +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 pushd >/dev/null "$base_template" || abort "Module template dir not found" zip -"$COMPRESSION_LEVEL" -FSqr "${CWD}/${BUILD_DIR}/${module_output}" . popd >/dev/null || : @@ -788,7 +989,11 @@ module_prop() { name=${2} version=v${3} versionCode=${NEXT_VER_CODE} +<<<<<<< HEAD author=ev3rlin +======= +author=j-hc +>>>>>>> 5e2d728c683b60e7a42b0f54511bdc59dbb9e3a8 description=${4}" >"${6}/module.prop" if [ "$ENABLE_MODULE_UPDATE" = true ]; then echo "updateJson=${5}" >>"${6}/module.prop"; fi