Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
M
Magisk
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Magisk
Commits
4e801788
Commit
4e801788
authored
Jun 10, 2017
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix shared library linking error
parent
0b4baad7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
42 deletions
+47
-42
boot_patch.sh
scripts/boot_patch.sh
+20
-23
flash_script.sh
scripts/flash_script.sh
+27
-19
No files found.
scripts/boot_patch.sh
View file @
4e801788
...
...
@@ -29,7 +29,7 @@ cd `dirname $1`
BOOTIMAGE
=
"
`
pwd
`
/
`
basename
$1
`
"
cd
"
$CWD
"
if
[
-z
$BOOTIMAGE
]
;
then
if
[
-z
"
$BOOTIMAGE
"
]
;
then
ui_print_wrap
"This script requires a boot image as a parameter"
exit
1
fi
...
...
@@ -59,17 +59,17 @@ grep_prop() {
# --cpio-add <incpio> <mode> <entry> <infile>
cpio_add
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-add
ramdisk.cpio
$1
$2
$3
./magiskboot
--cpio-add
ramdisk.cpio
$1
$2
$3
}
# --cpio-extract <incpio> <entry> <outfile>
cpio_extract
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-extract
ramdisk.cpio
$1
$2
./magiskboot
--cpio-extract
ramdisk.cpio
$1
$2
}
# --cpio-mkdir <incpio> <mode> <entry>
cpio_mkdir
()
{
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-mkdir
ramdisk.cpio
$1
$2
./magiskboot
--cpio-mkdir
ramdisk.cpio
$1
$2
}
##########################################################################################
...
...
@@ -80,11 +80,8 @@ cpio_mkdir() {
[
-z
$SOURCEDMODE
]
&&
cd
"
`
dirname
"
${
BASH_SOURCE
:-
$0
}
"
`
"
chmod
+x ./
*
# Detect ARCH
[
-d
/system/lib64
]
&&
SYSTEMLIB
=
/system/lib64
||
SYSTEMLIB
=
/system/lib
ui_print_wrap
"- Unpacking boot image"
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--unpack
$BOOTIMAGE
./magiskboot
--unpack
"
$BOOTIMAGE
"
case
$?
in
1
)
...
...
@@ -108,28 +105,28 @@ esac
# Test patch status and do restore, after this section, ramdisk.cpio.orig is guaranteed to exist
ui_print_wrap
"- Checking ramdisk status"
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-test
ramdisk.cpio
./magiskboot
--cpio-test
ramdisk.cpio
case
$?
in
0
)
# Stock boot
ui_print_wrap
"- Stock boot image detected!"
ui_print_wrap
"- Backing up stock boot image"
SHA1
=
`
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--sha1
$BOOTIMAGE
|
tail
-n
1
`
SHA1
=
`
./magiskboot
--sha1
"
$BOOTIMAGE
"
|
tail
-n
1
`
STOCKDUMP
=
stock_boot_
${
SHA1
}
.img
dd
if
=
$BOOTIMAGE
of
=
$STOCKDUMP
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--compress
$STOCKDUMP
dd
if
=
"
$BOOTIMAGE
"
of
=
$STOCKDUMP
./magiskboot
--compress
$STOCKDUMP
cp
-af
ramdisk.cpio ramdisk.cpio.orig
;;
1
)
# Magisk patched
ui_print_wrap
"- Magisk patched image detected!"
# Find SHA1 of stock boot image
if
[
-z
$SHA1
]
;
then
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-extract
ramdisk.cpio init.magisk.rc init.magisk.rc.old
./magiskboot
--cpio-extract
ramdisk.cpio init.magisk.rc init.magisk.rc.old
SHA1
=
`
grep_prop
"# STOCKSHA1"
init.magisk.rc.old
`
rm
-f
init.magisk.rc.old
fi
OK
=
false
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-restore
ramdisk.cpio
./magiskboot
--cpio-restore
ramdisk.cpio
if
[
$?
-eq
0
]
;
then
ui_print_wrap
"- Ramdisk restored from internal backup"
OK
=
true
...
...
@@ -141,8 +138,8 @@ case $? in
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
if
[
-f
${
STOCKDUMP
}
.gz
]
;
then
ui_print_wrap
"- Stock boot image backup found"
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--decompress
${
STOCKDUMP
}
.gz stock_boot.img
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--unpack
stock_boot.img
./magiskboot
--decompress
${
STOCKDUMP
}
.gz stock_boot.img
./magiskboot
--unpack
stock_boot.img
rm
-f
stock_boot.img
OK
=
true
fi
...
...
@@ -168,8 +165,8 @@ esac
ui_print_wrap
"- Patching ramdisk"
# The common patches
$KEEPVERITY
||
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-patch-dmverity
ramdisk.cpio
$KEEPFORCEENCRYPT
||
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-patch-forceencrypt
ramdisk.cpio
$KEEPVERITY
||
./magiskboot
--cpio-patch-dmverity
ramdisk.cpio
$KEEPFORCEENCRYPT
||
./magiskboot
--cpio-patch-forceencrypt
ramdisk.cpio
# Add magisk entrypoint
cpio_extract init.rc init.rc
...
...
@@ -180,7 +177,7 @@ rm -f init.rc
# sepolicy patches
cpio_extract sepolicy sepolicy
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magisk magiskpolicy
--load
sepolicy
--save
sepolicy
--minimal
./magisk magiskpolicy
--load
sepolicy
--save
sepolicy
--minimal
cpio_add 644 sepolicy sepolicy
rm
-f
sepolicy
...
...
@@ -194,7 +191,7 @@ cpio_add 750 init.magisk.rc init.magisk.rc
cpio_add 755 sbin/magisk magisk
# Create ramdisk backups
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cpio-backup
ramdisk.cpio ramdisk.cpio.orig
./magiskboot
--cpio-backup
ramdisk.cpio ramdisk.cpio.orig
rm
-f
ramdisk.cpio.orig
...
...
@@ -205,16 +202,16 @@ rm -f ramdisk.cpio.orig
# Hexpatches
# Remove Samsung RKP in stock kernel
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--hexpatch
kernel
\
./magiskboot
--hexpatch
kernel
\
49010054011440B93FA00F71E9000054010840B93FA00F7189000054001840B91FA00F7188010054
\
A1020054011440B93FA00F7140020054010840B93FA00F71E0010054001840B91FA00F7181010054
ui_print_wrap
"- Repacking boot image"
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--repack
$BOOTIMAGE
./magiskboot
--repack
"
$BOOTIMAGE
"
if
[
$?
-ne
0
]
;
then
ui_print_wrap
"! Unable to repack boot image!"
exit
1
fi
LD_LIBRARY_PATH
=
$SYSTEMLIB
./magiskboot
--cleanup
./magiskboot
--cleanup
scripts/flash_script.sh
View file @
4e801788
...
...
@@ -11,16 +11,15 @@
# Detect whether in boot mode
ps |
grep
zygote |
grep
-v
grep
>
/dev/null
&&
BOOTMODE
=
true
||
BOOTMODE
=
false
$BOOTMODE
||
ps
-A
|
grep
zygote |
grep
-v
grep
>
/dev/null
&&
BOOTMODE
=
true
$BOOTMODE
||
ps
-A
2>/dev/null
|
grep
zygote |
grep
-v
grep
>
/dev/null
&&
BOOTMODE
=
true
# This path should work in any cases
TMPDIR
=
/dev/tmp
INSTALLER
=
$TMPDIR
/magisk
COMMONDIR
=
$INSTALLER
/common
BOOTTMP
=
$TMPDIR
/boottmp
COREDIR
=
/magisk/.core
CHROMEDIR
=
$INSTALLER
/chromeos
COREDIR
=
/magisk/.core
# Default permissions
umask
022
...
...
@@ -81,16 +80,19 @@ getvar() {
find_boot_image
()
{
if
[
-z
"
$BOOTIMAGE
"
]
;
then
for
PARTITION
in
kern-a
KERN-A android_boot ANDROID_BOOT kernel KERNEL boot BOOT lnx LNX
;
do
BOOTIMAGE
=
`
readlink
/dev/block/by-name/
$PARTITION
||
readlink
/dev/block/platform/
*
/by-name/
$PARTITION
||
readlink
/dev/block/platform/
*
/
*
/by-name/
$PARTITION
`
if
[
!
-z
"
$BOOTIMAGE
"
]
;
then
break
;
fi
for
PARTITION
in
kern-a
android_boot kernel boot lnx
;
do
BOOTIMAGE
=
`
find /dev
-iname
"
$PARTITION
"
`
[
!
-z
$BOOTIMAGE
]
&&
break
done
fi
# Recovery fallback
if
[
-z
"
$BOOTIMAGE
"
]
;
then
FSTAB
=
"/etc/recovery.fstab"
[
!
-f
"
$FSTAB
"
]
&&
FSTAB
=
"/etc/recovery.fstab.bak"
[
-f
"
$FSTAB
"
]
&&
BOOTIMAGE
=
`
grep
-E
'\b/boot\b'
"
$FSTAB
"
|
grep
-oE
'/dev/[a-zA-Z0-9_./-]*'
`
for
FSTAB
in
/etc/
*
fstab
*
;
do
BOOTIMAGE
=
`
grep
-E
'\b/boot\b'
$FSTAB
|
grep
-oE
'/dev/[a-zA-Z0-9_./-]*'
`
[
!
-z
$BOOTIMAGE
]
&&
break
done
fi
[
-L
"
$BOOTIMAGE
"
]
&&
BOOTIMAGE
=
`
readlink
$BOOTIMAGE
`
}
is_mounted
()
{
...
...
@@ -194,6 +196,12 @@ if [ ! -f '/system/build.prop' ]; then
exit
1
fi
# Prefer binaries and libs in /system
[
-e
/vendor
]
||
ln
-s
/system/vendor /vendor
export
PATH
=
/system/bin:/system/xbin:/vendor/bin:
$PATH
export
LD_LIBRARY_PATH
=
/system/lib:/vendor/lib:/sbin
[
-d
/system/lib64
]
&&
export
LD_LIBRARY_PATH
=
/system/lib64:/vendor/lib64:/sbin
# read override variables
getvar KEEPVERITY
getvar KEEPFORCEENCRYPT
...
...
@@ -295,23 +303,23 @@ ui_print "- Found Boot Image: $BOOTIMAGE"
# Update our previous backup to new format if exists
if
[
-f
/data/stock_boot.img
]
;
then
SHA1
=
`
LD_LIBRARY_PATH
=
$SYSTEMLIB
$BINDIR
/magiskboot
--sha1
/data/stock_boot.img |
tail
-n
1
`
SHA1
=
`
$BINDIR
/magiskboot
--sha1
/data/stock_boot.img |
tail
-n
1
`
STOCKDUMP
=
/data/stock_boot_
${
SHA1
}
.img
mv
/data/stock_boot.img
$STOCKDUMP
LD_LIBRARY_PATH
=
$SYSTEMLIB
$BINDIR
/magiskboot
--compress
$STOCKDUMP
$BINDIR
/magiskboot
--compress
$STOCKDUMP
fi
SOURCEDMODE
=
true
cd
$MAGISKBIN
# Source the boot patcher
.
$COMMONDIR
/boot_patch.sh
$BOOTIMAGE
.
$COMMONDIR
/boot_patch.sh
"
$BOOTIMAGE
"
# Sign chromeos boot
if
[
-f
chromeos
]
;
then
echo
>
empty
LD_LIBRARY_PATH
=
$SYSTEMLIB
$CHROMEDIR
/futility vbutil_kernel
--pack
new-boot.img.signed
\
$CHROMEDIR
/futility vbutil_kernel
--pack
new-boot.img.signed
\
--keyblock
$CHROMEDIR
/kernel.keyblock
--signprivate
$CHROMEDIR
/kernel_data_key.vbprivk
\
--version
1
--vmlinuz
new-boot.img
--config
empty
--arch
arm
--bootloader
empty
--flags
0x1
...
...
@@ -320,15 +328,15 @@ if [ -f chromeos ]; then
fi
if
is_mounted /data
;
then
rm
-f
/data/stock_boot
*
mv
stock_boot
*
/data
rm
-f
/data/stock_boot
*
2>/dev/null
mv
stock_boot
*
/data
2>/dev/null
fi
ui_print
"- Flashing new boot image"
if
[
-L
$BOOTIMAGE
]
;
then
dd
if
=
new-boot.img
of
=
$BOOTIMAGE
bs
=
4096
if
[
-L
"
$BOOTIMAGE
"
]
;
then
dd
if
=
new-boot.img
of
=
"
$BOOTIMAGE
"
bs
=
4096
else
cat
new-boot.img /dev/zero |
dd
of
=
$BOOTIMAGE
bs
=
4096
cat
new-boot.img /dev/zero |
dd
of
=
"
$BOOTIMAGE
"
bs
=
4096
fi
rm
-f
new-boot.img
...
...
@@ -339,7 +347,7 @@ if ! $BOOTMODE; then
umount /magisk
losetup
-d
$MAGISKLOOP
2>/dev/null
rmdir
/magisk
umount /system
umount
-l
/system
fi
ui_print
"- Done"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment