-
Notifications
You must be signed in to change notification settings - Fork 14
/
gen_ota_json.sh
executable file
·42 lines (33 loc) · 1.46 KB
/
gen_ota_json.sh
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
#!/bin/bash
DEVICE=$1
REPOS="${@:2}"
d=$(date +%Y%m%d)
FILENAME=lineage-18.0-"${d}"-UNOFFICIAL-"${DEVICE}".zip
oldd=$(grep filename $DEVICE.json | cut -d '-' -f 3)
md5=$(md5sum ../out/target/product/$DEVICE/$FILENAME | cut -d ' ' -f 1)
oldmd5=$(grep '"id"' $DEVICE.json | cut -d':' -f 2)
utc=$(grep ro.build.date.utc ../out/target/product/$DEVICE/system/build.prop | cut -d '=' -f 2)
oldutc=$(grep datetime $DEVICE.json | cut -d ':' -f 2)
size=$(wc -c ../out/target/product/$DEVICE/$FILENAME | cut -d ' ' -f 1)
oldsize=$(grep size $DEVICE.json | cut -d ':' -f 2)
oldurl=$(grep url $DEVICE.json | cut -d ' ' -f 9)
# Generate the Changelog
# Clear the changelog file
echo "" > changelog.txt
for repo in ${REPOS[*]}
do
echo "########################################" >> changelog.txt
echo "${repo} Changes:" >> changelog.txt
git --git-dir ../"${repo}"/.git log --since="${oldutc}" >> changelog.txt
done
echo "########################################" >> changelog.txt
#This is where the magic happens
sed -i "s!${oldmd5}! \"${md5}\",!g" $DEVICE.json
sed -i "s!${oldutc}! \"${utc}\",!g" $DEVICE.json
sed -i "s!${oldsize}! \"${size}\",!g" $DEVICE.json
sed -i "s!${oldd}!${d}!" $DEVICE.json
#echo Generate Download URL
TAG=$(echo "${DEVICE}-${d}")
url="https://github.com/J0SH1X/Lineage-OTA/releases/download/${TAG}/${FILENAME}"
sed -i "s!${oldurl}!\"${url}\",!g" $DEVICE.json
hub release create -a ../out/target/product/$DEVICE/$FILENAME -a changelog.txt -m "${TAG}" "${TAG}"