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
4dd8d75c
Commit
4dd8d75c
authored
Feb 08, 2020
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update scripts
parent
e5f50bb7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
40 deletions
+59
-40
util_functions.sh
scripts/util_functions.sh
+59
-40
No files found.
scripts/util_functions.sh
View file @
4dd8d75c
...
@@ -135,6 +135,7 @@ recovery_cleanup() {
...
@@ -135,6 +135,7 @@ recovery_cleanup() {
# Installation Related
# Installation Related
#######################
#######################
# find_block [partname...]
find_block
()
{
find_block
()
{
for
BLOCK
in
"
$@
"
;
do
for
BLOCK
in
"
$@
"
;
do
DEVICE
=
`
find /dev/block
-type
l
-iname
$BLOCK
|
head
-n
1
`
2>/dev/null
DEVICE
=
`
find /dev/block
-type
l
-iname
$BLOCK
|
head
-n
1
`
2>/dev/null
...
@@ -157,7 +158,8 @@ find_block() {
...
@@ -157,7 +158,8 @@ find_block() {
return
1
return
1
}
}
setup_mountpoint
()
{
# setup_mntpoint <mountpoint>
setup_mntpoint
()
{
local
POINT
=
$1
local
POINT
=
$1
[
-L
$POINT
]
&&
mv
-f
$POINT
${
POINT
}
_link
[
-L
$POINT
]
&&
mv
-f
$POINT
${
POINT
}
_link
if
[
!
-d
$POINT
]
;
then
if
[
!
-d
$POINT
]
;
then
...
@@ -166,12 +168,12 @@ setup_mountpoint() {
...
@@ -166,12 +168,12 @@ setup_mountpoint() {
fi
fi
}
}
# mount_name <partname> <mountpoint> <flag>
# mount_name <partname
(s)
> <mountpoint> <flag>
mount_name
()
{
mount_name
()
{
local
PART
=
$1
local
PART
=
$1
local
POINT
=
$2
local
POINT
=
$2
local
FLAG
=
$3
local
FLAG
=
$3
setup_m
ou
ntpoint
$POINT
setup_mntpoint
$POINT
is_mounted
$POINT
&&
return
is_mounted
$POINT
&&
return
ui_print
"- Mounting
$POINT
"
ui_print
"- Mounting
$POINT
"
# First try mounting with fstab
# First try mounting with fstab
...
@@ -182,6 +184,7 @@ mount_name() {
...
@@ -182,6 +184,7 @@ mount_name() {
fi
fi
}
}
# mount_ro_ensure <partname(s)> <mountpoint>
mount_ro_ensure
()
{
mount_ro_ensure
()
{
# We handle ro partitions only in recovery
# We handle ro partitions only in recovery
$BOOTMODE
&&
return
$BOOTMODE
&&
return
...
@@ -204,7 +207,7 @@ mount_partitions() {
...
@@ -204,7 +207,7 @@ mount_partitions() {
mount_ro_ensure
"system
$SLOT
app
$SLOT
"
/system
mount_ro_ensure
"system
$SLOT
app
$SLOT
"
/system
if
[
-f
/system/init.rc
]
;
then
if
[
-f
/system/init.rc
]
;
then
SYSTEM_ROOT
=
true
SYSTEM_ROOT
=
true
setup_m
ou
ntpoint /system_root
setup_mntpoint /system_root
mount
--move
/system /system_root
mount
--move
/system /system_root
mount
-o
bind
/system_root/system /system
mount
-o
bind
/system_root/system /system
else
else
...
@@ -230,53 +233,69 @@ mount_partitions() {
...
@@ -230,53 +233,69 @@ mount_partitions() {
fi
fi
}
}
# loop_setup <ext4_img>, sets LOOPDEV
loop_setup
()
{
unset
LOOPDEV
local
LOOP
local
MINORX
=
1
[
-e
/dev/block/loop1
]
&&
MINORX
=
$(
stat
-Lc
'%T'
/dev/block/loop1
)
local
NUM
=
0
while
[
$NUM
-lt
64
]
;
do
LOOP
=
/dev/block/loop
$NUM
[
-e
$LOOP
]
||
mknod
$LOOP
b 7
$((
NUM
*
MINORX
))
if
losetup
$LOOP
"
$1
"
2>/dev/null
;
then
LOOPDEV
=
$LOOP
break
fi
NUM
=
$((
NUM
+
1
))
done
}
mount_apex
()
{
mount_apex
()
{
[
-d
/system/apex
]
||
return
$BOOTMODE
||
[
!
-d
/system/apex
]
&&
return
# APEX files present; need to extract and mount the payload imgs or if already extracted, mount folders
local
APEX DEST
local
APEX DEST LOOP MINORX NUM
setup_mntpoint /apex
setup_mountpoint /apex
[
-e
/dev/block/loop1
]
&&
MINORX
=
$(
ls
-l
/dev/block/loop1 |
awk
'{ print $6 }'
)
||
MINORX
=
1
NUM
=
0
for
APEX
in
/system/apex/
*
;
do
for
APEX
in
/system/apex/
*
;
do
DEST
=
/apex/
$(
basename
$APEX
.apex
)
DEST
=
/apex/
$(
basename
$APEX
.apex
)
[
"
$DEST
"
==
/apex/com.android.runtime.release
]
&&
DEST
=
/apex/com.android.runtime
[
"
$DEST
"
==
/apex/com.android.runtime.release
]
&&
DEST
=
/apex/com.android.runtime
mkdir
-p
$DEST
mkdir
-p
$DEST
2>/dev/null
case
$APEX
in
if
[
-f
$APEX
]
;
then
*
.apex
)
# APEX APKs, extract and loop mount
unzip
-qo
$APEX
apex_payload.img
-d
/apex
unzip
-qo
$APEX
apex_payload.img
-d
/apex
mv
-f
/apex/apex_payload.img
$DEST
.img
loop_setup apex_payload.img
mount
-t
ext4
-o
ro,noatime
$DEST
.img
$DEST
2>/dev/null
if
[
!
-z
$LOOPDEV
]
;
then
if
[
$?
!=
0
]
;
then
ui_print
"- Mounting
$DEST
"
while
[
$NUM
-lt
64
]
;
do
mount
-t
ext4
-o
ro,noatime
$LOOPDEV
$DEST
LOOP
=
/dev/block/loop
$NUM
;
fi
(
mknod
$LOOP
b 7
$((
NUM
*
MINORX
))
rm
-f
apex_payload.img
losetup
$LOOP
$DEST
.img
)
2>/dev/null
elif
[
-d
$APEX
]
;
then
NUM
=
$((
NUM
+
1
))
# APEX folders, bind mount directory
losetup
$LOOP
|
grep
-q
$DEST
.img
&&
break
ui_print
"- Mounting
$DEST
"
done
mount
-o
bind
$APEX
$DEST
mount
-t
ext4
-o
ro,loop,noatime
$LOOP
$DEST
fi
if
[
$?
!=
0
]
;
then
losetup
-d
$LOOP
2>/dev/null
fi
fi
;;
*
)
mount
-o
bind
$APEX
$DEST
;;
esac
done
done
export
ANDROID_RUNTIME_ROOT
=
/apex/com.android.runtime
export
ANDROID_RUNTIME_ROOT
=
/apex/com.android.runtime
export
ANDROID_TZDATA_ROOT
=
/apex/com.android.tzdata
export
ANDROID_TZDATA_ROOT
=
/apex/com.android.tzdata
export
BOOTCLASSPATH
=
/apex/com.android.runtime/javalib/core-oj.jar:/apex/com.android.runtime/javalib/core-libart.jar:/apex/com.android.runtime/javalib/okhttp.jar:/apex/com.android.runtime/javalib/bouncycastle.jar:/apex/com.android.runtime/javalib/apache-xml.jar:/system/framework/framework.jar:/system/framework/ext.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/ims-common.jar:/system/framework/android.test.base.jar:/system/framework/telephony-ext.jar:/apex/com.android.conscrypt/javalib/conscrypt.jar:/apex/com.android.media/javalib/updatable-media.jar
;
local
APEXRJPATH
=
/apex/com.android.runtime/javalib
local
SYSFRAME
=
/system/framework
export
BOOTCLASSPATH
=
\
$APEXRJPATH
/core-oj.jar:
$APEXRJPATH
/core-libart.jar:
$APEXRJPATH
/okhttp.jar:
\
$APEXRJPATH
/bouncycastle.jar:
$APEXRJPATH
/apache-xml.jar:
$SYSFRAME
/framework.jar:
\
$SYSFRAME
/ext.jar:
$SYSFRAME
/telephony-common.jar:
$SYSFRAME
/voip-common.jar:
\
$SYSFRAME
/ims-common.jar:
$SYSFRAME
/android.test.base.jar:
$SYSFRAME
/telephony-ext.jar:
\
/apex/com.android.conscrypt/javalib/conscrypt.jar:
\
/apex/com.android.media/javalib/updatable-media.jar
}
}
umount_apex
()
{
umount_apex
()
{
[
-d
/apex
]
||
return
[
-d
/apex
]
||
return
local
DEST
LOOP
local
DEST
SRC
for
DEST
in
$(
find /apex
-type
d
-mindepth
1
-maxdepth
1
)
;
do
for
DEST
in
/apex/
*
;
do
if
[
-f
$DEST
.img
]
;
then
[
"
$DEST
"
=
'/apex/*'
]
&&
break
LOOP
=
$(
mount |
grep
$DEST
|
cut
-d
" "
-f1
)
SRC
=
$(
grep
$DEST
/proc/mounts |
awk
'{ print $1 }'
)
fi
umount
-l
$DEST
(
umount
-l
$DEST
;
# Detach loop device just in case
losetup
-d
$
LOOP
)
2>/dev/null
losetup
-d
$
SRC
2>/dev/null
done
done
rm
-rf
/apex
rm
-rf
/apex
unset
ANDROID_RUNTIME_ROOT
unset
ANDROID_RUNTIME_ROOT
...
...
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