Skip to content

Commit fe3afa2

Browse files
authored
Add files via upload
1 parent f53a97b commit fe3afa2

File tree

8 files changed

+3213
-280
lines changed

8 files changed

+3213
-280
lines changed

META-INF/com/google/android/update-binary

Lines changed: 4 additions & 167 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ui_print() { echo "$1"; }
1111

1212
require_new_magisk() {
1313
ui_print "*******************************"
14-
ui_print " Please install Magisk v20.0+! "
14+
ui_print " Please install Magisk v20.4+! "
1515
ui_print "*******************************"
1616
exit 1
1717
}
@@ -27,170 +27,7 @@ mount /data 2>/dev/null
2727

2828
[ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
2929
. /data/adb/magisk/util_functions.sh
30-
[ $MAGISK_VER_CODE -lt 20000 ] && require_new_magisk
30+
[ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
3131

32-
if [ $MAGISK_VER_CODE -ge 20400 ]; then
33-
# New Magisk have complete installation logic within util_functions.sh
34-
install_module
35-
exit 0
36-
fi
37-
38-
#################
39-
# Legacy Support
40-
#################
41-
42-
TMPDIR=/dev/tmp
43-
PERSISTDIR=/sbin/.magisk/mirror/persist
44-
45-
is_legacy_script() {
46-
unzip -l "$ZIPFILE" install.sh | grep -q install.sh
47-
return $?
48-
}
49-
50-
print_modname() {
51-
local authlen len namelen pounds
52-
namelen=`echo -n $MODNAME | wc -c`
53-
authlen=$((`echo -n $MODAUTH | wc -c` + 3))
54-
[ $namelen -gt $authlen ] && len=$namelen || len=$authlen
55-
len=$((len + 2))
56-
pounds=$(printf "%${len}s" | tr ' ' '*')
57-
ui_print "$pounds"
58-
ui_print " $MODNAME "
59-
ui_print " by $MODAUTH "
60-
ui_print "$pounds"
61-
ui_print "*********************************************************"
62-
ui_print " If the systemless hosts module is available, remove it. "
63-
ui_print "*********************************************************"
64-
}
65-
66-
# Override abort as old scripts have some issues
67-
abort() {
68-
ui_print "$1"
69-
$BOOTMODE || recovery_cleanup
70-
[ -n $MODPATH ] && rm -rf $MODPATH
71-
rm -rf $TMPDIR
72-
exit 1
73-
}
74-
75-
rm -rf $TMPDIR 2>/dev/null
76-
mkdir -p $TMPDIR
77-
78-
# Preperation for flashable zips
79-
setup_flashable
80-
81-
# Mount partitions
82-
mount_partitions
83-
84-
# Detect version and architecture
85-
api_level_arch_detect
86-
87-
# Setup busybox and binaries
88-
$BOOTMODE && boot_actions || recovery_actions
89-
90-
##############
91-
# Preparation
92-
##############
93-
94-
# Extract prop file
95-
unzip -o "$ZIPFILE" module.prop -d $TMPDIR >&2
96-
[ ! -f $TMPDIR/module.prop ] && abort "! Unable to extract zip file!"
97-
98-
$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
99-
MODULEROOT=$NVBASE/$MODDIRNAME
100-
MODID=`grep_prop id $TMPDIR/module.prop`
101-
MODNAME=`grep_prop name $TMPDIR/module.prop`
102-
MODAUTH=`grep_prop author $TMPDIR/module.prop`
103-
MODPATH=$MODULEROOT/$MODID
104-
105-
# Create mod paths
106-
rm -rf $MODPATH 2>/dev/null
107-
mkdir -p $MODPATH
108-
109-
##########
110-
# Install
111-
##########
112-
113-
if is_legacy_script; then
114-
unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2
115-
116-
# Load install script
117-
. $TMPDIR/install.sh
118-
119-
# Callbacks
120-
print_modname
121-
on_install
122-
123-
# Custom uninstaller
124-
[ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh
125-
126-
# Skip mount
127-
$SKIPMOUNT && touch $MODPATH/skip_mount
128-
129-
# prop file
130-
$PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop
131-
132-
# Module info
133-
cp -af $TMPDIR/module.prop $MODPATH/module.prop
134-
135-
# post-fs-data scripts
136-
$POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh
137-
138-
# service scripts
139-
$LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh
140-
141-
ui_print "- Setting permissions"
142-
set_permissions
143-
else
144-
print_modname
145-
146-
unzip -o "$ZIPFILE" customize.sh -d $MODPATH >&2
147-
148-
if ! grep -q '^SKIPUNZIP=1$' $MODPATH/customize.sh 2>/dev/null; then
149-
ui_print "- Extracting module files"
150-
unzip -o "$ZIPFILE" -x 'META-INF/*' -d $MODPATH >&2
151-
152-
# Default permissions
153-
set_perm_recursive $MODPATH 0 0 0755 0644
154-
fi
155-
156-
# Load customization script
157-
[ -f $MODPATH/customize.sh ] && . $MODPATH/customize.sh
158-
fi
159-
160-
# Handle replace folders
161-
for TARGET in $REPLACE; do
162-
ui_print "- Replace target: $TARGET"
163-
mktouch $MODPATH$TARGET/.replace
164-
done
165-
166-
if $BOOTMODE; then
167-
# Update info for Magisk Manager
168-
mktouch $NVBASE/modules/$MODID/update
169-
cp -af $MODPATH/module.prop $NVBASE/modules/$MODID/module.prop
170-
fi
171-
172-
# Copy over custom sepolicy rules
173-
if [ -f $MODPATH/sepolicy.rule -a -e $PERSISTDIR ]; then
174-
ui_print "- Installing custom sepolicy patch"
175-
# Remove old recovery logs (which may be filling partition) to make room
176-
rm -f $PERSISTDIR/cache/recovery/*
177-
PERSISTMOD=$PERSISTDIR/magisk/$MODID
178-
mkdir -p $PERSISTMOD
179-
cp -af $MODPATH/sepolicy.rule $PERSISTMOD/sepolicy.rule || abort "! Insufficient partition size"
180-
fi
181-
182-
# Remove stuffs that don't belong to modules
183-
rm -rf \
184-
$MODPATH/system/placeholder $MODPATH/customize.sh \
185-
$MODPATH/README.md $MODPATH/.git* 2>/dev/null
186-
187-
#############
188-
# Finalizing
189-
#############
190-
191-
cd /
192-
$BOOTMODE || recovery_cleanup
193-
rm -rf $TMPDIR
194-
195-
ui_print "- Done"
196-
exit 0
32+
install_module
33+
exit 0

0 commit comments

Comments
 (0)