Skip to content

Commit

Permalink
Enhanced compatibility (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard20181 authored Jul 25, 2024
1 parent d190ec2 commit 5448a5f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
16 changes: 11 additions & 5 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,18 @@ if [ "$ROOT_SOL" = "magisk" ]; then
echo "Integrating Magisk"
SKIP="#"
SINGLEABI="#"
SKIPINITLD="#"
if [ -f "$WORK_DIR/magisk/magisk64" ]; then
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk64" "$WORK_DIR/magisk/magisk64.xz"
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk32" "$WORK_DIR/magisk/magisk32.xz"
unset SKIP
unset SINGLEABI
else
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk" "$WORK_DIR/magisk/magisk.xz"
unset SINGLEABI
unset SKIP
fi
if [ -f "$WORK_DIR/magisk/init-ld" ]; then
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/init-ld" "$WORK_DIR/magisk/init-ld.xz"
unset SKIPINITLD
fi
"$WORK_DIR/magisk/magiskboot" compress=xz "$MAGISK_PATH" "$WORK_DIR/magisk/stub.xz"
"$WORK_DIR/magisk/magiskboot" cpio "$WORK_DIR/wsa/$ARCH/Tools/initrd.img" \
Expand All @@ -502,9 +507,10 @@ if [ "$ROOT_SOL" = "magisk" ]; then
"add 0750 /magiskinit $WORK_DIR/magisk/magiskinit" \
"mkdir 0750 overlay.d" \
"mkdir 0750 overlay.d/sbin" \
"$SKIP add 0644 overlay.d/sbin/magisk64.xz $WORK_DIR/magisk/magisk64.xz" \
"$SKIP add 0644 overlay.d/sbin/magisk32.xz $WORK_DIR/magisk/magisk32.xz" \
"$SINGLEABI add 0644 overlay.d/sbin/magisk.xz $WORK_DIR/magisk/magisk.xz" \
"$SINGLEABI add 0644 overlay.d/sbin/magisk64.xz $WORK_DIR/magisk/magisk64.xz" \
"$SINGLEABI add 0644 overlay.d/sbin/magisk32.xz $WORK_DIR/magisk/magisk32.xz" \
"$SKIP add 0644 overlay.d/sbin/magisk.xz $WORK_DIR/magisk/magisk.xz" \
"$SKIPINITLD add 0644 overlay.d/sbin/init-ld.xz $WORK_DIR/magisk/init-ld.xz" \
"add 0644 overlay.d/sbin/stub.xz $WORK_DIR/magisk/stub.xz" \
"mkdir 000 .backup" \
"add 000 overlay.d/init.lsp.magisk.rc init.lsp.magisk.rc" \
Expand Down
5 changes: 4 additions & 1 deletion scripts/extractMagisk.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def extract_as(zip, name, as_name, dir):

with zipfile.ZipFile(magisk_zip) as zip:
props = Prop(zip.comment.decode().replace('\000', '\n'))
namelist = zip.namelist()
versionName = props.get("version")
versionCode = props.get("versionCode")
print(f"Magisk version: {versionName} ({versionCode})", flush=True)
Expand All @@ -71,10 +72,12 @@ def extract_as(zip, name, as_name, dir):
env.MAGISK_VERSION_CODE = versionCode
with open(os.environ['WSA_WORK_ENV'], 'w') as environ_file:
environ_file.write(str(env))
if f"lib/{ abi_map[arch][0] }/libmagisk64.so" in zip.namelist():
if f"lib/{ abi_map[arch][0] }/libmagisk64.so" in namelist:
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagisk64.so", "magisk64", "magisk")
extract_as(zip, f"lib/{ abi_map[arch][1] }/libmagisk32.so", "magisk32", "magisk")
else:
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagisk.so", "magisk", "magisk")
if f"lib/{ abi_map[arch][0] }/libinit-ld.so" in namelist:
extract_as(zip, f"lib/{ abi_map[arch][0] }/libinit-ld.so", "init-ld", "magisk")
extract_as(zip, f"lib/{ abi_map[arch][0] }/libmagiskinit.so", "magiskinit", "magisk")
extract_as(zip, f"lib/{ abi_map[host_abi][0] }/libmagiskboot.so", "magiskboot", "magisk")
16 changes: 11 additions & 5 deletions scripts/magisk_debug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,25 @@ echo -e "done\n"
echo "Integrating Magisk"
SKIP="#"
SINGLEABI="#"
SKIPINITLD="#"
if [ -f "$WORK_DIR/magisk/magisk64" ]; then
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk64" "$WORK_DIR/magisk/magisk64.xz"
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk32" "$WORK_DIR/magisk/magisk32.xz"
unset SKIP
unset SINGLEABI
else
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/magisk" "$WORK_DIR/magisk/magisk.xz"
unset SINGLEABI
unset SKIP
fi
if [ -f "$WORK_DIR/magisk/init-ld" ]; then
"$WORK_DIR/magisk/magiskboot" compress=xz "$WORK_DIR/magisk/init-ld" "$WORK_DIR/magisk/init-ld.xz"
unset SKIPINITLD
fi
"$WORK_DIR/magisk/magiskboot" compress=xz "$MAGISK_PATH" "$WORK_DIR/magisk/stub.xz"
"$WORK_DIR/magisk/magiskboot" cpio "$TARGET" \
"add 0750 /magiskinit $WORK_DIR/magisk/magiskinit" \
"$SKIP add 0644 overlay.d/sbin/magisk64.xz $WORK_DIR/magisk/magisk64.xz" \
"$SKIP add 0644 overlay.d/sbin/magisk32.xz $WORK_DIR/magisk/magisk32.xz" \
"$SINGLEABI add 0644 overlay.d/sbin/magisk.xz $WORK_DIR/magisk/magisk.xz" \
"$SINGLEABI add 0644 overlay.d/sbin/magisk64.xz $WORK_DIR/magisk/magisk64.xz" \
"$SINGLEABI add 0644 overlay.d/sbin/magisk32.xz $WORK_DIR/magisk/magisk32.xz" \
"$SKIP add 0644 overlay.d/sbin/magisk.xz $WORK_DIR/magisk/magisk.xz" \
"$SKIPINITLD add 0644 overlay.d/sbin/init-ld.xz $WORK_DIR/magisk/init-ld.xz" \
"add 0644 overlay.d/sbin/stub.xz $WORK_DIR/magisk/stub.xz" \
|| abort "Unable to patch initrd"

0 comments on commit 5448a5f

Please sign in to comment.