Skip to content

Commit

Permalink
implement shellcheck changes
Browse files Browse the repository at this point in the history
  • Loading branch information
programminghoch10 committed Dec 31, 2023
1 parent 423d61a commit 86500ee
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
13 changes: 7 additions & 6 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ executeGradle() {

(
cd revanced-cli
for patch in $(ls ../revanced-cli-patches/*.patch); do
for patch in ../revanced-cli-patches/*.patch; do
git am --no-3way "$patch"
done
)
Expand All @@ -41,17 +41,17 @@ git submodule update --checkout

source version.sh

REVANCED_INTEGRATIONS=$(sed -e 's/^v//' <<< "$REVANCED_INTEGRATIONS")
REVANCED_INTEGRATIONS=${REVANCED_INTEGRATIONS#v}
printf -v REVANCED_INTEGRATIONS_DL "$REVANCED_INTEGRATIONS_URL" "$REVANCED_INTEGRATIONS" "$REVANCED_INTEGRATIONS"
REVANCED_PATCHES=$(sed -e 's/^v//' <<< "$REVANCED_PATCHES")
REVANCED_PATCHES=${REVANCED_PATCHES#v}
printf -v REVANCED_PATCHES_DL "$REVANCED_PATCHES_URL" "$REVANCED_PATCHES" "$REVANCED_PATCHES"

for dlurl in "$REVANCED_INTEGRATIONS_DL" "$REVANCED_PATCHES_DL"; do
dlfile="$(basename "$dlurl")"
[ ! -f "$dlfile" ] && wget -c -O "$dlfile" "$dlurl"
done

REVANCED_CLI=$(sed -e 's/^v//' <<< "$REVANCED_CLI")
REVANCED_CLI=${REVANCED_CLI#v}
ln -v -s -f "revanced-cli/build/libs/revancedcli-$REVANCED_CLI-all.jar" "revanced-cli.jar"

PATCHES_LIST=$(java -jar revanced-cli.jar \
Expand All @@ -61,11 +61,12 @@ PATCHES_LIST=$(java -jar revanced-cli.jar \
rm -rf magiskmodule/packageversions
mkdir magiskmodule/packageversions
echo '## Supported Packages and Versions' > magiskmodule/supportedversions.md
for package in $(cut -d$'\t' -f1 <<< "$PATCHES_LIST" | sort -u); do
cut -d$'\t' -f1 <<< "$PATCHES_LIST" | sort -u | while IFS= read -r package; do
grep "^$package" <<< "$PATCHES_LIST" | cut -d$'\t' -f2 | tr ',' '\n' | sed -e 's/^ //' -e 's/ $//' -e '/^$/d' | sort -u > magiskmodule/packageversions/"$package"
echo "- **\`$package\`**" >> magiskmodule/supportedversions.md
#shellcheck disable=SC2016
sed 's/^\(.*\)$/`\1`/' < magiskmodule/packageversions/"$package" | tr '\n' '#' | sed -e '/^$/d' -e 's/#$//' -e 's/#/\n/g' | sed -e 's/^/ - /' >> magiskmodule/supportedversions.md
[ $(wc -l < magiskmodule/packageversions/"$package") -gt 0 ] && echo >> magiskmodule/supportedversions.md
[ "$(wc -l < magiskmodule/packageversions/"$package")" -gt 0 ] && echo >> magiskmodule/supportedversions.md
done

java -jar revanced-cli.jar \
Expand Down
18 changes: 8 additions & 10 deletions magiskmodule/customize.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/system/bin/sh

#shellcheck disable=SC2154
[ "$BOOTMODE" != "true" ] && abort "Please install this module within the Magisk app."

export IFS=$'\n'

cd "$MODPATH"

[ ! -f ./version.sh ] && abort "Missing version.sh"
source ./version.sh
. ./version.sh

MAGISKTMP="$(magisk --path)" || MAGISKTMP=/sbin
MIRROR="$MAGISKTMP"/.magisk/mirror
Expand All @@ -24,8 +23,8 @@ BLACKLIST="$(findConfigFile revancedrepackaged-blacklist.txt)"

ui_print "- Preparing Patching Process"

[ ! -f aapt2lib/$ARCH/libaapt2.so ] && abort "Failed to locate libaapt2.so for $ARCH"
mv -v aapt2lib/$ARCH/libaapt2.so aapt2
[ ! -f aapt2lib/"$ARCH"/libaapt2.so ] && abort "Failed to locate libaapt2.so for $ARCH"
mv -v aapt2lib/"$ARCH"/libaapt2.so aapt2
rm -r aapt2lib
chmod -v +x aapt2

Expand All @@ -34,7 +33,7 @@ chmod -v +x system/bin/revancedcli
mkdir overlay

processPackage() {
local packagename="$1"
packagename="$1"

[ -z "$(pm list packages "$packagename")" ] && return

Expand All @@ -44,7 +43,7 @@ processPackage() {

ui_print "- Processing $packagename"

installedpackageversion="$(pm dump $packagename | grep -E '^ *versionName=.*$' | cut -d'=' -f2)"
installedpackageversion="$(pm dump "$packagename" | grep -E '^ *versionName=.*$' | cut -d'=' -f2)"

[ -s packageversions/"$packagename" ] \
&& ! grep -q -F "$installedpackageversion" < packageversions/"$packagename" \
Expand Down Expand Up @@ -72,8 +71,8 @@ processPackage() {
}

patchAPK() {
local packagename="$1"
local apkpath="$2"
packagename="$1"
apkpath="$2"
cd "$TMPDIR"

ui_print "- Patching $packagename"
Expand All @@ -83,7 +82,6 @@ patchAPK() {
[ -f "$MODPATH"/options/"$packagename".json ] \
&& cp "$MODPATH"/options/"$packagename".json options.json

local optionsconfigfile=""
optionsconfigfile="$(findConfigFile revancedrepackaged-options.json)"
[ -f "$optionsconfigfile" ] \
&& cp "$optionsconfigfile" options.json
Expand Down
14 changes: 7 additions & 7 deletions magiskmodule/service.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/system/bin/sh
cd $(dirname $0)
cd "$(dirname "$0")"

source ./version.sh
. ./version.sh

logi() {
local msg="ReVancedRepackaged: $1"
msg="ReVancedRepackaged: $1"
log -t Magisk "$msg"
echo "$msg" >> /cache/magisk.log
}
Expand All @@ -19,16 +19,16 @@ MAGISKTMP="$(magisk --path)" || MAGISKTMP=/sbin
MIRROR="$MAGISKTMP"/.magisk/mirror

checkHash() {
local packagename="$1"
local apkpath="$2"
packagename="$1"
apkpath="$2"
[ "$(sha256sum < "$apkpath")" = "$(cat overlay/"$packagename".sha256sum)" ] && return 0
logi "Package $package has changed their base.apk! Removing their overlay, because a repatch is required."
logi "Package $packagename has changed their base.apk! Removing their overlay, because a repatch is required."
rm overlay/"$packagename".*
return 1
}

overlayPackage() {
local packagename="$1"
packagename="$1"
logi "Overlaying $packagename"

overlayapk=$(pwd)/overlay/"$packagename".apk
Expand Down

0 comments on commit 86500ee

Please sign in to comment.