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
d17ed2b9
Commit
d17ed2b9
authored
Aug 02, 2022
by
topjohnwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support patching AVD with release builds
parent
b496923c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
18 deletions
+23
-18
build.py
build.py
+13
-5
avd_magisk.sh
scripts/avd_magisk.sh
+6
-8
avd_patch.sh
scripts/avd_patch.sh
+4
-5
No files found.
build.py
View file @
d17ed2b9
...
...
@@ -460,14 +460,17 @@ def setup_ndk(args):
def
setup_avd
(
args
):
if
not
args
.
skip
:
args
.
release
=
False
build_all
(
args
)
header
(
'* Setting up emulator'
)
abi
=
cmd_out
([
adb_path
,
'shell'
,
'getprop'
,
'ro.product.cpu.abi'
])
proc
=
execv
([
adb_path
,
'push'
,
f
'native/out/{abi}/busybox'
,
'out/app-debug.apk'
,
'scripts/avd_magisk.sh'
,
'/data/local/tmp'
])
proc
=
execv
([
adb_path
,
'push'
,
f
'native/out/{abi}/busybox'
,
'scripts/avd_magisk.sh'
,
'/data/local/tmp'
])
if
proc
.
returncode
!=
0
:
error
(
'adb push failed!'
)
apk
=
'out/app-release.apk'
if
args
.
release
else
'out/app-debug.apk'
proc
=
execv
([
adb_path
,
'push'
,
apk
,
'/data/local/tmp/magisk.apk'
])
if
proc
.
returncode
!=
0
:
error
(
'adb push failed!'
)
...
...
@@ -501,10 +504,15 @@ def patch_avd_ramdisk(args):
f
.
write
(
adv_ft
)
abi
=
cmd_out
([
adb_path
,
'shell'
,
'getprop'
,
'ro.product.cpu.abi'
])
proc
=
execv
([
adb_path
,
'push'
,
f
'native/out/{abi}/busybox'
,
'out/app-debug.apk'
,
'scripts/avd_patch.sh'
,
'/data/local/tmp'
])
proc
=
execv
([
adb_path
,
'push'
,
f
'native/out/{abi}/busybox'
,
'scripts/avd_patch.sh'
,
'/data/local/tmp'
])
if
proc
.
returncode
!=
0
:
error
(
'adb push failed!'
)
apk
=
'out/app-release.apk'
if
args
.
release
else
'out/app-debug.apk'
proc
=
execv
([
adb_path
,
'push'
,
apk
,
'/data/local/tmp/magisk.apk'
])
if
proc
.
returncode
!=
0
:
error
(
'adb push failed!'
)
proc
=
execv
([
adb_path
,
'push'
,
backup
,
'/data/local/tmp/ramdisk.cpio.tmp'
])
if
proc
.
returncode
!=
0
:
error
(
'adb push failed!'
)
...
...
scripts/avd_magisk.sh
View file @
d17ed2b9
...
...
@@ -3,8 +3,7 @@
# AVD Magisk Setup
#####################################################################
#
# Support emulator ABI: ALL
# Support API level: 23 - 31 (21 and 22 images do not have SELinux)
# Support API level: 21 - 33
#
# With an emulator booted and accessible via ADB, usage:
# ./build.py emulator
...
...
@@ -46,15 +45,15 @@ if [ -z "$FIRST_STAGE" ]; then
fi
fi
pm
install
-r
$(
pwd
)
/
app-debug
.apk
pm
install
-r
$(
pwd
)
/
magisk
.apk
# Extract files from APK
unzip
-oj
app-debug
.apk
'assets/util_functions.sh'
unzip
-oj
magisk
.apk
'assets/util_functions.sh'
.
./util_functions.sh
api_level_arch_detect
unzip
-oj
app-debug
.apk
"lib/
$ABI
/*"
"lib/
$ABI32
/libmagisk32.so"
-x
"lib/
$ABI
/libbusybox.so"
unzip
-oj
magisk
.apk
"lib/
$ABI
/*"
"lib/
$ABI32
/libmagisk32.so"
-x
"lib/
$ABI
/libbusybox.so"
for
file
in
lib
*
.so
;
do
chmod
755
$file
mv
"
$file
"
"
${
file
:3:
${#
file
}
-6
}
"
...
...
@@ -120,8 +119,7 @@ fi
# Magisk stuff
mkdir
-p
$MAGISKBIN
2>/dev/null
unzip
-oj
app-debug.apk
'assets/*'
-x
'assets/chromeos/*'
\
-x
'assets/bootctl'
-x
'assets/main.jar'
-d
$MAGISKBIN
unzip
-oj
magisk.apk
'assets/*.sh'
-d
$MAGISKBIN
mkdir
$NVBASE
/modules 2>/dev/null
mkdir
$POSTFSDATAD
2>/dev/null
mkdir
$SERVICED
2>/dev/null
...
...
@@ -135,7 +133,7 @@ cp -af ./magiskboot $MAGISKBIN/magiskboot
cp
-af
./magiskinit
$MAGISKBIN
/magiskinit
cp
-af
./busybox
$MAGISKBIN
/busybox
if
[
"
$IS64BIT
"
=
"true"
]
;
then
if
$IS64BIT
;
then
ln
-s
./magisk64
$MAGISKTMP
/magisk
else
ln
-s
./magisk32
$MAGISKTMP
/magisk
...
...
scripts/avd_patch.sh
View file @
d17ed2b9
...
...
@@ -3,8 +3,7 @@
# AVD MagiskInit Setup
#####################################################################
#
# Support emulator ABI: x86_64 and arm64
# Support API level: 23 - 31 (21 and 22 images do not have SELinux)
# Support API level: 23 - 33 (21 and 22 images do not have SELinux)
#
# With an emulator booted and accessible via ADB, usage:
# ./build.py avd_patch path/to/booted/avd-image/ramdisk.img
...
...
@@ -24,7 +23,7 @@
# rootfs w/o early mount: API 23 - 25
# rootfs with early mount: API 26 - 27
# Legacy system-as-root: API 28
# 2 stage init: API 29 - 3
1
# 2 stage init: API 29 - 3
3
#####################################################################
if
[
!
-f
/system/build.prop
]
;
then
...
...
@@ -44,12 +43,12 @@ if [ -z "$FIRST_STAGE" ]; then
fi
# Extract files from APK
unzip
-oj
app-debug
.apk
'assets/util_functions.sh'
unzip
-oj
magisk
.apk
'assets/util_functions.sh'
.
./util_functions.sh
api_level_arch_detect
unzip
-oj
app-debug
.apk
"lib/
$ABI
/*"
"lib/
$ABI32
/libmagisk32.so"
-x
"lib/
$ABI
/libbusybox.so"
unzip
-oj
magisk
.apk
"lib/
$ABI
/*"
"lib/
$ABI32
/libmagisk32.so"
-x
"lib/
$ABI
/libbusybox.so"
for
file
in
lib
*
.so
;
do
chmod
755
$file
mv
"
$file
"
"
${
file
:3:
${#
file
}
-6
}
"
...
...
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