forked from ahmedmoselhi/OrangeFox-build-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorangefox_build.sh
executable file
·234 lines (205 loc) · 7.71 KB
/
orangefox_build.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
# OrangeFox building script by SebaUbuntu
# You can find a list of all variables at OF_ROOT_DIR/vendor/recovery/orangefox_build_vars.txt
SCRIPT_VERSION="v2.2"
#!/bin/bash
# For clean environment
unset TARGET_DEVICE
unset TW_DEVICE_VERSION
unset BUILD_TYPE
unset TARGET_ARCH
unset OF_SCREEN_H
unset CLEAN_BUILD_NEEDED
unset TG_POST
clear
# OrangeFox logo function
NORMAL=$(tput sgr0)
REVERSE=$(tput smso)
logo() {
printf "${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE} ${NORMAL} ${REVERSE}\n"
printf "${NORMAL} \n"
printf " OrangeFox Recovery Project \n\n"
printf " Build script by SebaUbuntu \n"
printf " $SCRIPT_VERSION \n\n"
}
logo
# AOSP enviroment setup
printf "AOSP environment setup, please wait...\n"
. build/envsetup.sh
clear
logo
# Ask user if a clean build is needed
printf "Do you want to post this on Telegram channel or group?\nFor info read README.md\nAnswer: "
read TG_POST
case $TG_POST in
yes|y|true|1)
TG_POST=Yes
printf "\nTelegram posting of this release activated\n\n"
sleep 1
;;
*)
TG_POST=No
printf "\nTelegram posting of this release not requested, skipping...\n\n"
sleep 1
;;
esac
# Telegram API values import
IFS="
"
if [ $TG_POST = "Yes" ]
then
if [ -f telegram_api.txt ]
then
for i in $(cat telegram_api.txt)
do
if [ "$(printf '%s' "$i" | cut -c1)" != "#" ]
then
export $i
fi
done
else
printf "Telegram API values not found! Telegram post will be skipped\n\n"
exit
fi
fi
IFS=" "
clear
logo
# Ask user if a clean build is needed
printf "Do you want to do a clean build?\nAnswer: "
read CLEAN_BUILD_NEEDED
case $CLEAN_BUILD_NEEDED in
yes|y|true|1)
CLEAN_BUILD_NEEDED=Yes
printf "\nDeleting out/ dir, please wait...\n"
make clean
sleep 2
clear
;;
*)
CLEAN_BUILD_NEEDED=No
printf "\nClean build not required, skipping..."
sleep 2
clear
;;
esac
logo
# what device are we building for?
printf "Insert the device codename you want to build for\nCodename: "
read TARGET_DEVICE
clear
logo
# Ask for release version
printf "Insert the version number of this release\nExample: R10.1\nVersion: "
read TW_DEVICE_VERSION
export TW_DEVICE_VERSION
clear
logo
# Ask for release type
printf "Insert the type of this release\nPossibilities: Stable - Beta - RC - Unofficial\nRelease type: "
read BUILD_TYPE
export BUILD_TYPE
clear
logo
# Export device-specific variables, remember to create a config file!
IFS="
"
if [ -f configs/"$TARGET_DEVICE"_ofconfig ]
then
for i in $(cat configs/"$TARGET_DEVICE"_ofconfig)
do
if [ "$(printf '%s' "$i" | cut -c1)" != "#" ]
then
export $i
fi
done
else
printf "Device-specific config not found! Create a config file as documented in GitHub repo. Exiting...\n\n"
exit
fi
IFS=" "
# TARGET_ARCH variable is needed by OrangeFox to determine which version of binary to include
if [ -z ${TARGET_ARCH+x} ]
then
printf "You didn't set TARGET_ARCH variable in config\n"
exit
fi
# Define this value to fix graphical issues
if [ -z ${OF_SCREEN_H+x} ]
then
printf "You didn't set OF_SCREEN_H variable in config\nThis variable is needed to fix graphical issues on non-16:9 devices.\nEven if you have a 16:9 device, set it anyway."
exit
fi
# Configure some default settings for the build
# For building with mimimal TWRP
export ALLOW_MISSING_DEPENDENCIES=true
export TW_DEFAULT_LANGUAGE="en"
# This fix build bug when locale is not "C"
export LC_ALL="C"
# To use ccache to speed up building
export USE_CCACHE="1"
# To use Magiskboot patching to have better compatibility with theming and avoid rebooting to fastboot
export OF_USE_MAGISKBOOT="1"
export OF_USE_MAGISKBOOT_FOR_ALL_PATCHES="1"
# Prevent issues like bootloop on encrypted devices
export OF_DONT_PATCH_ENCRYPTED_DEVICE="1"
# Try to decrypt data when a MIUI backup is restored
export OF_OTA_RES_DECRYPT="1"
# Include full bash shell
export FOX_USE_BASH_SHELL="1"
# Include nano editor
export FOX_USE_NANO_EDITOR="1"
# Modify this variable to your name
export OF_MAINTAINER="SebaUbuntu"
# A/B devices
[ "$OF_AB_DEVICE" = "1" ] && export OF_USE_MAGISKBOOT_FOR_ALL_PATCHES="1"
# Enable ccache if declared
[ "$USE_CCACHE" = "1" ] && ccache -M 20G
# Lunch device
lunch omni_"$TARGET_DEVICE"-eng
# If lunch command fail, there is no need to continue building
if [ "$?" != "0" ]
then exit
fi
# Send message about started build
MESSAGE_ID=$(curl -s -X POST "https://api.telegram.org/bot$TG_BOT_TOKEN/sendMessage" -d chat_id=$TG_CHAT_ID -d text="Build started
OrangeFox $TW_DEVICE_VERSION $BUILD_TYPE
Device: $TARGET_DEVICE
Architecture: $TARGET_ARCH
Clean build: $CLEAN_BUILD_NEEDED
Output:" | jq -r '.result.message_id')
# Start building
mka recoveryimage
# If build had success, send file to a Telegram channel, else say failed
if [ "$?" = "0" ]
then
curl -s -X POST "https://api.telegram.org/bot$TG_BOT_TOKEN/editMessageText" -d chat_id=$TG_CHAT_ID -d message_id=$MESSAGE_ID -d text="Build finished!
OrangeFox $TW_DEVICE_VERSION $BUILD_TYPE
Device: $TARGET_DEVICE
Architecture: $TARGET_ARCH
Clean build: $CLEAN_BUILD_NEEDED
Output:"
printf "\n"
curl -F name=document -F document=@"out/target/product/$TARGET_DEVICE/OrangeFox-$TW_DEVICE_VERSION-$BUILD_TYPE-$TARGET_DEVICE.zip" -H "Content-Type:multipart/form-data" "https://api.telegram.org/bot$TG_BOT_TOKEN/sendDocument?chat_id=$TG_CHAT_ID"
printf "\n"
else
curl -s -X POST "https://api.telegram.org/bot$TG_BOT_TOKEN/editMessageText" -d chat_id=$TG_CHAT_ID -d message_id=$MESSAGE_ID -d text="Build failed!
OrangeFox $TW_DEVICE_VERSION $BUILD_TYPE
Device: $TARGET_DEVICE
Architecture: $TARGET_ARCH
Clean build: $CLEAN_BUILD_NEEDED
Output:"
printf "\n"
fi