2021-03-28 16:57:44 +00:00
|
|
|
#!/system/bin/sh
|
2020-06-06 16:12:37 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2021-03-28 16:57:44 +00:00
|
|
|
if ! [ "$(getprop ro.boot.dynamic_partitions)" = true ];then
|
|
|
|
echo "OTA is supported only for devices with dynamic partitions!"
|
|
|
|
exit 1
|
2020-06-06 16:12:37 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-28 16:57:44 +00:00
|
|
|
flavor=$(getprop ro.product.product.name)
|
|
|
|
nextVersion=$(curl --silent -L https://raw.githubusercontent.com/phhusson/treble_experimentations/master/ota/roar/$flavor/date)
|
|
|
|
if [ -z "$nextVersion" ];then
|
|
|
|
echo "Couldn't find any OTA for $flavor"
|
|
|
|
exit 1
|
2020-06-06 16:12:37 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-28 16:57:44 +00:00
|
|
|
url=$(curl --silent -L https://raw.githubusercontent.com/phhusson/treble_experimentations/master/ota/roar/$flavor/url)
|
|
|
|
size=$(curl --silent -L https://raw.githubusercontent.com/phhusson/treble_experimentations/master/ota/roar/$flavor/size)
|
|
|
|
|
|
|
|
if [ "$(getprop ro.product.build.date.utc)" = "$nextVersion" ];then
|
|
|
|
echo "Installing $nextVersion onto itself, aborting"
|
|
|
|
exit 1
|
2020-06-06 16:12:37 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-28 16:57:44 +00:00
|
|
|
if ! curl --silent -L https://raw.githubusercontent.com/phhusson/treble_experimentations/master/ota/roar/$flavor/known_releases |grep -q $(getprop ro.product.build.date.utc);then
|
|
|
|
echo "Warning! The build you are currently running is unknown. Type YES to confirm you want to apply OTA from $url"
|
|
|
|
read answer
|
|
|
|
if ! [ "$answer" = YES ];then
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-06-06 16:12:37 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-28 16:57:44 +00:00
|
|
|
if [ -b /dev/tmp-phh ] && ! tune2fs -l /dev/tmp-phh |grep 'Last mount time' |grep -q n/a;then
|
|
|
|
echo "Warning! It looks like you modified your system image! Flashing this OTA will revert this!"
|
|
|
|
echo "Type YES to acknowledge"
|
|
|
|
read answer
|
|
|
|
if ! [ "$answer" = YES ];then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2020-06-06 16:12:37 +00:00
|
|
|
|
2021-03-28 16:57:44 +00:00
|
|
|
lptools remove system_phh
|
|
|
|
free=$(lptools free |grep -oE '[0-9]+$')
|
|
|
|
if [ "$free" -le "$size" ];then
|
|
|
|
echo "Warning! There doesn't seem to be enough space on super partition."
|
|
|
|
echo "Do you want me to try to make more space? Type YES"
|
|
|
|
read answer
|
|
|
|
if ! [ "$answer" = YES ];then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
lptools clear-cow || true
|
|
|
|
lptools unlimited-group || true
|
|
|
|
lptools remove product || true
|
|
|
|
lptools remove product$(getprop ro.boot.slot_suffix) || true
|
|
|
|
free=$(lptools free |grep -oE '[0-9]+$')
|
|
|
|
if [ "$free" -le "$size" ];then
|
|
|
|
echo "Sorry, there is still not enough space available. OTA requires $size, you have $free available"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-06-06 16:12:37 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-28 16:57:44 +00:00
|
|
|
|
|
|
|
lptools create system_phh "$size"
|
|
|
|
lptools unmap system_phh
|
|
|
|
dmDevice=$(lptools map system_phh|grep -oE '/dev/block/[^ ]*')
|
|
|
|
echo "Flashing from ${url}..."
|
|
|
|
|
|
|
|
curl -L "$url" | busybox_phh xz -d -c | simg2img_simple > $dmDevice
|
|
|
|
|
|
|
|
lptools replace system_phh system
|
|
|
|
reboot
|
|
|
|
exit 0
|