From 86500ee4347aaba5c94c1e72af0b1ae8bfb5a3a4 Mon Sep 17 00:00:00 2001 From: programminghoch10 <16062290+programminghoch10@users.noreply.github.com> Date: Sun, 31 Dec 2023 00:19:52 +0100 Subject: [PATCH] implement shellcheck changes --- compile.sh | 13 +++++++------ magiskmodule/customize.sh | 18 ++++++++---------- magiskmodule/service.sh | 14 +++++++------- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/compile.sh b/compile.sh index 2638861..b4b361b 100755 --- a/compile.sh +++ b/compile.sh @@ -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 ) @@ -41,9 +41,9 @@ 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 @@ -51,7 +51,7 @@ for dlurl in "$REVANCED_INTEGRATIONS_DL" "$REVANCED_PATCHES_DL"; do [ ! -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 \ @@ -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 \ diff --git a/magiskmodule/customize.sh b/magiskmodule/customize.sh index 51ac62c..ce41655 100644 --- a/magiskmodule/customize.sh +++ b/magiskmodule/customize.sh @@ -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 @@ -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 @@ -34,7 +33,7 @@ chmod -v +x system/bin/revancedcli mkdir overlay processPackage() { - local packagename="$1" + packagename="$1" [ -z "$(pm list packages "$packagename")" ] && return @@ -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" \ @@ -72,8 +71,8 @@ processPackage() { } patchAPK() { - local packagename="$1" - local apkpath="$2" + packagename="$1" + apkpath="$2" cd "$TMPDIR" ui_print "- Patching $packagename" @@ -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 diff --git a/magiskmodule/service.sh b/magiskmodule/service.sh index 8c19f34..c150097 100644 --- a/magiskmodule/service.sh +++ b/magiskmodule/service.sh @@ -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 } @@ -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