-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
magisk: Fix compatibility with Magisk v28
A new library 'libinit-ld.so' got introduced, 'libmagisk<arch>.so' changed to 'libmagisk.so' and the old download server got deprecated. Rework and simplify update_magisk.sh to account for the new library changes and download links. Signed-off-by: Louis Poier <lpoier7@proton.me>
- Loading branch information
1 parent
fe815ff
commit 8dc43d9
Showing
3 changed files
with
34 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,37 @@ | ||
#!/bin/bash | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
set -eu | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
# [ | ||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" | ||
|
||
ver="$(cat "$DIR/magisk_version" 2>/dev/null || echo -n 'none')" | ||
MAGISK_CURRENT_VERSION="$(cat "$DIR/magisk_version" 2>/dev/null || echo -n 'none')" | ||
MAGISK_BRANCH="$1" | ||
# ] | ||
|
||
if [ "x$1" = "xcanary" ] | ||
then | ||
nver="canary" | ||
magisk_link="https://github.com/topjohnwu/magisk-files/raw/${nver}/app-debug.apk" | ||
elif [ "x$1" = "xlocal" ] | ||
then | ||
nver="local" | ||
magisk_link="https://gitlab.com/TenSeventy7/magisk-files/raw/main/app-debug.apk" | ||
if [[ $MAGISK_BRANCH == local ]]; then | ||
MAGISK_VERSION="local" | ||
MAGISK_LINK="https://gitlab.com/TenSeventy7/magisk-files/raw/main/app-debug.apk" | ||
else | ||
if [ "x$1" = "x" ]; then | ||
nver="$(curl -s https://raw.githubusercontent.com/topjohnwu/magisk-files/master/stable.json | jq '.magisk.version' | cut -d '"' -f 2)" | ||
else | ||
nver="$1" | ||
fi | ||
magisk_link="https://cdn.jsdelivr.net/gh/topjohnwu/magisk-files@${nver}/app-release.apk" | ||
MAGISK_VERSION="$(curl -s "https://raw.githubusercontent.com/topjohnwu/magisk-files/master/$MAGISK_BRANCH.json" | jq '.magisk.version' | cut -d '"' -f 2)" | ||
MAGISK_LINK="$(curl -s "https://raw.githubusercontent.com/topjohnwu/magisk-files/master/$MAGISK_BRANCH.json" | jq '.magisk.link' | cut -d '"' -f 2)" | ||
fi | ||
|
||
if [ \( -n "$nver" \) -a \( "$nver" != "$ver" \) -o ! \( -f "$DIR/arm/magiskinit64" \) -o \( "$nver" = "canary" \) -o \( "$nver" = "local" \) ] | ||
then | ||
echo "Updating Magisk from $ver to $nver" | ||
curl -s --output "$DIR/magisk.zip" -L "$magisk_link" | ||
if fgrep 'Not Found' "$DIR/magisk.zip"; then | ||
curl -s --output "$DIR/magisk.zip" -L "${magisk_link%.apk}.zip" | ||
fi | ||
|
||
7z e "$DIR/magisk.zip" lib/arm64-v8a/libmagiskinit.so lib/armeabi-v7a/libmagisk32.so lib/arm64-v8a/libmagisk64.so assets/stub.apk -o"$DIR" -y | ||
mv -f "$DIR/libmagiskinit.so" "$DIR/magiskinit" | ||
mv -f "$DIR/libmagisk32.so" "$DIR/magisk32" | ||
mv -f "$DIR/libmagisk64.so" "$DIR/magisk64" | ||
mv -f "$DIR/stub.apk" "$DIR/stub" | ||
xz --force --check=crc32 "$DIR/magisk32" "$DIR/magisk64" "$DIR/stub" | ||
|
||
echo -n "$nver" > "$DIR/magisk_version" | ||
if [[ $MAGISK_CURRENT_VERSION != "$MAGISK_VERSION" ]] || [[ $MAGISK_BRANCH == local || $MAGISK_BRANCH == canary ]]; then | ||
echo "Updating Magisk from $MAGISK_CURRENT_VERSION to $MAGISK_VERSION" | ||
curl -s --output "$DIR/magisk.zip" -L "$MAGISK_LINK" | ||
|
||
grep -q 'Not Found' "$DIR/magisk.zip" \ | ||
&& curl -s --output "$DIR/magisk.zip" -L "${MAGISK_LINK%.apk}.zip" | ||
|
||
7z e -so "$DIR/magisk.zip" lib/arm64-v8a/libmagiskinit.so > "$DIR/magiskinit" | ||
7z e -so "$DIR/magisk.zip" lib/arm64-v8a/libmagisk.so > "$DIR/magisk" | ||
7z e -so "$DIR/magisk.zip" lib/arm64-v8a/libinit-ld.so > "$DIR/init-ld" | ||
7z e -so "$DIR/magisk.zip" assets/stub.apk > "$DIR/stub" | ||
xz --force --check=crc32 "$DIR/magisk" "$DIR/init-ld" "$DIR/stub" | ||
|
||
echo -n "$MAGISK_VERSION" > "$DIR/magisk_version" | ||
rm "$DIR/magisk.zip" | ||
touch "$DIR/initramfs_list" | ||
else | ||
echo "Nothing to be done: Magisk version $nver" | ||
echo "Nothing to be done: Magisk version $MAGISK_VERSION" | ||
fi |