diff --git a/ota/update.sh b/ota/update.sh index 2e6cb6c4..9df529e3 100644 --- a/ota/update.sh +++ b/ota/update.sh @@ -1,28 +1,54 @@ #!/bin/bash -set -e +set -ex -if [ $# != 1 ];then - echo "Usage: $0 " +vers="$1" + +if [ -z "$vers" ];then + echo "Usage: $0 " exit 1 fi -umount d || true -rm -Rf s.img s2.img d - -wget "$1" -O - |xz -c -d > s.img -simg2img s.img s2.img -rm -f s.img -mkdir -p d -mount -o loop,ro s2.img d - -timestamp="$(sed -nE 's/ro.product.build.date.utc=(.*)/\1/p' d/system/product/build.prop)" -flavor="$(sed -nE 's/ro.product.product.name=(.*)/\1/p' d/system/product/build.prop)" -umount d - -mkdir -p "$flavor" -echo "$timestamp" >> "$flavor/known_releases" -echo "$timestamp" > "$flavor/date" -echo "$1" > "$flavor/url" -wc -c s2.img |grep -oE '^[0-9]+' > "$flavor/size" -rm -f s2.img +rm -f ota-list.json +minUtc="" +for i in /home/phh/Treble/treble_experimentations/cloud/release/release/220208/*.xz;do + + # Grab props + unxz -dc $i |strings |grep -E -e ro.system.build.fingerprint= -e ro.build.flavor= -e ro.system.build.date.utc= > tmpprops + + utc=$(sed -n -E -e 's/ro.system.build.date.utc=//p' tmpprops) + flavor=$(sed -n -E -e 's/ro.build.flavor=//p' tmpprops |sed -E 's/-user.*//g') + if echo "$i" |grep -qE secure;then + flavor="$flavor-secure" + elif echo "$i" |grep -qE vndklite;then + flavor="$flavor-vndklite" + fi + + if [ "$minUtc" == "" ] || [ "$utc" -le "$minUtc" ];then + minUtc="$utc" + fi + size="$(du -s "$i" |grep -oE '^[0-9]+')" + url=https://github.com/phhusson/treble_experimentations/releases/download/"$vers"/"$(basename "$i")" + cat >> ota-list.json << EOF +{ "name": "$flavor", "size": $size, "url": "$url"}, +EOF +done + +# Add a stupid entry to not have to remove the trailing `,` +echo '{ "name": "useless", "size": 0, "url": "http://devnull.org"}' >> ota-list.json + +# Optimism +minUtc=$((minUtc-100)) + +cat > ota.json << EOF +{ + "version": "$vers", + "date": "$minUtc", + "variants": [ +EOF +cat ota-list.json >> ota.json + +cat >> ota.json << EOF + ] +} +EOF