Updated LZ4 and InstallPrebuiltKernelModules Routine

This commit is contained in:
NewBit
2021-10-26 23:09:21 +02:00
parent 851d360d10
commit 5c8c8be349
2 changed files with 39 additions and 19 deletions
+2
View File
@@ -266,6 +266,8 @@ rootAVD.bat %LOCALAPPDATA%\Android\Sdk\system-images\android-31\google_apis_play
### Change Logs
#### [October 2021]
* [rootAVD.sh] - Updated LZ4 decompression Routine
* [rootAVD.sh] - Updated InstallPrebuiltKernelModules Routine to support ARM64 Kernels
* [rootAVD.sh] - Updated Busybox Extraction Routine
* [General] - Added Multiarch Busybox Binarys and 64-Bit Only Support
* [General] - Added Alpha Channel to the Menu
+37 -19
View File
@@ -170,6 +170,7 @@ detect_ramdisk_compression_method() {
local FIRSTFILEBYTES
local METHOD_LZ4="02214c18"
local METHOD_GZ="1f8b0800"
COMPRESS_SIGN=""
FIRSTFILEBYTES=$(xxd -p -c8 -l8 "$RDF")
FIRSTFILEBYTES="${FIRSTFILEBYTES:0:8}"
RAMDISK_LZ4=false
@@ -183,11 +184,13 @@ detect_ramdisk_compression_method() {
RAMDISK_LZ4=true
mv $RDF $RDF$ENDG
RDF=$RDF$ENDG
COMPRESS_SIGN="$METHOD_LZ4"
elif [ "$FIRSTFILEBYTES" == "$METHOD_GZ" ]; then
ENDG=".gz"
METHOD="gzip"
RAMDISK_GZ=true
mv $RDF $RDF$ENDG
COMPRESS_SIGN="$METHOD_GZ"
fi
if [ "$ENDG" == "" ]; then
@@ -855,21 +858,21 @@ decompress_ramdisk(){
echo "[-] Multiple cpio archives detected"
REPACKRAMDISK=1
fi
fi
fi
if [[ -n "$REPACKRAMDISK" ]]; then
$RAMDISK_GZ && rm $RDF$ENDG
echo "[*] Unpacking ramdisk .."
mkdir -p $TMPDIR/ramdisk
LASTINDEX=0
NextArchiveINDEX=0
IBS=1
OBS=4096
OF=$TMPDIR/temp$ENDG
RAMDISKS=`strings -t d $RDF | grep TRAILER`
for OFFSET in $RAMDISKS
do
for OFFSET in $RAMDISKS; do
# calculate offset to next archive
if [ `echo "$OFFSET" | grep TRAILER` ]; then
# find position of end of TRAILER!!! string in image
@@ -886,29 +889,40 @@ decompress_ramdisk(){
break
done
LASTINDEX=$((START+HEAD))
fi
if $RAMDISK_LZ4; then
START=$LASTINDEX
fi
fi
continue
fi
# number of blocks we'll extract
$RAMDISK_GZ && BLOCKS=$(((OFFSET+128)/IBS))
$RAMDISK_LZ4 && BLOCKS=$(((OFFSET+19)/IBS))
if $RAMDISK_LZ4; then
if [ $LASTINDEX == "0" ]; then
echo "[*] Searching for the real End of the 1st Archive"
while [ $LASTINDEX == "0" ]; do
FIRSTFILEBYTES=$(xxd -p -c8 -l8 -s "$OFFSET" "$RDF")
FIRSTFILEBYTES="${FIRSTFILEBYTES:0:8}"
if [ "$FIRSTFILEBYTES" == "$COMPRESS_SIGN" ]; then
break
fi
OFFSET=$((OFFSET+1))
done
fi
BLOCKS=$((OFFSET/IBS))
fi
# extract and dump
echo "[-] Dumping from $LASTINDEX to $BLOCKS .."
dd if=$RDF skip=$LASTINDEX count=$BLOCKS ibs=$IBS obs=$OBS of=$OF > /dev/null 2>&1
cd $TMPDIR/ramdisk > /dev/null
$RAMDISK_GZ && cat $OF | $BASEDIR/busybox cpio -i > /dev/null 2>&1
if $RAMDISK_LZ4; then
if $RAMDISK_LZ4; then
$BASEDIR/magiskboot decompress $OF $OF.cpio
$BASEDIR/busybox cpio -F $OF.cpio -i > /dev/null 2>&1
fi
cd - > /dev/null
$RAMDISK_GZ && LASTINDEX=$OFFSET
$RAMDISK_LZ4 && LASTINDEX=$BLOCKS
LASTINDEX=$OFFSET
done
update_lib_modules
echo "[*] Repacking ramdisk .."
@@ -1082,13 +1096,17 @@ strip_html_links() {
update_lib_modules() {
local INITRAMFS=initramfs.img
if ("$AVDIsOnline"); then
if ( "$InstallPrebuiltKernelModules" ); then
if ( "$InstallPrebuiltKernelModules" ); then
local KERNEL_ARCH="x86-64"
if [[ $ABI == *"arm"* ]]; then
KERNEL_ARCH="arm64"
fi
local unameR=$(uname -r)
local majmin=${unameR%.*}
local installedbuild=${unameR##*ab}
local URL="https://android.googlesource.com"
local KERSRC="/kernel/prebuilts/$majmin/x86-64/+log/refs/heads/master"
local MODSRC="/kernel/prebuilts/common-modules/virtual-device/$majmin/x86-64/+log/refs/heads/master"
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 KERPREMASHTML="kernelprebuiltsmaster.html"
local KERDST="prebuiltkernel.tar.gz"
local MODDST="prebuiltmodules.tar.gz"
@@ -1176,9 +1194,9 @@ update_lib_modules() {
echo "[-] Downloading Kernel and its Modules..."
# Download Kernel
DownLoadFile "$URL/kernel/prebuilts/$majmin/x86-64/+archive/" $KERCOMMITID $KERDST
DownLoadFile "$URL/kernel/prebuilts/$majmin/$KERNEL_ARCH/+archive/" $KERCOMMITID $KERDST
# Download Modules
DownLoadFile "$URL/kernel/prebuilts/common-modules/virtual-device/$majmin/x86-64/+archive/" $MODCOMMITID $MODDST
DownLoadFile "$URL/kernel/prebuilts/common-modules/virtual-device/$majmin/$KERNEL_ARCH/+archive/" $MODCOMMITID $MODDST
echo "[*] Extracting kernel-$majmin to bzImage"
tar -xf $KERDST kernel-$majmin -O > bzImage