Skip to content

Commit 3f13066

Browse files
committed
Added script to generate the OTA json file
Signed-off-by: Arindam Bhattacharjee <abhattacharjee717@gmail.com>
0 parents  commit 3f13066

3 files changed

Lines changed: 78 additions & 0 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# android-OTA
2+
OTA (Over The Air) update of android customOS
3+
Instructions
4+
5+
Clone this repository with the following command...
6+
```bash
7+
git clone -b 15 https://github.com/AndroidOne-Experience/OTA-update.git OTA
8+
```
9+
Run:
10+
```bash
11+
bash ./OTA/generate_OTA.sh
12+
```

changelogs/miatoll.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# 06-Apr-2025
2+
- Initial Android 15 QPR2 Build

generate_ota.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
# Path to the maintainer info file (not needed anymore in minimal format)
4+
5+
# Prompt user for device codename
6+
read -p "Enter device codename (e.g. PL2, miatoll): " codename
7+
8+
# Prompt user for release tag
9+
read -p "Enter release tag (e.g. mm-yyyy): " release_tag
10+
11+
# OTA package directory and pattern
12+
ota_package_dir="out/target/product/${codename}"
13+
file_path=$(ls ${ota_package_dir}/AndroidOne-*${codename}-*.zip 2>/dev/null)
14+
15+
# Check if the OTA package exists
16+
if [[ -z "$file_path" ]]; then
17+
echo "OTA package file not found in ${ota_package_dir}."
18+
echo "Ensure the file follows the pattern: AndroidOne-*${codename}-*.zip"
19+
exit 1
20+
else
21+
echo "Found OTA package: $file_path"
22+
fi
23+
24+
# Extract info
25+
filename=$(basename "$file_path")
26+
datetime=$(grep -oP '^ro.build.date.utc=\K\d+' "${ota_package_dir}/system/build.prop" 2>/dev/null || echo "UNKNOWN")
27+
id=$(sha256sum "$file_path" | awk '{ print $1 }')
28+
size=$(stat -c%s "$file_path")
29+
version="15" # or change based on release/version scheme
30+
31+
# Replace this with your actual storage URL base
32+
base_url="https://storage.googleapis.com/rom"
33+
url="${base_url}/${filename}"
34+
35+
# Output directory
36+
output_dir="./OTA/devices"
37+
mkdir -p "$output_dir"
38+
output_file="${output_dir}/${codename}.json"
39+
40+
# Create the JSON
41+
json=$(cat <<EOF
42+
{
43+
"response": [
44+
{
45+
"datetime": "$datetime",
46+
"filename": "$filename",
47+
"id": "$id",
48+
"size": $size,
49+
"url": "$url",
50+
"version": "$version"
51+
}
52+
]
53+
}
54+
EOF
55+
)
56+
57+
# Save prettified if jq is available
58+
if command -v jq &> /dev/null; then
59+
echo "$json" | jq '.' > "$output_file"
60+
else
61+
echo "$json" > "$output_file"
62+
fi
63+
64+
echo "Minimal OTA JSON saved to $output_file"

0 commit comments

Comments
 (0)