Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
NoName-exe committed Jan 10, 2023
2 parents 66af5a1 + 74b3cf3 commit da1b0ec
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 185 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on: [workflow_call, workflow_dispatch]

jobs:
run:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:
SHOULD_BUILD: ${{ steps.should_build.outputs.SHOULD_BUILD }}

build:
permissions: write-all
needs: check
uses: ./.github/workflows/build.yml
if: ${{ needs.check.outputs.SHOULD_BUILD == 1 }}
Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for t in $(toml_get_all_tables); do
enabled=$(toml_get "$t" enabled) || enabled=true
if [ "$enabled" = false ]; then continue; fi

if [ $idx -ge "$PARALLEL_JOBS" ]; then wait -n; else idx=$((idx + 1)); fi
if (( idx >= PARALLEL_JOBS )); then wait -n; else idx=$((idx + 1)); fi
declare -A app_args
merge_integrations=$(toml_get "$t" merge-integrations) || merge_integrations=false
excluded_patches=$(toml_get "$t" excluded-patches) || excluded_patches=""
Expand Down Expand Up @@ -72,9 +72,9 @@ rm -rf temp/tmp.*
if [ "$BUILD_MINDETACH_MODULE" = true ]; then
echo "Building mindetach module"
cp -f $PKGS_LIST mindetach-magisk/mindetach/detach.txt
cd mindetach-magisk/mindetach/
pushd mindetach-magisk/mindetach/
zip -r ../../build/mindetach-"$(grep version= module.prop | cut -d= -f2)".zip .
cd ../../
popd
fi

youtube_mode=$(toml_get "YouTube" "build-mode") || youtube_mode="module"
Expand Down
2 changes: 1 addition & 1 deletion scripts/service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RVPATH=/data/adb/__PKGNAME_rv.apk
until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1; done
until [ -d /sdcard ]; do sleep 1; done

ln -f $MODDIR/base.apk $RVPATH
ln $MODDIR/base.apk $RVPATH
BASEPATH=$(pm path __PKGNAME | grep base)
BASEPATH=${BASEPATH#*:}
if [ $BASEPATH ] && [ -d ${BASEPATH%base.apk}lib ]; then
Expand Down
150 changes: 0 additions & 150 deletions semver

This file was deleted.

70 changes: 39 additions & 31 deletions utils.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env bash

source semver

MODULE_TEMPLATE_DIR="revanced-magisk"
MODULE_SCRIPTS_DIR="scripts"
TEMP_DIR="temp"
Expand All @@ -13,7 +11,7 @@ if [ "${GITHUB_TOKEN+x}" ]; then
else
GH_AUTH_HEADER=""
fi
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-$"NoName-exe/revanced"}
GITHUB_REPOSITORY=${GITHUB_REPOSITORY:-"NoName-exe/revanced"}
NEXT_VER_CODE=${NEXT_VER_CODE:-$(date +'%Y%m%d')}
WGET_HEADER="User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:108.0) Gecko/20100101 Firefox/108.0"
DRYRUN=false
Expand All @@ -22,16 +20,9 @@ SERVICE_SH=$(cat $MODULE_SCRIPTS_DIR/service.sh)
CUSTOMIZE_SH=$(cat $MODULE_SCRIPTS_DIR/customize.sh)
UNINSTALL_SH=$(cat $MODULE_SCRIPTS_DIR/uninstall.sh)

json_get() {
grep -o "\"${1}\":[^\"]*\"[^\"]*\"" | sed -E 's/".*".*"(.*)"/\1/'
}

toml_prep() {
__TOML__=$(echo "$1" | tr -d '\t\r' | tr "'" '"' | grep -o '^[^#]*' | grep -v '^$' | sed -r 's/(\".*\")|\s*/\1/g')
}
toml_get_all_tables() {
echo "$__TOML__" | grep -x '\[.*\]' | tr -d '[]' || return 1
}
json_get() { grep -o "\"${1}\":[^\"]*\"[^\"]*\"" | sed -E 's/".*".*"(.*)"/\1/'; }
toml_prep() { __TOML__=$(echo "$1" | tr -d '\t\r' | tr "'" '"' | grep -o '^[^#]*' | grep -v '^$' | sed -r 's/(\".*\")|\s*/\1/g'); }
toml_get_all_tables() { echo "$__TOML__" | grep -x '\[.*\]' | tr -d '[]' || return 1; }
toml_get() {
local table=$1 key=$2
val=$(echo "$__TOML__" | sed -n "/\[${table}]/,/^\[.*]$/p" | grep "^${key}=")
Expand Down Expand Up @@ -96,14 +87,37 @@ gh_req() { wget -nv -O "$2" --header="$GH_AUTH_HEADER" "$1"; }
log() { echo -e "$1 " >>build.md; }
get_largest_ver() {
local max=0
while read -r v || [ -n "$v" ]; do
#shellcheck disable=SC2001
if [ "$(command_compare "$(sed 's/\./-/3' <<<"$v")" "$(sed 's/\./-/3' <<<"$max")")" = 1 ]; then max=$v; fi
while read -r v; do
if [ "$max" != 0 ] && ! semver_validate "$max" "$v"; then return 0; fi
if [ "$(semver_cmp "$max" "$v")" = 1 ]; then max=$v; fi
done
if [[ $max != 0 ]]; then echo "$max"; fi
if [ "$max" != 0 ]; then echo "$max"; fi
}
get_patch_last_supported_ver() {
unzip -p "$RV_PATCHES_JAR" | strings -s , | sed -rn "s/.*${1},versions,(([0-9.]*,*)*),Lk.*/\1/p" | tr ',' '\n' | get_largest_ver
local vs
vs=$(unzip -p "$RV_PATCHES_JAR" | strings -s , | sed -rn "s/.*${1},versions,(([0-9.]*,*)*),Lk.*/\1/p" | tr ',' '\n')
printf "%s\n" "$vs" | get_largest_ver
}
semver_cmp() {
local IFS=.
read -r -a v1 <<<"${1//[^.0-9]/}"
read -r -a v2 <<<"${2//[^.0-9]/}"
for i in ${!v1[*]}; do
if ((v1[i] > v2[i])); then
echo -1
return 0
elif ((v2[i] > v1[i])); then
echo 1
return 0
fi
done
echo 0
}
semver_validate() {
local a1="${1%-*}" a2="${2%-*}"
local c1="${a1//[^.]/}" c2="${a2//[^.]/}"
local a1c="${a1//[.0-9]/}" a2c="${a2//[.0-9]/}"
[ ${#c1} = ${#c2} ] && [ ${#a1c} = 0 ] && [ ${#a2c} = 0 ]
}

dl_if_dne() {
Expand Down Expand Up @@ -136,18 +150,12 @@ get_apkmirror_vers() {
vers=$(req "https://www.apkmirror.com/uploads/?appcategory=${apkmirror_category}" - | sed -n 's;.*Version:</span><span class="infoSlide-value">\(.*\) </span>.*;\1;p')
if [ "$allow_alpha_version" = false ]; then grep -i -v -e "beta" -e "alpha" <<<"$vers"; else echo "$vers"; fi
}
get_apkmirror_pkg_name() {
req "$1" - | sed -n 's;.*id=\(.*\)" class="accent_color.*;\1;p'
}
get_apkmirror_pkg_name() { req "$1" - | sed -n 's;.*id=\(.*\)" class="accent_color.*;\1;p'; }
# ------------------------------

# ------- uptodown -------------
get_uptodown_resp() {
req "https://${1}.en.uptodown.com/android/versions" -
}
get_uptodown_vers() {
echo "$1" | grep -x '^[0-9.]* <span>.*</span>' | sed 's/ <s.*//'
}
get_uptodown_resp() { req "https://${1}.en.uptodown.com/android/versions" -; }
get_uptodown_vers() { echo "$1" | grep -x '^[0-9.]* <span>.*</span>' | sed 's/ <s.*//'; }
dl_uptodown() {
local uptwod_resp=$1 version=$2 output=$3
url=$(echo "$uptwod_resp" | grep "${version} <span>" -B 1 | head -1 | sed -n 's;.*data-url="\(.*\)".*;\1;p')
Expand Down Expand Up @@ -177,9 +185,9 @@ zip_module() {
local patched_apk=$1 module_name=$2 stock_apk=$3 pkg_name=$4 template_dir=$5
cp -f "$patched_apk" "${template_dir}/base.apk"
cp -f "$stock_apk" "${template_dir}/${pkg_name}.apk"
cd "$template_dir" || abort "Module template dir not found"
pushd "$template_dir" || abort "Module template dir not found"
zip -"$COMPRESSION_LEVEL" -FSr "../../${BUILD_DIR}/${module_name}" .
cd ../..
popd || :
}

build_rv() {
Expand Down Expand Up @@ -254,7 +262,7 @@ build_rv() {
echo "ERROR: empty version"
return 1
fi
echo "Choosing version '${version}'"
echo "Choosing version '${version}' (${args[app_name]})"

local stock_apk="${TEMP_DIR}/${app_name_l}-stock-v${version}-${arch}.apk"
local apk_output="${BUILD_DIR}/${app_name_l}-revanced-v${version}-${arch}.apk"
Expand Down Expand Up @@ -324,7 +332,7 @@ build_rv() {
}

join_args() {
echo "$1" | tr -d '\t\r' | tr ' ' '\n' | grep -v '^$' | sed "s/^/${2} /" | paste -sd " " - || echo ""
echo "$1" | tr -d '\t\r' | tr ' ' '\n' | grep -v '^$' | sed "s/^/${2} /" | paste -sd " " - || :
}

uninstall_sh() { echo "${UNINSTALL_SH//__PKGNAME/$1}" >"${2}/uninstall.sh"; }
Expand Down

0 comments on commit da1b0ec

Please sign in to comment.