This repository has been archived by the owner on Jul 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.sh
executable file
·80 lines (60 loc) · 1.74 KB
/
generate.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
set -euo pipefail
DEVICE="rosemary"
META="$(mktemp)" # Will be filled META-INF/com/android/metadata
getMetadataProp()
{
PROPNAME="${1}"
awk -F "=" "{ if (\$1 == \"${PROPNAME}\") print \$2 }" "${META}"
}
OTA="${1}"
if [[ ! -f "${1}" ]]
then
echo "Zip not found, bruh!"
fi
echo "- Generating LineageOS OTA for ${1}"
echo "-- Writing metatada in ${META}"
unzip -p "${OTA}" "META-INF/com/android/metadata" > "${META}"
SDK="$(getMetadataProp "post-sdk-level")"
INCR="$(getMetadataProp "post-build-incremental")"
TS="$(getMetadataProp "post-timestamp")"
BUILD_DATE="$(date --date="@${TS}" +%Y%m%d)"
echo "-- SDK: ${SDK}"
echo "-- Incremental: ${INCR}"
echo "-- Build timestamp: ${TS} (date ${BUILD_DATE})"
LINEAGE_VER=""
case "${SDK}" in
30)
LINEAGE_VER="18.1"
;;
32)
LINEAGE_VER="19.1"
;;
*)
echo "Unknown sdk ver"
exit 1
esac
VER_DIRNAME="lineage-${LINEAGE_VER/\./}"
VER_FILENAME="lineage-${LINEAGE_VER}-${BUILD_DATE}-UNOFFICIAL-rosemary.zip"
echo "-- Lineage ver: ${LINEAGE_VER} (${VER_DIRNAME})"
echo "-- Finished reading props"
echo "-- Writing ota json"
cat << EOF > "${VER_DIRNAME}/${DEVICE}.json"
{
"response": [
{
"datetime": ${TS},
"filename": "${VER_FILENAME}",
"id": "$(md5sum "${OTA}" | awk '{print $1}')",
"romtype": "unofficial",
"size": "$(stat -c%s "${OTA}")",
"url": "https://github.com/RedmiNote10S/lineage_releases/releases/download/${TS}/${VER_FILENAME}",
"version": "${LINEAGE_VER}"
}
]
}
EOF
echo "-- Generated ${VER_DIRNAME}/${DEVICE}.json"
echo "-- Making sure json seems valid"
jq -r . "${VER_DIRNAME}/${DEVICE}.json"
echo "-- Valid JSON"