Skip to content

Commit

Permalink
New OTA json generator
Browse files Browse the repository at this point in the history
  • Loading branch information
phhusson committed Feb 9, 2022
1 parent f027105 commit c2af9d6
Showing 1 changed file with 48 additions and 22 deletions.
70 changes: 48 additions & 22 deletions ota/update.sh
Original file line number Diff line number Diff line change
@@ -1,28 +1,54 @@
#!/bin/bash

set -e
set -ex

if [ $# != 1 ];then
echo "Usage: $0 <url to release gsi>"
vers="$1"

if [ -z "$vers" ];then
echo "Usage: $0 <github version name>"
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

This comment has been minimized.

Copy link
@penn5

penn5 Feb 10, 2022

sus


# 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

0 comments on commit c2af9d6

Please sign in to comment.