-
Notifications
You must be signed in to change notification settings - Fork 2
/
generate_xda_thread.sh
executable file
·331 lines (285 loc) · 14.5 KB
/
generate_xda_thread.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
#!/bin/bash
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
ENDCOLOR='\033[0m'
display_header() {
echo -e "${GREEN}===========================================================${ENDCOLOR}"
echo -e "${BLUE} ______ __ __ _ _ __ ${ENDCOLOR}"
echo -e "${BLUE} / ____/ ______ / /_ __/ /_(_)___ ____ | |/ / ${ENDCOLOR}"
echo -e "${BLUE} / __/ | | / / __ \/ / / / / __/ / __ \/ __ \ | / ${ENDCOLOR}"
echo -e "${BLUE} / /___ | |/ / /_/ / / /_/ / /_/ / /_/ / / / / / | ${ENDCOLOR}"
echo -e "${BLUE} /_____/ |___/\____/_/\__,_/\__/_/\____/_/ /_/ /_/|_| ${ENDCOLOR}"
echo -e "${BLUE} ${ENDCOLOR}"
echo -e "${BLUE} XDA thread generator ${ENDCOLOR}"
echo -e "${BLUE} ${ENDCOLOR}"
echo -e "${BLUE} #KeepEvolving ${ENDCOLOR}"
echo -e "${GREEN}===========================================================${ENDCOLOR}"
}
generate_thread() {
clear && display_header
# Device manufacturer
while true; do
read -p "Manufacturer name: " manufacturer
if [[ $manufacturer =~ [0-9] ]]; then
echo "Manufacturer name should not contain numbers. Please try again."
continue
fi
manufacturer_lowercase=$(echo "$manufacturer" | tr '[:upper:]' '[:lower:]')
case $manufacturer_lowercase in
"google")
manufacturer_name="[SIZE=6][B][COLOR=rgb(0, 96, 255)]G[/COLOR][COLOR=rgb(184, 49, 47)]o[/COLOR][COLOR=rgb(250, 197, 28)]o[/COLOR][COLOR=rgb(0, 96, 255)]g[/COLOR][COLOR=rgb(97, 189, 109)]l[/COLOR][COLOR=rgb(184, 49, 47)]e[/COLOR][/B][/SIZE]"
;;
"oneplus")
manufacturer_name="[B][COLOR=rgb(226, 80, 65)][SIZE=6]OnePlus[/SIZE][/COLOR][/B]"
;;
"xiaomi")
manufacturer_name="[B][COLOR=rgb(251, 160, 38)][SIZE=6]Xiaomi[/SIZE][/COLOR][/B]"
;;
*)
manufacturer_name="[B][COLOR=rgb(0, 96, 255)][SIZE=6]$(tr '[:lower:]' '[:upper:]' <<< ${manufacturer:0:1})${manufacturer:1}[/SIZE][/COLOR][/B]"
;;
esac
break
done
# Device name & codename
if [ ! -z "$manufacturer_name" ]; then
echo "Device names (separated by ',' and/or '&' e.g Pixel 7, 7 Pro & 7a): "
read -r devices
devices=$(echo "$devices" | sed 's/\s*\(,\|&\)\s*/\1/g')
IFS=',&' read -ra device_array <<< "$devices"
device_count=${#device_array[@]}
if [ $device_count -eq 1 ]; then
device="${device_array[0]}"
device_name="[COLOR=rgb(0, 96, 255)][B][SIZE=6]$device[/SIZE][/B][/COLOR]"
echo "Codename for $device: "
read codename
codenames="[COLOR=rgb(0, 96, 255)][B][SIZE=6][$codename][/SIZE][/B][/COLOR]"
else
device_name="[COLOR=rgb(0, 96, 255)][B][SIZE=6]"
codenames="[COLOR=rgb(0, 96, 255)][B][SIZE=6]"
for ((i=0; i<$device_count; i++)); do
device="${device_array[i]}"
device_name+="$device"
echo "Codename for $device: "
read codename
codenames+="[$codename]"
if [ $i -ne $(($device_count - 1)) ]; then
if [ $i -eq $(($device_count - 2)) ]; then
device_name+=" & "
codenames+=""
else
device_name+=", "
codenames+=""
fi
fi
done
device_name+="[/SIZE][/B][/COLOR]"
codenames+="[/SIZE][/B][/COLOR]"
fi
# Banner styles
while true; do
echo "Choose the banner style:"
echo "1. Center punch-hole notch"
echo "2. Left side punch-hole notch"
echo "3. No notch"
echo "4. Pop up camera"
echo "5. Tablet"
read -p "Enter your choice (1-5): " banner_style
case $banner_style in
1) banner_image="banner_style_1.png"; break;;
2) banner_image="banner_style_2.png"; break;;
3) banner_image="banner_style_3.png"; break;;
4) banner_image="banner_style_4.png"; break;;
5) banner_image="banner_style_5.png"; break;;
*) echo "Invalid choice. Please enter a number between 1 and 5.";;
esac
done
# Security patch URL/Name
while true; do
read -p "Security patch level (mm/yyyy): " security_patch_level
patch_month=${security_patch_level%%/*}
patch_year=${security_patch_level##*/}
if [[ $security_patch_level =~ ^[0-9]{2}/[0-9]{4}$ && $patch_month -ge 1 && $patch_month -le 12 ]]; then
patch_month_full=$(date -d "$patch_month/1" +%B)
security_patch_level_date="$patch_month_full $patch_year"
security_patch_url="https://source.android.com/security/bulletin/$patch_year-$patch_month-01"
current_date=$(date +%Y%m)
provided_date=$(printf "%d%02d" "$patch_year" "$patch_month")
if [[ $provided_date -le $current_date ]]; then
break
else
echo -e "${RED}The provided date is in the future. Please enter a valid date.${ENDCOLOR}"
fi
else
echo -e "${RED}Invalid format or out of range. Please use mm/yyyy format with a valid month and year.${ENDCOLOR}"
fi
done
# XDA second post URL
while true; do
read -p "XDA thread second post URL (this is where your download links should reside): " installation_images_url
if [[ $installation_images_url =~ ^https://xdaforums\.com/t/ ]]; then
break
else
echo -e "${RED}Invalid format. Please enter a URL starting with 'https://xdaforums.com/t/'.${ENDCOLOR}"
fi
done
# Manifest URL & Android version
while true; do
branches=($(curl -s "https://api.github.com/repos/Evolution-X/manifest/branches" | jq -r '.[].name'))
echo "Available branches:"
for index in "${!branches[@]}"; do
printf "%s) %s\n" "$((index+1))" "${branches[index]}"
done
read -p "Select the manifest branch used for compilation: " branch_index
if [[ ! "$branch_index" =~ ^[0-9]+$ || $branch_index -le 0 || $branch_index -gt ${#branches[@]} ]]; then
echo -e "${RED}Invalid selection. Please enter a valid option (1-${#branches[@]}).${ENDCOLOR}"
continue
fi
selected_branch=${branches[$((branch_index-1))]}
raw_manifest_url="https://raw.githubusercontent.com/Evolution-X/manifest/$selected_branch/default.xml"
xml_data=$(curl -s "$raw_manifest_url")
tree_url="https://github.com/Evolution-X/manifest/tree/$selected_branch"
if [[ ! -z "$xml_data" ]]; then
android_version=$(echo "$xml_data" | grep -oP '(?<=revision="refs/tags/android-)[^"]+')
if [[ ! -z "$android_version" ]]; then
echo -e "${GREEN}Android version detected: $android_version${ENDCOLOR}"
blob_manifest_url="https://github.com/Evolution-X/manifest/blob/$selected_branch/"
break
else
echo -e "${RED}Android version not found in the XML.${ENDCOLOR}"
fi
else
echo -e "${RED}Failed to fetch XML data from $raw_manifest_url.${ENDCOLOR}"
fi
done
# Kernel source URL
while true; do
read -p "Kernel Source URL: " kernel_source_url
if [[ $kernel_source_url =~ ^(https?://)?(www\.)?(github\.com|gitlab\.com|bitbucket\.org|git\.com|android.googlesource\.com)(.*) ]]; then
break
else
echo -e "${RED}Invalid format. Please enter a valid URL from GitHub, GitLab, Bitbucket, or any other Git hosting service.${ENDCOLOR}"
fi
done
# Clang version
while true; do
read -p "Clang Version: " clang_version
if [[ $clang_version =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
break
else
echo -e "${RED}Invalid format. Please enter a Clang version in the format of only numbers with optional decimal points (e.g., 14.0.7).${ENDCOLOR}"
fi
done
# Maintainer name
while true; do
read -p "Your full name: " maintainer_name
if [[ ! $maintainer_name =~ [0-9] ]]; then
break
else
echo -e "${RED}Invalid name. Please enter your full name without numbers.${ENDCOLOR}"
fi
done
# XDA profile URL
while true; do
read -p "XDA profile URL: " xda_profile_url_full
if [[ $xda_profile_url_full =~ ^https://xdaforums\.com/m/[[:alnum:]._%-]+.[[:digit:]]+/ ]]; then
break
else
echo -e "${RED}Invalid format. Please enter a URL in the format: https://xdaforums.com/m/username.123456/${ENDCOLOR}"
fi
done
xda_username=$(echo "$xda_profile_url_full" | awk -F'/' '{print $(NF-1)}')
xda_profile_url="https://xdaforums.com/m/$xda_username/"
# Donation URL
while true; do
read -p "Donation URL: " donation_url
if [[ $donation_url =~ ^https?:// ]]; then
break
else
echo -e "${RED}Invalid format. Please enter a valid URL starting with 'http://' or 'https://'.${ENDCOLOR}"
fi
done
# Device support URL
while true; do
read -p "Device support URL: " device_support_url
if [[ $device_support_url =~ ^(https?://)?(www\.)?(discord\.com|discord\.gg|t\.me|telegram\.me|telegram\.org)(.*) ]]; then
break
else
echo -e "${RED}Invalid format. Please enter a valid URL from Discord or Telegram.${ENDCOLOR}"
fi
done
cat << EOF > /tmp/generated_xda_thread.txt
[CENTER]
$manufacturer_name $device_name
$codenames
[IMG]https://raw.githubusercontent.com/Evolution-X/XDA/udc/assets/$banner_image[/IMG]
[SIZE=5][B][COLOR=#0060FF][B]Pixel UI, customization and more, we are Evolution X![/B][/COLOR][/B][/SIZE]
[URL='https://xdaforums.com/m/joeyhuab.4936496/']Joey Huab[/URL] - Founder/Lead Developer
[URL='https://xdaforums.com/m/anierinb.7125966/']Anierin Bliss[/URL] - Co-Founder/Co-Developer
[URL='https://xdaforums.com/m/realakito.9008281/']Akito Mizukito[/URL] - Co-Founder/Project Manager
[I]Reach us on Twitter! [URL='https://twitter.com/EvolutionXROM']@EvolutionXROM[/URL][/I]
Check out our [URL='https://evolution-x.org/']website[/URL]!
[IMG]https://raw.githubusercontent.com/Evolution-X/XDA/udc/assets/features.png[/IMG]
[URL='https://github.com/Evolution-X/XDA/blob/udc/features.md']Added features[/URL]
[IMG]https://raw.githubusercontent.com/Evolution-X/XDA/udc/assets/known_issues.png[/IMG]
[SIZE=5][B][COLOR=red]DO NOT FLASH GAPPS, THEY ARE ALREADY INCLUDED[/COLOR][/B][/SIZE]
[B][IMG]https://raw.githubusercontent.com/Evolution-X/XDA/udc/assets/installation.png[/IMG][/B]
[SPOILER]
[SIZE=5][B][COLOR=rgb(0, 96, 255)][SIZE=5][B]First Time Install[/B][/SIZE][/COLOR][/B][/SIZE]
[COLOR=rgb(251, 160, 38)](Note: These releases include firmware)[/COLOR]
1. Download boot, dtbo, vendor_kernel_boot, vendor_boot & rom for your device from [URL='$installation_images_url']here[/URL]
2. Reboot to bootloader
3. fastboot flash boot boot.img
fastboot flash dtbo dtbo.img
fastboot flash vendor_kernel_boot vendor_kernel_boot.img
fastboot flash vendor_boot vendor_boot.img
fastboot reboot recovery
4. While in recovery, navigate to Factory reset -> Format data/factory reset and confirm to format the device.
5. When done formatting, go back to the main menu and then navigate to Apply update -> Apply from ADB
6. adb sideload rom.zip (replace "rom" with actual filename)
7 (optional). Reboot to recovery (fully) to sideload any add-ons (e.g magisk)
8. Reboot to system & #KeepEvolving
[SIZE=5][B][COLOR=rgb(0, 96, 255)]Update[/COLOR][/B][/SIZE]
[SIZE=3]1. Reboot to recovery
2. While in recovery, navigate to Apply update -> Apply from ADB
3. adb sideload rom.zip (replace "rom" with actual filename)[/SIZE]
4 (optional). Reboot to recovery to sideload any add-ons (e.g magisk)
[SIZE=3]5. Reboot to system & #KeepEvolving
[COLOR=rgb(0, 96, 255)][SIZE=5][B]OTA[/B][/SIZE][/COLOR][/SIZE]
[SIZE=3]1. Check for update. If available, select "Download and install" (approx 10-15 min)
2. Reboot & #KeepEvolving[/SIZE]
[/SPOILER]
[URL='$donation_url'][IMG width="200px" height="180px"]https://raw.githubusercontent.com/Evolution-X/XDA/udc/assets/donate_to_me.png[/IMG][/URL][URL='https://discord.gg/3qbSZHx'][IMG width="200px" height="180px"]https://raw.githubusercontent.com/Evolution-X/XDA/udc/assets/official_chat.png[/IMG][/URL][URL='$device_support_url'][IMG width="200px" height="180px"]https://raw.githubusercontent.com/Evolution-X/XDA/udc/assets/device_support.png[/IMG][/URL][/CENTER]
[TABLE]
[TR]
[TD][IMG]https://raw.githubusercontent.com/Evolution-X/XDA/udc/assets/source.png[/IMG][/TD]
[/TR]
[TR]
[TD][B][COLOR=rgb(97, 189, 109)]Android version[/COLOR]:[/B] [URL='$tree_url']$android_version[/URL][/TD]
[/TR]
[TR]
[TD][B][COLOR=rgb(184, 49, 47)]Security patch level[/COLOR]:[/B] [URL='$security_patch_url']$security_patch_level_date[/URL][/TD]
[/TR]
[TR]
[TD][B][COLOR=rgb(41, 105, 176)]Build author[/COLOR]:[/B] [URL='$xda_profile_url']$maintainer_name[/URL][/TD]
[/TR]
[TR]
[TD][B][COLOR=rgb(65, 168, 95)]Kernel Source[/COLOR]:[/B] [URL]$kernel_source_url[/URL][/TD]
[/TR]
[TR]
[TD][COLOR=rgb(243, 121, 52)][B]Clang version:[/B] $clang_version[/COLOR][/TD]
[/TR]
[TR]
[TD][B][COLOR=rgb(41, 105, 176)]ROM Developer[/COLOR]:[/B] [URL='https://xdaforums.com/member.php?u=4936496']Joey Huab[/URL] & [URL='https://xdaforums.com/m/anierinb.7125966/']Anierin Bliss[/URL][/TD]
[/TR]
[TR]
[TD][B][COLOR=rgb(97, 189, 109)]Source code[/COLOR]:[/B] [URL]https://github.com/Evolution-X[/URL][/TD]
[/TR]
[/TABLE]
[CENTER][/CENTER]
EOF
echo -e "${GREEN}Thread saved to '/tmp/generated_xda_thread.txt'${ENDCOLOR}"
fi
}
generate_thread