2021-03-28 16:57:44 +00:00
|
|
|
#!/system/bin/sh
|
2020-06-06 16:12:37 +00:00
|
|
|
|
2022-01-22 19:35:47 +00:00
|
|
|
set -ex
|
2020-06-06 16:12:37 +00:00
|
|
|
|
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)
|
2022-01-22 19:35:47 +00:00
|
|
|
if [ -f /system/phh/secure ];then
|
|
|
|
flavor=${flavor}-secure
|
|
|
|
fi
|
|
|
|
nextVersion=$(curl --silent -L https://raw.githubusercontent.com/phhusson/treble_experimentations/master/ota/squeak/$flavor/date)
|
2021-03-28 16:57:44 +00:00
|
|
|
if [ -z "$nextVersion" ];then
|
|
|
|
echo "Couldn't find any OTA for $flavor"
|
|
|
|
exit 1
|
2020-06-06 16:12:37 +00:00
|
|
|
fi
|
|
|
|
|
2022-01-22 19:35:47 +00:00
|
|
|
url=$(curl --silent -L https://raw.githubusercontent.com/phhusson/treble_experimentations/master/ota/squeak/$flavor/url)
|
|
|
|
size=$(curl --silent -L https://raw.githubusercontent.com/phhusson/treble_experimentations/master/ota/squeak/$flavor/size)
|
2021-03-28 16:57:44 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2022-01-22 19:35:47 +00:00
|
|
|
if ! curl --silent -L https://raw.githubusercontent.com/phhusson/treble_experimentations/master/ota/squeak/$flavor/known_releases |grep -q $(getprop ro.product.build.date.utc);then
|
2021-03-28 16:57:44 +00:00
|
|
|
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
|
|
|
echo "Flashing from ${url}..."
|
|
|
|
|
2022-01-22 19:35:47 +00:00
|
|
|
dmDevice=$(phh-ota new-slot)
|
|
|
|
curl -L "$url" | busybox_phh xz -d -c > $dmDevice
|
|
|
|
phh-ota switch-slot
|
2021-03-28 16:57:44 +00:00
|
|
|
|
|
|
|
reboot
|
|
|
|
exit 0
|