From 412b5ee3c521d1047398f7bffac77a5250e456b7 Mon Sep 17 00:00:00 2001 From: j-hc Date: Sun, 8 Oct 2023 23:30:27 +0300 Subject: [PATCH] a few checks --- build.sh | 2 ++ utils.sh | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/build.sh b/build.sh index 81bd585..4d4e7a1 100755 --- a/build.sh +++ b/build.sh @@ -113,7 +113,9 @@ for table_name in $(toml_get_table_names); do 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]="" + if [ -n "${app_args[excluded_patches]}" ] && [[ "${app_args[excluded_patches]}" != *'"'* ]]; then abort "patch names inside excluded-patches must be quoted"; fi app_args[included_patches]=$(toml_get "$t" included-patches) || app_args[included_patches]="" + if [ -n "${app_args[included_patches]}" ] && [[ "${app_args[included_patches]}" != *'"'* ]]; then abort "patch names inside included-patches must be quoted"; fi app_args[exclusive_patches]=$(toml_get "$t" exclusive-patches) && vtf "${app_args[exclusive_patches]}" "exclusive-patches" || app_args[exclusive_patches]=false app_args[version]=$(toml_get "$t" version) || app_args[version]="auto" app_args[app_name]=$(toml_get "$t" app-name) || app_args[app_name]=$table_name diff --git a/utils.sh b/utils.sh index e6f26fd..56950d5 100755 --- a/utils.sh +++ b/utils.sh @@ -175,17 +175,19 @@ semver_validate() { [ ${#ac} = 0 ] } get_patch_last_supported_ver() { - local inc_sel exc_sel + local inc_sel exc_sel vs inc_sel=$(list_args "$2" | sed 's/.*/\.name == &/' | paste -sd '~' | sed 's/~/ or /g' || :) exc_sel=$(list_args "$3" | sed 's/.*/\.name != &/' | paste -sd '~' | sed 's/~/ and /g' || :) inc_sel=${inc_sel:-false} if [ "$4" = false ]; then inc_sel="${inc_sel} or .use==true"; fi - jq -r ".[] + if ! vs=$(jq -r ".[] | select(.compatiblePackages // [] | .[] | .name==\"${1}\") | select(${inc_sel}) | select(${exc_sel:-true}) - | .compatiblePackages[].versions // []" "$5" | - tr -d ' ,\t[]"' | sort -u | grep -v '^$' | get_largest_ver || return 1 + | .compatiblePackages[].versions // []" "$5"); then + abort "error in jq query" + fi + tr -d ' ,\t[]"' <<<"$vs" | sort -u | grep -v '^$' | get_largest_ver || : } dl_if_dne() { @@ -352,10 +354,12 @@ build_rv() { local get_latest_ver=false if [ "$version_mode" = auto ]; then - version=$( - get_patch_last_supported_ver "$pkg_name" \ - "${args[included_patches]}" "${args[excluded_patches]}" "${args[exclusive_patches]}" "${args[ptjs]}" - ) || get_latest_ver=true + if ! version=$(get_patch_last_supported_ver "$pkg_name" \ + "${args[included_patches]}" "${args[excluded_patches]}" "${args[exclusive_patches]}" "${args[ptjs]}"); then + exit 1 + elif [ -z "$version" ]; then + get_latest_ver=true + fi elif isoneof "$version_mode" latest beta; then get_latest_ver=true p_patcher_args+=("-f") @@ -457,7 +461,8 @@ build_rv() { if [ "${args[merge_integrations]}" = true ]; then p_patcher_args+=("-m ${args[integ]}"); fi local microg_patch microg_patch=$(jq -r ".[] | select(.compatiblePackages // [] | .[] | .name==\"${pkg_name}\") | .name" "${args[ptjs]}" | grep -iF microg || :) - if [ "$microg_patch" ]; then + if [ "$microg_patch" ] && [[ ${p_patcher_args[*]} =~ $microg_patch ]]; then + epr "You cant include/exclude microg patches as that's done by rvmm builder automatically." p_patcher_args=("${p_patcher_args[@]//-[ei] ${microg_patch}/}") fi @@ -505,9 +510,9 @@ build_rv() { if [ "$microg_patch" ]; then patched_apk="${TEMP_DIR}/${app_name_l}-${rv_brand_f}-${version_f}-${arch_f}-${build_mode}.apk" if [ "$build_mode" = apk ]; then - patcher_args+=("-i '${microg_patch}'") + patcher_args+=("-i \"${microg_patch}\"") elif [ "$build_mode" = module ]; then - patcher_args+=("-e '${microg_patch}'") + patcher_args+=("-e \"${microg_patch}\"") fi else patched_apk="${TEMP_DIR}/${app_name_l}-${rv_brand_f}-${version_f}-${arch_f}.apk"