mirror of
https://gitlab.com/newbit/rootAVD.git
synced 2026-07-03 13:15:10 +02:00
Bug fixes
This commit is contained in:
@@ -234,11 +234,6 @@ rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-31\google_apis_play
|
||||
* The script also detects if there is already a patched Boot.img present
|
||||
* This feature lets you also update and switch between Magisk Versions
|
||||
* Updating a patched ramdisk will delete the overlay.d folder, all mods are gone!
|
||||
* All the ramdisk hacks like fstab, boot scripts and kernel+module updates, can not be applied,
|
||||
* (I don't know a way to Pause the patching process from the Magisk APK)
|
||||
* those hacks can be done, the classical way via the script, with the working and patched ramdisk
|
||||
* If a not proper working ramdisk prevents the Magisk APK from beeing installed and starting, use the toggleRamdisk Argument to stack your patched,\
|
||||
but not yet 100% working ramdisk away, boot the AVD with the Stock ramdisk, toggleRamdisk back, and run the script with the FAKEBOOTIMG Argument
|
||||
|
||||
### 2 Ways to boot the AVD into Safe Mode
|
||||
* 1st Way - If the AVD still boots normal:
|
||||
@@ -344,6 +339,7 @@ but not yet 100% working ramdisk away, boot the AVD with the Stock ramdisk, togg
|
||||
|
||||
### Change Logs
|
||||
#### [November 2022]
|
||||
* [General] - Bug fixes
|
||||
* [General] - Updated to Magisk Stable Version 25.2
|
||||
* [General] - Added FAKEBOOTIMG Use Case Examples as Gif
|
||||
* [rootAVD.sh] - Added support for adding the stub.apk if present
|
||||
|
||||
+120
-62
@@ -156,6 +156,7 @@ api_level_arch_detect() {
|
||||
export ABI
|
||||
export API
|
||||
export FIRSTAPI
|
||||
export AVERSION
|
||||
}
|
||||
|
||||
abort_script() {
|
||||
@@ -209,6 +210,7 @@ detect_ramdisk_compression_method() {
|
||||
METHOD="gzip"
|
||||
RAMDISK_GZ=true
|
||||
mv $RDF $RDF$ENDG
|
||||
#cp $RDF $RDF$ENDG
|
||||
COMPRESS_SIGN="$METHOD_GZ"
|
||||
fi
|
||||
|
||||
@@ -246,7 +248,8 @@ create_fake_boot_img() {
|
||||
printf "\x00\x00\x00\x00\x00\x00\x00\x00" >> $FBHI
|
||||
printf "\x00\x00\x00\x00\x00\x08\x00\x00" >> $FBHI # 00080000 (Pagesize 2048)
|
||||
echo "[!] Only a minimal header is required for Magisk to repack the ramdisk"
|
||||
cp $RDF $CPIO
|
||||
mv $RDF $CPIO
|
||||
|
||||
echo "[*] repacking ramdisk.img into $FBI"
|
||||
$BASEDIR/magiskboot repack -n $FBHI $FBI > /dev/null 2>&1
|
||||
InstallMagiskTemporarily
|
||||
@@ -263,14 +266,15 @@ unpack_patched_ramdisk_from_fake_boot_img() {
|
||||
break
|
||||
done
|
||||
echo "[*] unpacking latest $MagiskPatched"
|
||||
$BASEDIR/magiskboot unpack -n $MagiskPatched > /dev/null 2>&1
|
||||
$BASEDIR/magiskboot unpack $MagiskPatched > /dev/null 2>&1
|
||||
echo "[-] deleting all magisk_patched files"
|
||||
for file in `ls -tu $SDCARD/*magisk_patched*`; do
|
||||
rm -f $file
|
||||
done
|
||||
mv $CPIO "ramdiskpatched4AVD.img"
|
||||
done
|
||||
|
||||
else
|
||||
echo "[!] No magisk_patched file could be found!"
|
||||
abort_script
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -606,6 +610,13 @@ CopyMagiskToAVD() {
|
||||
fi
|
||||
|
||||
ADBWORKDIR=/data/data/com.android.shell
|
||||
adb shell "cd $ADBWORKDIR" 2>/dev/null
|
||||
|
||||
if [ "$?" != "0" ]; then
|
||||
echo "[!] $ADBWORKDIR doesn't exist, switching to tmp'"
|
||||
ADBWORKDIR=/data/local/tmp
|
||||
fi
|
||||
|
||||
ADBBASEDIR=$ADBWORKDIR/Magisk
|
||||
echo "[-] In any AVD via ADB, you can execute code without root in $ADBWORKDIR"
|
||||
|
||||
@@ -1181,20 +1192,7 @@ mkdir -p $TMP/ramdisk
|
||||
|
||||
cd $TMP/ramdisk > /dev/null
|
||||
$BASEDIR/busybox cpio -F $CPIO -i *lib* > /dev/null 2>&1
|
||||
#../../busybox cpio -F ../../ramdisk.cpio -i *lib*
|
||||
#if [ -e $TMP/ramdisk/.backup ]; then
|
||||
#$BASEDIR/magiskboot cpio $CPIO "extract .backup" > /dev/null 2>&1
|
||||
#chmod 750 .backup/ -R
|
||||
#rm .backup/ -R
|
||||
#$BASEDIR/magiskboot cpio $CPIO "extract lib" > /dev/null 2>&1
|
||||
#$BASEDIR/magiskboot cpio $CPIO "rm -r .backup" > /dev/null 2>&1
|
||||
#magiskboot cpio ../../ramdisk.cpio "rm -r .backup"
|
||||
#$BASEDIR/busybox cpio -F $CPIO -i > /dev/null 2>&1
|
||||
#../../magiskboot cpio ../../ramdisk.cpio "extract lib*"
|
||||
#../../magiskboot cpio ../../ramdisk.cpio "rm -r .backup"
|
||||
#../../busybox cpio -F ../../ramdisk.cpio -t
|
||||
../../magiskboot cpio ../../ramdisk.cpio "rm -r /lib/modules/*"
|
||||
#fi
|
||||
../../magiskboot cpio ../../ramdisk.cpio "rm -r /lib/modules/*"
|
||||
ls -la
|
||||
cd - > /dev/null
|
||||
exit
|
||||
@@ -1300,7 +1298,7 @@ decompress_ramdisk(){
|
||||
else
|
||||
echo "[*] After decompressing ramdisk.img, magiskboot will work"
|
||||
$RAMDISK_GZ && RDF=$RDF$ENDG
|
||||
./magiskboot decompress $RDF $CPIO
|
||||
$BASEDIR/magiskboot decompress $RDF $CPIO
|
||||
fi
|
||||
#update_lib_modules
|
||||
}
|
||||
@@ -1312,7 +1310,7 @@ apply_ramdisk_hacks() {
|
||||
# cp the read-only fstab.ranchu from vendor partition and add usb:auto for SD devices
|
||||
# kernel musst have Mass-Storage + SCSI Support enabled to create /dev/block/sd* nodes
|
||||
|
||||
echo "[!] PATCHFSTAB=$PATCHFSTAB"
|
||||
#echo "[!] PATCHFSTAB=$PATCHFSTAB"
|
||||
if ("$PATCHFSTAB"); then
|
||||
echo "[-] pulling fstab.ranchu from AVD"
|
||||
cp /system/vendor/etc/fstab.ranchu $(pwd)
|
||||
@@ -1320,20 +1318,18 @@ apply_ramdisk_hacks() {
|
||||
echo "/devices/*/block/sd* auto auto defaults voldmanaged=usb:auto" >> fstab.ranchu
|
||||
#echo "/devices/*/block/loop7 auto auto defaults voldmanaged=sdcard:auto" >> fstab.ranchu
|
||||
#echo "/devices/1-* auto auto defaults voldmanaged=usb:auto" >> fstab.ranchu
|
||||
# cat fstab.ranchu
|
||||
#/system/vendor/etc/fstab.f2fs.hi3650
|
||||
./magiskboot cpio ramdisk.cpio \
|
||||
$BASEDIR/magiskboot cpio ramdisk.cpio \
|
||||
"mkdir 0755 overlay.d/vendor" \
|
||||
"mkdir 0755 overlay.d/vendor/etc" \
|
||||
"add 0644 overlay.d/vendor/etc/fstab.ranchu fstab.ranchu"
|
||||
echo "[-] overlay adding complete"
|
||||
echo "[-] jumping back to patching ramdisk for magisk init"
|
||||
else
|
||||
echo "[!] Skipping fstab.ranchu patch with /dev/block/sda"
|
||||
echo "[?] If you want fstab.ranchu patched, Call rootAVD with PATCHFSTAB"
|
||||
#echo "[-] jumping back to patching ramdisk for magisk init"
|
||||
#else
|
||||
#echo "[!] Skipping fstab.ranchu patch with /dev/block/sda"
|
||||
#echo "[?] If you want fstab.ranchu patched, Call rootAVD with PATCHFSTAB"
|
||||
fi
|
||||
|
||||
echo "[!] AddRCscripts=$AddRCscripts"
|
||||
#echo "[!] AddRCscripts=$AddRCscripts"
|
||||
if ("$AddRCscripts"); then
|
||||
echo "[*] adding *.rc files to ramdisk"
|
||||
#for f in *.rc; do
|
||||
@@ -1344,26 +1340,40 @@ apply_ramdisk_hacks() {
|
||||
for f in *.rc; do
|
||||
echo "$f" > $CSTRC
|
||||
done
|
||||
./magiskboot cpio ramdisk.cpio "add 0755 overlay.d/$CSTRC $CSTRC"
|
||||
$BASEDIR/magiskboot cpio ramdisk.cpio "add 0755 overlay.d/$CSTRC $CSTRC"
|
||||
echo "[-] overlay adding complete"
|
||||
echo "[-] jumping back to patching ramdisk for magisk init"
|
||||
else
|
||||
echo "[!] Skip adding *.rc scripts into ramdisk.img/sbin/*.rc"
|
||||
echo "[?] If you want *.rc scripts added into ramdisk.img/sbin/*.rc, Call rootAVD with AddRCscripts"
|
||||
#echo "[-] jumping back to patching ramdisk for magisk init"
|
||||
#else
|
||||
#echo "[!] Skip adding *.rc scripts into ramdisk.img/sbin/*.rc"
|
||||
#echo "[?] If you want *.rc scripts added into ramdisk.img/sbin/*.rc, Call rootAVD with AddRCscripts"
|
||||
fi
|
||||
|
||||
#$PATCHFSTAB && SKIPOVERLAYD="#" || SKIPOVERLAYD=""
|
||||
update_lib_modules
|
||||
}
|
||||
|
||||
verify_ramdisk_origin() {
|
||||
echo "[*] Verifying Boot Image Build Date"
|
||||
local property=ro.bootimage.build.date.utc
|
||||
BUILDDATEAVD=$(getprop $property)
|
||||
echo "[-] Boot Image Build Date AVD=$BUILDDATEAVD"
|
||||
BUILDDATERDF=$(cat $CPIO | grep -m 1 $property | cut -f 2 -d "=")
|
||||
if [ "$BUILDDATERDF" != "" ]; then
|
||||
echo "[-] Boot Image Build Date Ramdisk=$BUILDDATERDF"
|
||||
if [ "$BUILDDATEAVD" == "$BUILDDATERDF" ]; then
|
||||
echo "[!] Ramdisk is probably from this AVD"
|
||||
else
|
||||
echo "[!] Ramdisk is probably NOT from this AVD"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
test_ramdisk_patch_status(){
|
||||
echo "[-] Test patch status and do restore"
|
||||
echo "[-] Checking ramdisk status"
|
||||
|
||||
if [ -e ramdisk.cpio ]; then
|
||||
./magiskboot cpio ramdisk.cpio test 2>/dev/null
|
||||
$BASEDIR/magiskboot cpio ramdisk.cpio test 2>/dev/null
|
||||
STATUS=$?
|
||||
echo "[-] STATUS=$STATUS"
|
||||
echo "[-] Checking ramdisk STATUS=$STATUS"
|
||||
else
|
||||
echo "[-] Stock A only system-as-root"
|
||||
STATUS=0
|
||||
@@ -1373,8 +1383,9 @@ test_ramdisk_patch_status(){
|
||||
case $((STATUS & 3)) in
|
||||
0 ) # Stock boot
|
||||
echo "[-] Stock boot image detected"
|
||||
SHA1=`./magiskboot sha1 ramdisk.cpio 2>/dev/null`
|
||||
cp -af ramdisk.cpio ramdisk.cpio.orig 2>/dev/null
|
||||
SHA1=`$BASEDIR/magiskboot sha1 ramdisk.cpio 2>/dev/null`
|
||||
cp -af $CPIO $CPIOORIG 2>/dev/null
|
||||
verify_ramdisk_origin
|
||||
;;
|
||||
|
||||
1 ) # Magisk patched
|
||||
@@ -1414,11 +1425,11 @@ patching_ramdisk(){
|
||||
# Compress to save precious ramdisk space
|
||||
|
||||
if $IS32BITONLY || ! $IS64BITONLY ; then
|
||||
./magiskboot compress=xz magisk32 magisk32.xz
|
||||
$BASEDIR/magiskboot compress=xz magisk32 magisk32.xz
|
||||
fi
|
||||
|
||||
if $IS64BITONLY || ! $IS32BITONLY ; then
|
||||
./magiskboot compress=xz magisk64 magisk64.xz
|
||||
$BASEDIR/magiskboot compress=xz magisk64 magisk64.xz
|
||||
fi
|
||||
|
||||
$IS64BITONLY && SKIP32="#" || SKIP32=""
|
||||
@@ -1426,7 +1437,7 @@ patching_ramdisk(){
|
||||
|
||||
if $STUBAPK; then
|
||||
echo "[!] stub.apk is present, compress and add it to ramdisk"
|
||||
./magiskboot compress=xz stub.apk stub.xz
|
||||
$BASEDIR/magiskboot compress=xz stub.apk stub.xz
|
||||
fi
|
||||
|
||||
$STUBAPK && SKIPSTUB="" || SKIPSTUB="#"
|
||||
@@ -1434,14 +1445,14 @@ patching_ramdisk(){
|
||||
# Here gets the ramdisk.img patched with the magisk su files and stuff
|
||||
|
||||
echo "[*] adding overlay.d/sbin folders to ramdisk"
|
||||
./magiskboot cpio ramdisk.cpio \
|
||||
$BASEDIR/magiskboot cpio ramdisk.cpio \
|
||||
"mkdir 0750 overlay.d" \
|
||||
"mkdir 0750 overlay.d/sbin"
|
||||
|
||||
apply_ramdisk_hacks
|
||||
|
||||
echo "[!] patching the ramdisk with Magisk Init"
|
||||
./magiskboot cpio ramdisk.cpio \
|
||||
$BASEDIR/magiskboot cpio ramdisk.cpio \
|
||||
"add 0750 init magiskinit" \
|
||||
"$SKIP32 add 0644 overlay.d/sbin/magisk32.xz magisk32.xz" \
|
||||
"$SKIP64 add 0644 overlay.d/sbin/magisk64.xz magisk64.xz" \
|
||||
@@ -1466,17 +1477,39 @@ rename_copy_magisk() {
|
||||
repacking_ramdisk(){
|
||||
if [ $((STATUS & 4)) -ne 0 ]; then
|
||||
echo "[!] Compressing ramdisk before repacking it"
|
||||
./magiskboot cpio ramdisk.cpio compress
|
||||
$BASEDIR/magiskboot cpio ramdisk.cpio compress
|
||||
fi
|
||||
|
||||
echo "[*] repacking back to ramdisk.img format"
|
||||
# Rename and compress ramdisk.cpio back to ramdiskpatched4AVD.img
|
||||
./magiskboot compress=$METHOD "ramdisk.cpio" "ramdiskpatched4AVD.img"
|
||||
$BASEDIR/magiskboot compress=$METHOD "ramdisk.cpio" "ramdiskpatched4AVD.img"
|
||||
}
|
||||
|
||||
strip_html_links() {
|
||||
sed -i -e 's/<a href=/\n<a href=/g;s/<\/a>/<\/a>\n/g' "$1"
|
||||
sed -i -n '/>Update kernel to builds/p' "$1"
|
||||
sed -i -e 's/<a href=/\n<a href=/g;s/<\/a>/<\/a>\n/g' "$1"
|
||||
}
|
||||
strip_kernel_builds() {
|
||||
sed -i -n '/>Update kernel to builds/p' "$1"
|
||||
}
|
||||
strip_next_pages() {
|
||||
sed -n '/>Next/p' "$1"
|
||||
}
|
||||
find_next_pages() {
|
||||
local URL="$2"
|
||||
local NEXTPAGESRC=""
|
||||
local TMPHTML="tmp.html"
|
||||
rm -rf $TMPHTML
|
||||
NEXTPAGESRC=$(strip_next_pages $1)
|
||||
|
||||
echo "[-] Find Next Page(s)"
|
||||
while [[ "$NEXTPAGESRC" != "" ]]; do
|
||||
NEXTPAGESRC=$(echo $NEXTPAGESRC | sed -e 's/.*href=\"/\1/' -e 's/\">Next.*//')
|
||||
#echo $NEXTPAGESRC
|
||||
DownLoadFile $URL $NEXTPAGESRC $TMPHTML
|
||||
strip_html_links $TMPHTML
|
||||
cat $TMPHTML >> $1
|
||||
NEXTPAGESRC=$(strip_next_pages $TMPHTML)
|
||||
done
|
||||
}
|
||||
|
||||
update_lib_modules() {
|
||||
@@ -1489,10 +1522,28 @@ update_lib_modules() {
|
||||
fi
|
||||
local unameR=$(uname -r)
|
||||
local majmin=${unameR%.*}
|
||||
#majmin=5.15
|
||||
local installedbuild=${unameR##*ab}
|
||||
|
||||
echo "[*] Fetching Kernel Data:"
|
||||
echo "[-] Android: $AVERSION"
|
||||
echo "[-] Arch: $KERNEL_ARCH"
|
||||
echo "[-] Uname: $unameR"
|
||||
echo "[-] Version: $majmin"
|
||||
echo "[-] Build Version: $installedbuild"
|
||||
|
||||
local URL="https://android.googlesource.com"
|
||||
local KERSRC="/kernel/prebuilts/$majmin/$KERNEL_ARCH/+log/refs/heads/master"
|
||||
local MODSRC="/kernel/prebuilts/common-modules/virtual-device/$majmin/$KERNEL_ARCH/+log/refs/heads/master"
|
||||
#local TAG="android$AVERSION-mainline-sdkext-release"
|
||||
local TAG="android$AVERSION-gsi"
|
||||
#local TAG="master"
|
||||
local KERSRC="/kernel/prebuilts/$majmin/$KERNEL_ARCH/+log/refs/heads/$TAG"
|
||||
#local KERSRC="/platform/prebuilts/qemu-kernel/+log/refs/heads/$TAG"
|
||||
#https://android.googlesource.com/platform/prebuilts/qemu-kernel/+log/refs/heads/android11-gsi
|
||||
#https://android.googlesource.com/platform/prebuilts/qemu-kernel/+/refs/heads/android11-gsi
|
||||
#local KERSRC="/kernel/prebuilts/$majmin/$KERNEL_ARCH/+log/refs/heads/android$AVERSION-mainline-sdkext-release"
|
||||
|
||||
local MODSRC="/kernel/prebuilts/common-modules/virtual-device/$majmin/$KERNEL_ARCH/+log/refs/heads/$TAG"
|
||||
#local MODSRC="/kernel/prebuilts/common-modules/virtual-device/$majmin/$KERNEL_ARCH/+log/refs/heads/android$AVERSION-mainline-sdkext-release"
|
||||
local KERPREMASHTML="kernelprebuiltsmaster.html"
|
||||
local KERDST="prebuiltkernel.tar.gz"
|
||||
local MODDST="prebuiltmodules.tar.gz"
|
||||
@@ -1510,12 +1561,17 @@ update_lib_modules() {
|
||||
local ker_line_cnt=""
|
||||
local mod_line_cnt=""
|
||||
local i=""
|
||||
|
||||
|
||||
DownLoadFile $URL $KERSRC $KERPREMASHTML
|
||||
DownLoadFile $URL $MODSRC $MODPREMASHTML
|
||||
|
||||
strip_html_links $KERPREMASHTML
|
||||
strip_html_links $KERPREMASHTML
|
||||
find_next_pages $KERPREMASHTML $URL
|
||||
strip_kernel_builds $KERPREMASHTML
|
||||
|
||||
DownLoadFile $URL $MODSRC $MODPREMASHTML
|
||||
strip_html_links $MODPREMASHTML
|
||||
find_next_pages $MODPREMASHTML $URL
|
||||
strip_kernel_builds $MODPREMASHTML
|
||||
|
||||
ker_line_cnt=$(sed -n '$=' $KERPREMASHTML)
|
||||
mod_line_cnt=$(sed -n '$=' $MODPREMASHTML)
|
||||
@@ -1533,11 +1589,11 @@ update_lib_modules() {
|
||||
|
||||
echo "[*] Find common Build Versions"
|
||||
while read line; do
|
||||
BUILDVER=$(echo $line | sed -e 's/<[^>]*>//g')
|
||||
grep -e ">$BUILDVER<" -F $FILETOSTRIP >> $TMPSTRIPFILE
|
||||
if [[ "$?" == "0" ]]; then
|
||||
echo $line >> $TMPREADFILE
|
||||
fi
|
||||
BUILDVER=$(echo $line | sed -e 's/<[^>]*>//g')
|
||||
grep -e ">$BUILDVER<" -F $FILETOSTRIP >> $TMPSTRIPFILE
|
||||
if [[ "$?" == "0" ]]; then
|
||||
echo $line >> $TMPREADFILE
|
||||
fi
|
||||
done < $FILETOREAD
|
||||
|
||||
mv -f $TMPREADFILE $FILETOREAD
|
||||
@@ -2209,7 +2265,7 @@ InstallMagiskToAVD() {
|
||||
get_flags
|
||||
copyARCHfiles
|
||||
|
||||
$ENVFIXTASK && construct_environment
|
||||
#$ENVFIXTASK && construct_environment
|
||||
|
||||
if [ "$DERIVATE" == "BlueStacks" ]; then
|
||||
GetBlueStacksRamdisk
|
||||
@@ -2217,10 +2273,12 @@ InstallMagiskToAVD() {
|
||||
|
||||
if $INEMULATOR; then
|
||||
detect_ramdisk_compression_method
|
||||
decompress_ramdisk
|
||||
if $FAKEBOOTIMG; then
|
||||
process_fake_boot_img
|
||||
else
|
||||
decompress_ramdisk
|
||||
fi
|
||||
#else
|
||||
#decompress_ramdisk
|
||||
test_ramdisk_patch_status
|
||||
if [ "$DERIVATE" == "BlueStacks" ]; then
|
||||
InstallMagiskIntoBlueStacksRamdisk
|
||||
@@ -2232,7 +2290,7 @@ InstallMagiskToAVD() {
|
||||
fi
|
||||
fi
|
||||
repacking_ramdisk
|
||||
fi
|
||||
#fi
|
||||
rename_copy_magisk
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user