-
Notifications
You must be signed in to change notification settings - Fork 11
/
update-binary
47 lines (35 loc) · 1.62 KB
/
update-binary
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/sbin/sh
# Exit immediately if the device is not Treble-enabled
if [ ! $(getprop ro.treble.enabled) ]
then echo -e "ui_print Your device is not Treble-enabled!" >> /proc/self/fd/${2}
exit 1
fi
# Exit immediately if a command fails
set -e
# Extract the package to a temporary location
unzip -oq ${3} -d "/tmp/MulchWebViewInstaller"
# Create faux mountpoints
mkdir /picodroid_system
mkdir /picodroid_vendor
# Mount the neccesary partitions
mount -o rw $(readlink -f $(cd /dev && find /dev/block -type l -name system$(getprop ro.boot.slot_suffix) | head -n 1 )) /picodroid_system
mount -o rw $(readlink -f $(cd /dev && find /dev/block -type l -name vendor$(getprop ro.boot.slot_suffix) | head -n 1 )) /picodroid_vendor
# Copy the overlay to the appropriate location
cp /tmp/MulchWebViewInstaller/vendor/overlay/treble-overlay-mulch-webview.apk /picodroid_vendor/overlay
# Copy the OTA survival script to the appropriate location
if [ -d /picodroid_system/system/addon.d ]
then cp /tmp/MulchWebViewInstaller/system/addon.d/99-mulch-webview.sh /picodroid_system/system/addon.d
fi
# Make the script executable
chmod 755 /picodroid_system/system/addon.d/99-mulch-webview.sh
# Unmount the previously mounted partitions
umount -l /picodroid_system
umount -l /picodroid_vendor
# Delete de faux mountpoints
rmdir /picodroid_system
rmdir /picodroid_vendor
# Clean up the installation files
rm -rf /tmp/MulchWebViewInstaller
# Inform the user that the update has been successful
echo -e "ui_print Update successfully installed!" >> /proc/self/fd/${2}
echo -e "ui_print You can now install Mulch SystemWebView as a regular app!" >> /proc/self/fd/${2}